diff --git a/.gitignore b/.gitignore index ab38b63..7e41956 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,12 @@ -.DS_Store -bin -*.userprefs -*.pidb -TestHarness +.DS_Store +*.pidb +*.suo +*.user +*.userprefs +TestHarness +UpgradeLog.htm +/.vs/ +/Backup +/**/bin/ +/**/obj/ +/WebEssentials2015-Settings.json \ No newline at end of file diff --git a/BUILD.md b/BUILD.md new file mode 100644 index 0000000..f20fde3 --- /dev/null +++ b/BUILD.md @@ -0,0 +1,7 @@ +# How to build TidyHtml5Managed + +1. Clone the source code +2. Open the solution in Visual Studio +3. Select your target configuration and platform +4. Build the project +5. Copy the TidyHtml5Managed.dll from the output folder to your application project \ No newline at end of file diff --git a/Interop/.gitignore b/Interop/.gitignore deleted file mode 100644 index e43b0f9..0000000 --- a/Interop/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/Interop/TidyOptionId.cs b/Interop/TidyOptionId.cs deleted file mode 100644 index 2f90927..0000000 --- a/Interop/TidyOptionId.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; - -namespace TidyManaged.Interop -{ - internal enum TidyOptionId - { - TidyUnknownOption, /*< Unknown option! */ - TidyIndentSpaces, /*< Indentation n spaces */ - TidyWrapLen, /*< Wrap margin */ - TidyTabSize, /*< Expand tabs to n spaces */ - TidyCharEncoding, /*< In/out character encoding */ - TidyInCharEncoding, /*< Input character encoding (if different) */ - TidyOutCharEncoding, /*< Output character encoding (if different) */ - TidyNewline, /*< Output line ending (default to platform) */ - TidyDoctypeMode, /*< See doctype property */ - TidyDoctype, /*< User specified doctype */ - TidyDuplicateAttrs, /*< Keep first or last duplicate attribute */ - TidyAltText, /*< Default text for alt attribute */ - - [Obsolete] - TidySlideStyle, /*< Style sheet for slides: not used for anything yet */ - - TidyErrFile, /*< File name to write errors to */ - TidyOutFile, /*< File name to write markup to */ - TidyWriteBack, /*< If true then output tidied markup */ - TidyShowMarkup, /*< If false, normal output is suppressed */ - TidyShowWarnings, /*< However errors are always shown */ - TidyQuiet, /*< No 'Parsing X', guessed DTD or summary */ - TidyIndentContent, /*< Indent content of appropriate tags */ - /*< "auto" does text/block level content indentation */ - TidyHideEndTags, /*< Suppress optional end tags */ - TidyXmlTags, /*< Treat input as XML */ - TidyXmlOut, /*< Create output as XML */ - TidyXhtmlOut, /*< Output extensible HTML */ - TidyHtmlOut, /*< Output plain HTML, even for XHTML input. - Yes means set explicitly. */ - TidyXmlDecl, /*< Add for XML docs */ - TidyUpperCaseTags, /*< Output tags in upper not lower case */ - TidyUpperCaseAttrs, /*< Output attributes in upper not lower case */ - TidyMakeBare, /*< Make bare HTML: remove Microsoft cruft */ - TidyMakeClean, /*< Replace presentational clutter by style rules */ - TidyLogicalEmphasis, /*< Replace i by em and b by strong */ - TidyDropPropAttrs, /*< Discard proprietary attributes */ - TidyDropFontTags, /*< Discard presentation tags */ - TidyDropEmptyParas, /*< Discard empty p elements */ - TidyFixComments, /*< Fix comments with adjacent hyphens */ - TidyBreakBeforeBR, /*< Output newline before
or not? */ - - [Obsolete] - TidyBurstSlides, /*< Create slides on each h2 element */ - - TidyNumEntities, /*< Use numeric entities */ - TidyQuoteMarks, /*< Output " marks as " */ - TidyQuoteNbsp, /*< Output non-breaking space as entity */ - TidyQuoteAmpersand, /*< Output naked ampersand as & */ - TidyWrapAttVals, /*< Wrap within attribute values */ - TidyWrapScriptlets, /*< Wrap within JavaScript string literals */ - TidyWrapSection, /*< Wrap within section tags */ - TidyWrapAsp, /*< Wrap within ASP pseudo elements */ - TidyWrapJste, /*< Wrap within JSTE pseudo elements */ - TidyWrapPhp, /*< Wrap within PHP pseudo elements */ - TidyFixBackslash, /*< Fix URLs by replacing \ with / */ - TidyIndentAttributes,/*< Newline+indent before each attribute */ - TidyXmlPIs, /*< If set to yes PIs must end with ?> */ - TidyXmlSpace, /*< If set to yes adds xml:space attr as needed */ - TidyEncloseBodyText, /*< If yes text at body is wrapped in P's */ - TidyEncloseBlockText,/*< If yes text in blocks is wrapped in P's */ - TidyKeepFileTimes, /*< If yes last modied time is preserved */ - TidyWord2000, /*< Draconian cleaning for Word2000 */ - TidyMark, /*< Add meta element indicating tidied doc */ - TidyEmacs, /*< If true format error output for GNU Emacs */ - TidyEmacsFile, /*< Name of current Emacs file */ - TidyLiteralAttribs, /*< If true attributes may use newlines */ - TidyBodyOnly, /*< Output BODY content only */ - TidyFixUri, /*< Applies URI encoding if necessary */ - TidyLowerLiterals, /*< Folds known attribute values to lower case */ - TidyHideComments, /*< Hides all (real) comments in output */ - TidyIndentCdata, /*< Indent section */ - TidyForceOutput, /*< Output document even if errors were found */ - TidyShowErrors, /*< Number of errors to put out */ - TidyAsciiChars, /*< Convert quotes and dashes to nearest ASCII char */ - TidyJoinClasses, /*< Join multiple class attributes */ - TidyJoinStyles, /*< Join multiple style attributes */ - TidyEscapeCdata, /*< Replace sections with escaped text */ -#if SUPPORT_ASIAN_ENCODINGS - TidyLanguage, /*< Language property: not used for anything yet */ - TidyNCR, /*< Allow numeric character references */ -#else - TidyLanguageNotUsed, - TidyNCRNotUsed, -#endif -#if SUPPORT_UTF16_ENCODINGS - TidyOutputBOM, /**< Output a Byte Order Mark (BOM) for UTF-16 encodings */ - /**< auto: if input stream has BOM, we output a BOM */ -#else - TidyOutputBOMNotUsed, -#endif - TidyReplaceColor, /*< Replace hex color attribute values with names */ - TidyCSSPrefix, /*< CSS class naming for -clean option */ - TidyInlineTags, /*< Declared inline tags */ - TidyBlockTags, /*< Declared block tags */ - TidyEmptyTags, /*< Declared empty tags */ - TidyPreTags, /*< Declared pre tags */ - TidyAccessibilityCheckLevel, /*< Accessibility check level - 0 (old style), or 1, 2, 3 */ - TidyVertSpace, /*< degree to which markup is spread out vertically */ -#if SUPPORT_ASIAN_ENCODINGS - TidyPunctWrap, /*< consider punctuation and breaking spaces for wrapping */ -#else - TidyPunctWrapNotUsed, -#endif - TidyMergeDivs, /*< Merge multiple DIVs */ - TidyDecorateInferredUL, /*< Mark inferred UL elements with no indent CSS */ - TidyPreserveEntities, /*< Preserve entities */ - TidySortAttributes, /*< Sort attributes */ - TidyMergeSpans, /*< Merge multiple SPANs */ - TidyAnchorAsName, /*< Define anchors as name attributes */ - N_TIDY_OPTIONS /*< Must be last */ - } -} diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e4348cc --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Frandi Dwi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 09d791d..d18dcb0 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,64 @@ -# TidyManaged - -This is a managed .NET/Mono wrapper for the open source, cross-platform Tidy library, a HTML/XHTML/XML markup parser & cleaner originally created by Dave Raggett. - -I'm not going to explain Tidy's "raison d'être" - please read [Dave Raggett's original web page](http://www.w3.org/People/Raggett/tidy/) for more information, or the [SourceForge project](http://tidy.sourceforge.net/) that has taken over maintenance of the library. - -## libtidy - -This wrapper is written in C#, and makes use of .NET platform invoke (p/invoke) functionality to interoperate with the Tidy library "libtidy" (written in portable ANSI C). - -Therefore, you'll also need a build of the binary appropriate for your platform. If you're after a 32 or 64 bit Windows build, or you want a more recent build for Mac OS X than the one that is bundled with the OS, try these: - -- [Windows 32-bit build](http://wemakeapps.net/downloads/TidyManaged/libtidy.dll.Win32.zip) -- [Windows 64-bit build](http://wemakeapps.net/downloads/TidyManaged/libtidy.dll.Win64.zip) -- [Mac x64/x86/PPC fat binary](http://wemakeapps.net/downloads/TidyManaged/libtidy.dylib.zip) - this is a newer build (25 March 2009) than the version included in default OS X installations. - -Otherwise, grab the latest source from the [SourceForge project](http://tidy.sourceforge.net/), and roll your own. - -## Sample Usage - -Here's a quick'n'dirty example using a simple console app. -Note: always remember to .Dispose() of your Document instance (or wrap it in a "using" statement), so the interop layer can clean up any unmanaged resources (memory, file handles etc) when it's done cleaning. - - using System; - using TidyManaged; - - public class Test - { - public static void Main(string[] args) - { - using (Document doc = Document.FromString("test</tootle><body>asd</body>")) - { - doc.ShowWarnings = false; - doc.Quiet = true; - doc.OutputXhtml = true; - doc.CleanAndRepair(); - string parsed = doc.Save(); - Console.WriteLine(parsed); - } - } - } - -results in: - - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - <html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <meta name="generator" content= - "HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 13), see www.w3.org" /> - <title>test - - - asd - - - -## Notes for non-Windows platforms - -Thanks to the platform-agnostic nature of ANSI C, and the excellent work of the people at the [Mono Project](http://www.mono-project.com/), you can use this wrapper library anywhere that Mono is supported, assuming you can have (or can build) a version of the underlying Tidy library for your platform. That shouldn't be too hard - it's a default part of a standard Mac OS X install, for example; it probably is for most Linux distributions as well. - -Under Mono, you might need to re-map the p/invoke calls to the appropriate library - or you might find it just works. See [this page on DLL mapping](http://www.mono-project.com/Config_DllMap) for more information on achieving this. Note: the .config file needs to be configured for the TidyManaged DLL, NOT your application's binary. - -### Example TidyManaged.dll.config - - - - - -## The API - -At this stage I've just created a basic mapping of each of the configuration options made available by Tidy to properties of the main Document object - I've renamed a few things here & there, but it should be pretty easy to figure out what each property does (the documentation included in the code includes the original Tidy option name for each property). You can read the [Tidy configuration documentation here](http://tidy.sourceforge.net/docs/quickref.html). - -## The Future - -At some point I'll add a nicer ".NET-style" API layer over the top, as it's a bit clunky (although perfectly usable) at the moment. +# TidyHtml5Managed +This is a managed .NET wrapper for the open source, cross-platform [Tidy HTML5](http://www.html-tidy.org/) library. + +TidyHtml5Managed was forked from Mark Beaton's [TidyManaged](https://github.com/markbeaton/TidyManaged), with the main objectives are to implement +the new features of Tidy HTML5 and drop support for the old Tidy library. + +Minimum version of the supported Tidy HTML5 library is [5.0.0](https://github.com/htacg/tidy-html5/releases/tag/5.0.0) + +## Usage +### From Binary +1. Create your new application project +2. Get **TidyHtml5Managed.dll** from [release page](https://github.com/frandi/TidyHtml5Managed/releases) +(or go [build yourself](BUILD.md)), and add reference to it from your application project +3. Get **tidy.dll** from [release page](http://binaries.html-tidy.org/) +(or go [build yourself](https://github.com/htacg/tidy-html5/blob/master/README/README.md)), and put it in your application project's output folder +4. Build and Run your project + +### From NuGet +1. Create your new application project +2. Install TidyHtml5Managed package from NuGet + + `Install-Package TidyHtml5Managed` + +3. Build and Run your project + +### Code Sample + +The following code is the sample of using the library in a Console Application. + +```C# +using System; +using TidyManaged; + +namespace TidyHtml5.ConsoleApp +{ + class Program + { + static void Main(string[] args) + { + string dirtyHtml = "

Test"; + Console.WriteLine("Dirty HTML: " + dirtyHtml); + + using (Document doc = Document.FromString(dirtyHtml)) + { + doc.OutputBodyOnly = AutoBool.Yes; + doc.Quiet = true; + doc.CleanAndRepair(); + string cleanHtml = doc.Save(); + + Console.WriteLine("Clean HTML: " + cleanHtml); + } + + Console.ReadKey(); + } + } +} +``` + +And here is the output: + +![sample code output](images/sampleoutput.gif) + +## License +TidyHtml5Managed uses MIT License as stated in the [License](LICENSE.md) file. diff --git a/TidyHtml5Managed.sln b/TidyHtml5Managed.sln new file mode 100644 index 0000000..a0e2edf --- /dev/null +++ b/TidyHtml5Managed.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TidyHtml5Managed", "TidyHtml5Managed\TidyHtml5Managed.csproj", "{D799633D-00EF-437C-B158-315557D930FC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TidyHtml5Managed_Net35", "TidyHtml5Managed_Net35\TidyHtml5Managed_Net35.csproj", "{94B637BE-23DC-403D-9369-A40FA2080808}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TidyHtml5Managed_Net45", "TidyHtml5Managed_Net45\TidyHtml5Managed_Net45.csproj", "{5FE3954B-6430-4B35-B5C7-5B32C515FCCD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TidyHtml5Managed_Net40", "TidyHtml5Managed_Net40\TidyHtml5Managed_Net40.csproj", "{840D7069-1605-4DC3-858B-A8F249FEDF4A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TidyHtml5Managed_Net20", "TidyHtml5Managed_Net20\TidyHtml5Managed_Net20.csproj", "{C9FF4F09-BF5E-4A10-B610-1DA0D2BD30DA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D799633D-00EF-437C-B158-315557D930FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D799633D-00EF-437C-B158-315557D930FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D799633D-00EF-437C-B158-315557D930FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D799633D-00EF-437C-B158-315557D930FC}.Release|Any CPU.Build.0 = Release|Any CPU + {94B637BE-23DC-403D-9369-A40FA2080808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94B637BE-23DC-403D-9369-A40FA2080808}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94B637BE-23DC-403D-9369-A40FA2080808}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94B637BE-23DC-403D-9369-A40FA2080808}.Release|Any CPU.Build.0 = Release|Any CPU + {5FE3954B-6430-4B35-B5C7-5B32C515FCCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5FE3954B-6430-4B35-B5C7-5B32C515FCCD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5FE3954B-6430-4B35-B5C7-5B32C515FCCD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5FE3954B-6430-4B35-B5C7-5B32C515FCCD}.Release|Any CPU.Build.0 = Release|Any CPU + {840D7069-1605-4DC3-858B-A8F249FEDF4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {840D7069-1605-4DC3-858B-A8F249FEDF4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {840D7069-1605-4DC3-858B-A8F249FEDF4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {840D7069-1605-4DC3-858B-A8F249FEDF4A}.Release|Any CPU.Build.0 = Release|Any CPU + {C9FF4F09-BF5E-4A10-B610-1DA0D2BD30DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9FF4F09-BF5E-4A10-B610-1DA0D2BD30DA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9FF4F09-BF5E-4A10-B610-1DA0D2BD30DA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9FF4F09-BF5E-4A10-B610-1DA0D2BD30DA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = TidyManaged.csproj + EndGlobalSection +EndGlobal diff --git a/AccessibilityCheckLevel.cs b/TidyHtml5Managed/AccessibilityCheckLevel.cs similarity index 97% rename from AccessibilityCheckLevel.cs rename to TidyHtml5Managed/AccessibilityCheckLevel.cs index 1a5f46d..2c45e52 100644 --- a/AccessibilityCheckLevel.cs +++ b/TidyHtml5Managed/AccessibilityCheckLevel.cs @@ -1,48 +1,48 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - ///

- /// Represents the available accessibility check levels. - /// - public enum AccessibilityCheckLevel - { - /// - /// Equivalent to Tidy Classic's accessibility checking. - /// - TidyClassic = 0, - /// - /// Priority 1. - /// - Priority1 = 1, - /// - /// Priority 2. - /// - Priority2 = 2, - /// - /// Priority 3. - /// - Priority3 = 3 - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents the available accessibility check levels. + /// + public enum AccessibilityCheckLevel + { + /// + /// Equivalent to Tidy Classic's accessibility checking. + /// + TidyClassic = 0, + /// + /// Priority 1. + /// + Priority1 = 1, + /// + /// Priority 2. + /// + Priority2 = 2, + /// + /// Priority 3. + /// + Priority3 = 3 + } +} diff --git a/AutoBool.cs b/TidyHtml5Managed/AutoBool.cs similarity index 97% rename from AutoBool.cs rename to TidyHtml5Managed/AutoBool.cs index 74a053a..32f5238 100644 --- a/AutoBool.cs +++ b/TidyHtml5Managed/AutoBool.cs @@ -1,44 +1,44 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - /// - /// Represents yes/no/auto values used by some Tidy properties. - /// - public enum AutoBool - { - /// - /// No. - /// - No, - /// - /// Yes. - /// - Yes, - /// - /// Automatic. - /// - Auto - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents yes/no/auto values used by some Tidy properties. + /// + public enum AutoBool + { + /// + /// No. + /// + No, + /// + /// Yes. + /// + Yes, + /// + /// Automatic. + /// + Auto + } +} diff --git a/DocTypeMode.cs b/TidyHtml5Managed/DocTypeMode.cs similarity index 96% rename from DocTypeMode.cs rename to TidyHtml5Managed/DocTypeMode.cs index c055f1f..50196e5 100644 --- a/DocTypeMode.cs +++ b/TidyHtml5Managed/DocTypeMode.cs @@ -1,56 +1,56 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - /// - /// Represents the available accessibility DOCTYPE modes. - /// - public enum DocTypeMode - { - /// - /// Omit DOCTYPE altogether. - /// - Omit, - - /// - /// Keep DOCTYPE in input. Set version to content. - /// - Auto, - - /// - /// Convert document to strict content model. - /// - Strict, - - /// - /// Convert document to transitional content model. - /// - Loose, - - /// - /// User-specified doctype. - /// - User - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents the available accessibility DOCTYPE modes. + /// + public enum DocTypeMode + { + /// + /// Omit DOCTYPE altogether. + /// + Omit, + + /// + /// Keep DOCTYPE in input. Set version to content. + /// + Auto, + + /// + /// Convert document to strict content model. + /// + Strict, + + /// + /// Convert document to transitional content model. + /// + Loose, + + /// + /// User-specified doctype. + /// + User + } +} diff --git a/Document.cs b/TidyHtml5Managed/Document.cs old mode 100755 new mode 100644 similarity index 83% rename from Document.cs rename to TidyHtml5Managed/Document.cs index 85c5317..d38b6d9 --- a/Document.cs +++ b/TidyHtml5Managed/Document.cs @@ -1,1105 +1,1179 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; -using TidyManaged.Interop; - -namespace TidyManaged -{ - /// - /// Represents an HTML document (or XML, XHTML) to be processed by Tidy. - /// - public class Document : IDisposable - { - #region Constructors - - Document() - { - this.handle = PInvoke.tidyCreate(); - this.disposed = false; - } - - Document(string htmlString) - : this() - { - this.htmlString = htmlString; - this.fromString = true; - } - - - Document(Stream stream) - : this() - { - this.stream = stream; - } - - #endregion - - #region Fields - - IntPtr handle; - Stream stream; - string htmlString; - bool fromString; - bool disposed; - bool cleaned; - - #endregion - - #region Properties - - DateTime? _ReleaseDate; - static readonly object releaseDateLock = new object(); - /// - /// Gets the release date of the underlying Tidy library. - /// - public DateTime ReleaseDate - { - get - { - lock (releaseDateLock) - { - if (!_ReleaseDate.HasValue) - { - DateTime val = DateTime.MinValue; - string release = Marshal.PtrToStringAnsi(PInvoke.tidyReleaseDate()); - if (release != null) - { - string[] tokens = release.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); - if (tokens.Length >= 3) - { - DateTime.TryParseExact(tokens[0] + " " + tokens[1] + " " + tokens[2], "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out val); - } - } - _ReleaseDate = val; - } - return _ReleaseDate.Value; - } - } - } - - #region HTML, XHTML, XML Options - - /// - /// [add-xml-decl] Gets or sets whether Tidy should add the XML declaration when outputting XML or XHTML. Note that if the input already includes an <?xml ... ?> declaration then this option will be ignored. If the encoding for the output is different from "ascii", one of the utf encodings or "raw", the declaration is always added as required by the XML standard. Defaults to false. - /// - public bool AddXmlDeclaration - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlDecl); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlDecl, value); } - } - - /// - /// [add-xml-space] Gets or sets whether Tidy should add xml:space="preserve" to elements such as <PRE>, <STYLE> and <SCRIPT> when generating XML. This is needed if the whitespace in such elements is to be parsed appropriately without having access to the DTD. Defaults to false. - /// - public bool AddXmlSpacePreserve - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlSpace); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlSpace, value); } - } - - /// - /// [alt-text] Gets or sets the default "alt=" text Tidy uses for <IMG> attributes. This feature is dangerous as it suppresses further accessibility warnings. You are responsible for making your documents accessible to people who can not see the images! - /// - public string DefaultAltText - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyAltText); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyAltText, value); } - } - - /// - /// [anchor-as-name] Gets or sets the deletion or addition of the name attribute in elements where it can serve as anchor. If set to true, a name attribute, if not already existing, is added along an existing id attribute if the DTD allows it. If set to false, any existing name attribute is removed if an id attribute exists or has been added. Defaults to true. - /// - public bool AnchorAsName - { - // Not available before until 18 Jun 2008 - get - { - if (this.ReleaseDate < new DateTime(2008, 6, 18)) - { - Trace.WriteLine("AnchorAsName is not supported by your version of tidylib - ignoring."); - return true; - } - return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyAnchorAsName); - } - set - { - if (this.ReleaseDate < new DateTime(2008, 6, 18)) - Trace.WriteLine("AnchorAsName is not supported by your version of tidylib - ignoring."); - else - PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyAnchorAsName, value); - } - } - - /// - /// [assume-xml-procins] Gets or sets whether Tidy should change the parsing of processing instructions to require ?> as the terminator rather than >. This option is automatically set if the input is in XML. Defaults to false. - /// - public bool ChangeXmlProcessingInstructions - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlPIs); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlPIs, value); } - } - - /// - /// [bare] Gets or sets whether Tidy should strip Microsoft specific HTML from Word 2000 documents, and output spaces rather than non-breaking spaces where they exist in the input. Defaults to false. - /// - public bool MakeBare - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMakeBare); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMakeBare, value); } - } - - /// - /// [clean] Gets or sets whether Tidy should strip out surplus presentational tags and attributes replacing them by style rules and structural markup as appropriate. It works well on the HTML saved by Microsoft Office products. Defaults to false. - /// - public bool MakeClean - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMakeClean); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMakeClean, value); } - } - - /// - /// [css-prefix] Gets or sets the prefix that Tidy uses for styles rules. By default, "c" will be used. - /// - public string CssPrefix - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyCSSPrefix); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyCSSPrefix, value); } - } - - /// - /// [decorate-inferred-ul] Gets or sets whether Tidy should decorate inferred UL elements with some CSS markup to avoid indentation to the right. Defaults to false. - /// - public bool DecorateInferredUL - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDecorateInferredUL); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDecorateInferredUL, value); } - } - - /// - /// [doctype] Gets or sets the DOCTYPE declaration generated by Tidy. If set to "Omit" the output won't contain a DOCTYPE declaration. If set to "Auto" (the default) Tidy will use an educated guess based upon the contents of the document. If set to "Strict", Tidy will set the DOCTYPE to the strict DTD. If set to "Loose", the DOCTYPE is set to the loose (transitional) DTD. Alternatively, you can supply a string for the formal public identifier (FPI). - /// - /// For example: - /// doctype: "-//ACME//DTD HTML 3.14159//EN" - /// - /// If you specify the FPI for an XHTML document, Tidy will set the system identifier to an empty string. For an HTML document, Tidy adds a system identifier only if one was already present in order to preserve the processing mode of some browsers. Tidy leaves the DOCTYPE for generic XML documents unchanged. "Omit" implies OutputNumericEntities = true. This option does not offer a validation of the document conformance. - /// - public DocTypeMode DocType - { - get { return (DocTypeMode) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyDoctypeMode); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyDoctypeMode, (uint) value); } - } - - /// - /// [drop-empty-paras] Gets or sets whether Tidy should discard empty paragraphs. Defaults to true. - /// - public bool DropEmptyParagraphs - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropEmptyParas); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropEmptyParas, value); } - } - - /// - /// [drop-font-tags] Gets or sets whether Tidy should discard <FONT> and <CENTER> tags without creating the corresponding style rules. This option can be set independently of the MakeClean option. Defaults to false. - /// - public bool DropFontTags - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropFontTags); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropFontTags, value); } - } - - /// - /// [drop-proprietary-attributes] Gets or sets whether Tidy should strip out proprietary attributes, such as MS data binding attributes. Defaults to false. - /// - public bool DropProprietaryAttributes - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropPropAttrs); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropPropAttrs, value); } - } - - /// - /// [enclose-block-text] Gets or sets whether Tidy should insert a <P> element to enclose any text it finds in any element that allows mixed content for HTML transitional but not HTML strict. Defaults to false. - /// - public bool EncloseBlockText - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEncloseBlockText); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEncloseBlockText, value); } - } - - /// - /// [enclose-text] Gets or sets whether Tidy should enclose any text it finds in the body element within a <P> element. This is useful when you want to take existing HTML and use it with a style sheet. Defaults to false. - /// - public bool EncloseBodyText - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEncloseBodyText); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEncloseBodyText, value); } - } - - /// - /// [escape-cdata] Gets or sets whether Tidy should convert <![CDATA[]]> sections to normal text. Defaults to false. - /// - public bool EscapeCdata - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEscapeCdata); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEscapeCdata, value); } - } - - /// - /// [fix-backslash] Gets or sets whether Tidy should replace backslash characters "\" in URLs with forward slashes "/". Defaults to true. - /// - public bool FixUrlBackslashes - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyFixBackslash); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyFixBackslash, value); } - } - - /// - /// [fix-bad-comments] Gets or sets whether Tidy should replace unexpected hyphens with "=" characters when it comes across adjacent hyphens. This option is provided for users of Cold Fusion which uses the comment syntax: <!--- --->. Defaults to true. - /// - public bool FixBadComments - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyFixComments); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyFixComments, value); } - } - - /// - /// [fix-uri] Gets or sets whether Tidy should check attribute values that carry URIs for illegal characters and if such are found, escape them as HTML 4 recommends. Defaults to true. - /// - public bool FixAttributeUris - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyFixUri); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyFixUri, value); } - } - - /// - /// [hide-comments] Gets or sets whether Tidy should print out comments. Defaults to false. - /// - public bool RemoveComments - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyHideComments); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyHideComments, value); } - } - - /// - /// [hide-endtags] Gets or sets whether Tidy should omit optional end-tags when generating the pretty printed markup. This option is ignored if you are outputting to XML. Defaults to false. - /// - public bool RemoveEndTags - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyHideEndTags); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyHideEndTags, value); } - } - - /// - /// [indent-cdata] Gets or sets whether Tidy should indent <![CDATA[]]> sections. Defaults to false. - /// - public bool IndentCdata - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyIndentCdata); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyIndentCdata, value); } - } - - /// - /// [input-xml] Gets or sets whether Tidy use the XML parser rather than the error correcting HTML parser. Defaults to false. - /// - public bool UseXmlParser - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlTags); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlTags, value); } - } - - /// - /// [join-classes] Gets or sets whether Tidy should combine class names to generate a single new class name, if multiple class assignments are detected on an element. Defaults to false. - /// - public bool JoinClasses - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyJoinClasses); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyJoinClasses, value); } - } - - /// - /// [join-styles] Gets or sets whether Tidy should combine styles to generate a single new style, if multiple style values are detected on an element. Defaults to true. - /// - public bool JoinStyles - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyJoinStyles); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyJoinStyles, value); } - } - - /// - /// [literal-attributes] Gets or sets whether Tidy should ensure that whitespace characters within attribute values are passed through unchanged. Defaults to false. - /// - public bool EnsureLiteralAttributes - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyLiteralAttribs); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyLiteralAttribs, value); } - } - - /// - /// [logical-emphasis] Gets or sets whether Tidy should replace any occurrence of <I> by <EM> and any occurrence of <B> by <STRONG>. In both cases, the attributes are preserved unchanged. This option can be set independently of the "MakeClean" and "DropFontTags" properties. Defaults to false. - /// - public bool UseLogicalEmphasis - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyLogicalEmphasis); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyLogicalEmphasis, value); } - } - - /// - /// [lower-literals] Gets or sets whether Tidy should convert the value of an attribute that takes a list of predefined values to lower case. This is required for XHTML documents. Defaults to false. - /// - public bool LowerCaseLiterals - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyLowerLiterals); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyLowerLiterals, value); } - } - - /// - /// [merge-divs] Gets or sets whether Tidy should merge nested <div> such as "<div><divglt;...</div></div>". If set to "Auto", the attributes of the inner <div> are moved to the outer one. As well, nested <div> with ID attributes are not merged. If set to "Yes", the attributes of the inner <div> are discarded with the exception of "class" and "style". Can be used to modify behavior of the "MakeClean" option. Defaults to Auto. - /// - public AutoBool MergeDivs - { - get { return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyMergeDivs); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyMergeDivs, (uint) value); } - } - - /// - /// [merge-spans] Gets or sets whether Tidy should merge nested <span> such as "<span><span;...</span></span>". The algorithm is identical to the one used by MergeDivs. Can be used to modify behavior of the "MakeClean" option. Defaults to "Auto". - /// - public AutoBool MergeSpans - { - // Not available before until 13 Aug 2007 - get - { - if (this.ReleaseDate < new DateTime(2007, 8, 13)) - { - Trace.WriteLine("MergeSpans is not supported by your version of tidylib - ignoring."); - return AutoBool.No; - } - return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyMergeSpans); - } - set - { - if (this.ReleaseDate < new DateTime(2007, 8, 13)) - Trace.WriteLine("MergeSpans is not supported by your version of tidylib - ignoring."); - else - PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyMergeSpans, (uint) value); - } - } - -#if SUPPORT_ASIAN_ENCODINGS - /// - /// [ncr] Gets or sets whether Tidy should allow numeric character references. Defaults to true. - /// - public bool AllowNumericCharacterReferences - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyNCR); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyNCR, value); } - } -#endif - - /// - /// [new-blocklevel-tags] Gets or sets new block-level tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note you can't change the content model for elements such as <TABLE>, <UL>, <OL> and <DL>. This option is ignored in XML mode. - /// - public string NewBlockLevelTags - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyBlockTags); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyBlockTags, value); } - } - - /// - /// [new-empty-tags] Gets or sets new empty inline tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. This option is ignored in XML mode. - /// - public string NewEmptyInlineTags - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyEmptyTags); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyEmptyTags, value); } - } - - /// - /// [new-inline-tags] Gets or sets new non-empty inline tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. This option is ignored in XML mode. - /// - public string NewInlineTags - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyInlineTags); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyInlineTags, value); } - } - - /// - /// [new-pre-tags] Gets or sets new tags that are to be processed in exactly the same way as HTML's <PRE> element. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note you can not as yet add new CDATA elements (similar to <SCRIPT>). This option is ignored in XML mode. - /// - public string NewPreTags - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyPreTags); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyPreTags, value); } - } - - /// - /// [numeric-entities] Gets or sets whether Tidy should output entities other than the built-in HTML entities (&amp;, &lt;, &gt; and &quot;) in the numeric rather than the named entity form. Only entities compatible with the DOCTYPE declaration generated are used. Entities that can be represented in the output encoding are translated correspondingly. Defaults to false. - /// - public bool OutputNumericEntities - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyNumEntities); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyNumEntities, value); } - } - - /// - /// [output-html] Gets or sets whether Tidy should generate pretty printed output, writing it as HTML. Defaults to false. - /// - public bool OutputHtml - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyHtmlOut); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyHtmlOut, value); } - } - - /// - /// [output-xhtml] Gets or sets whether Tidy should generate pretty printed output, writing it as extensible HTML. This option causes Tidy to set the DOCTYPE and default namespace as appropriate to XHTML. If a DOCTYPE or namespace is given they will checked for consistency with the content of the document. In the case of an inconsistency, the corrected values will appear in the output. For XHTML, entities can be written as named or numeric entities according to the setting of the "OutputNumericEntities" value. The original case of tags and attributes will be preserved, regardless of other options. Defaults to false. - /// - public bool OutputXhtml - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXhtmlOut); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXhtmlOut, value); } - } - - /// - /// [output-xml] Gets or sets whether Tidy should generate pretty printed output, writing it as well-formed XML. Any entities not defined in XML 1.0 will be written as numeric entities to allow them to be parsed by a XML parser. The original case of tags and attributes will be preserved, regardless of other options. Defaults to false. - /// - public bool OutputXml - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlOut); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlOut, value); } - } - - /// - /// [preserve-entities] Gets or sets whether Tidy should preserve the well-formed entitites as found in the input. Defaults to false. - /// - public bool PreserveEntities - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyPreserveEntities); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyPreserveEntities, value); } - } - - /// - /// [quote-ampersand] Gets or sets whether Tidy should output unadorned & characters as &amp;. Defaults to true. - /// - public bool QuoteAmpersands - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuoteAmpersand); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuoteAmpersand, value); } - } - - /// - /// [quote-marks] Gets or sets whether Tidy should output " characters as &quot; as is preferred by some editing environments. The apostrophe character ' is written out as &#39; since many web browsers don't yet support &apos;. Defaults to false. - /// - public bool QuoteMarks - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuoteMarks); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuoteMarks, value); } - } - - /// - /// [quote-nbsp] Gets or sets whether Tidy should output non-breaking space characters as entities, rather than as the Unicode character value 160 (decimal). Defaults to true. - /// - public bool QuoteNonBreakingSpaces - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuoteNbsp); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuoteNbsp, value); } - } - - /// - /// [repeated-attributes] Gets or sets whether Tidy should keep the first or last attribute, if an attribute is repeated, e.g. has two align attributes. Defaults to "KeepLast". - /// - public RepeatedAttributeMode RepeatedAttributeMode - { - get { return (RepeatedAttributeMode) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyDuplicateAttrs); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyDuplicateAttrs, (uint) value); } - } - - /// - /// [replace-color] Gets or sets whether Tidy should replace numeric values in color attributes by HTML/XHTML color names where defined, e.g. replace "#ffffff" with "white". Defaults to false. - /// - public bool UseColorNames - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyReplaceColor); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyReplaceColor, value); } - } - - /// - /// [show-body-only] Gets or sets whether Tidy should print only the contents of the body tag as an HTML fragment. If set to "Auto", this is performed only if the body tag has been inferred. Useful for incorporating existing whole pages as a portion of another page. This option has no effect if XML output is requested. Defaults to "No". - /// - public AutoBool OutputBodyOnly - { - // This option was changed from a Bool to an AutoBool on 24 May 2007. - get - { - if (this.ReleaseDate < new DateTime(2007, 5, 24)) - return (PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyBodyOnly) ? AutoBool.Yes : AutoBool.No); - else - return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyBodyOnly); - } - set - { - if (this.ReleaseDate < new DateTime(2007, 5, 24)) - PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyBodyOnly, (value == AutoBool.Yes)); - else - PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyBodyOnly, (uint) value); - } - } - - /// - /// [uppercase-attributes] Gets or sets whether Tidy should output attribute names in upper case. The default is false, which results in lower case attribute names, except for XML input, where the original case is preserved. - /// - public bool UpperCaseAttributes - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyUpperCaseAttrs); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyUpperCaseAttrs, value); } - } - - /// - /// [uppercase-tags] Gets or sets whether Tidy should output tag names in upper case. The default is false, which results in lower case tag names, except for XML input, where the original case is preserved. - /// - public bool UpperCaseTags - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyUpperCaseTags); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyUpperCaseTags, value); } - } - - /// - /// [word-2000] Gets or sets whether Tidy should go to great pains to strip out all the surplus stuff Microsoft Word 2000 inserts when you save Word documents as "Web pages". Doesn't handle embedded images or VML. You should consider using Word's "Save As: Web Page, Filtered". Defaults to false. - /// - public bool CleanWord2000 - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWord2000); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWord2000, value); } - } - - #endregion - - #region Diagnostics Options - - /// - /// [accessibility-check] Gets or sets the level of accessibility checking, if any, that Tidy should do. Defaults to TidyClassic. - /// - public AccessibilityCheckLevel AccessibilityCheckLevel - { - get { return (AccessibilityCheckLevel) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyAccessibilityCheckLevel); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyAccessibilityCheckLevel, (uint) value); } - } - - /// - /// [show-errors] Gets or sets the number Tidy uses to determine if further errors should be shown. If set to 0, then no errors are shown. Defaults to 6. - /// - public int MaximumErrors - { - get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyShowErrors); } - set - { - if (value < 0) value = 0; - PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyShowErrors, (uint) value); - } - } - - /// - /// [show-warnings] Gets or sets whether Tidy should suppress warnings. This can be useful when a few errors are hidden in a flurry of warnings. Defaults to true. - /// - public bool ShowWarnings - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyShowWarnings); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyShowWarnings, value); } - } - - #endregion - - #region Pretty Print Options - - /// - /// [break-before-br] Gets or sets whether Tidy should output a line break before each <BR> element. Defaults to false. - /// - public bool LineBreakBeforeBR - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyBreakBeforeBR); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyBreakBeforeBR, value); } - } - - /// - /// [indent] Gets or sets whether Tidy should indent block-level tags. If set to Auto, this option causes Tidy to decide whether or not to indent the content of tags such as TITLE, H1-H6, LI, TD, TD, or P depending on whether or not the content includes a block-level element. You are advised to avoid setting indent to Yes as this can expose layout bugs in some browsers. Defaults to No. - /// - public AutoBool IndentBlockElements - { - get { return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyIndentContent); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyIndentContent, (uint) value); } - } - - /// - /// [indent-attributes] Gets or sets whether Tidy should begin each attribute on a new line. Defaults to false. - /// - public bool IndentAttributes - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyIndentAttributes); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyIndentAttributes, value); } - } - - /// - /// [indent-spaces] Gets or sets the number of spaces Tidy uses to indent content, when indentation is enabled. Defaults to 2. - /// - public int IndentSpaces - { - get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyIndentSpaces); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyIndentSpaces, (uint) value); } - } - - /// - /// [markup] Gets or sets whether Tidy should generate a pretty printed version of the markup. Note that Tidy won't generate a pretty printed version if it finds significant errors (see ForceOutput). Defaults to true. - /// - public bool Markup - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyShowMarkup); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyShowMarkup, value); } - } - -#if SUPPORT_ASIAN_ENCODINGS - /// - /// [punctuation-wrap] Gets or sets whether Tidy should line wrap after some Unicode or Chinese punctuation characters. Defaults to false. - /// - public bool PunctuationWrap - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyPunctWrap); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyPunctWrap, value); } - } -#endif - - /// - /// [sort-attributes] Gets or sets how Tidy should sort attributes within an element using the specified sort algorithm. If set to Alpha, the algorithm is an ascending alphabetic sort. Defaults to None. - /// - public SortStrategy AttributeSortType - { - // Not available before until 6 Jun 2007 - get - { - if (this.ReleaseDate < new DateTime(2007, 6, 12)) - { - Trace.WriteLine("AttributeSortType is not supported by your version of tidylib - ignoring."); - return SortStrategy.None; - } - return (SortStrategy) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidySortAttributes); - } - set - { - if (this.ReleaseDate < new DateTime(2007, 6, 12)) - Trace.WriteLine("AttributeSortType is not supported by your version of tidylib - ignoring."); - else - PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidySortAttributes, (uint) value); - } - } - - /// - /// [tab-size] Gets or sets the number of columns that Tidy uses between successive tab stops. It is used to map tabs to spaces when reading the input. Tidy never outputs tabs. Defaults to 8. - /// - public int TabSize - { - get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyTabSize); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyTabSize, (uint) value); } - } - - /// - /// [vertical-space] Gets or sets whether Tidy should add some empty lines for readability. Defaults to false. - /// - public bool AddVerticalSpace - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyVertSpace); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyVertSpace, value); } - } - - /// - /// [wrap] Gets or sets the right margin Tidy uses for line wrapping. Tidy tries to wrap lines so that they do not exceed this length. Set wrap to zero if you want to disable line wrapping. Defaults to 68. - /// - public int WrapAt - { - get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyWrapLen); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyWrapLen, (uint) value); } - } - - /// - /// [wrap-asp] Gets or sets whether Tidy should line wrap text contained within ASP pseudo elements, which look like: <% ... %>. Defaults to true. - /// - public bool WrapAsp - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapAsp); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapAsp, value); } - } - - /// - /// [wrap-attributes] Gets or sets whether Tidy should line wrap attribute values, for easier editing. This option can be set independently of WrapAcriptLiterals. Defaults to false. - /// - public bool WrapAttributeValues - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapAttVals); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapAttVals, value); } - } - - /// - /// [wrap-jste] Gets or sets whether Tidy should line wrap text contained within JSTE pseudo elements, which look like: <# ... #>. Defaults to true. - /// - public bool WrapJste - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapJste); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapJste, value); } - } - - /// - /// [wrap-php] Gets or sets whether Tidy should line wrap text contained within PHP pseudo elements, which look like: <?php ... ?>. Defaults to true. - /// - public bool WrapPhp - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapPhp); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapPhp, value); } - } - - /// - /// [wrap-script-literals] Gets or sets whether Tidy should line wrap string literals that appear in script attributes. Tidy wraps long script string literals by inserting a backslash character before the line break. Defaults to false. - /// - public bool WrapScriptLiterals - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapScriptlets); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapScriptlets, value); } - } - - /// - /// [wrap-sections] Gets or sets whether Tidy should line wrap text contained within <![ ... ]> section tags. Defaults to true. - /// - public bool WrapSections - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapSection); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapSection, value); } - } - - #endregion - - #region Character Encoding Options - - /// - /// [ascii-chars] Gets or sets whether &emdash;, &rdquo;, and other named character entities are downgraded to their closest ascii equivalents when the "MakeClean" option is set to true. Defaults to false. - /// - public bool AsciiEntities - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyAsciiChars); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyAsciiChars, value); } - } - - /// - /// [char-encoding] Gets or sets character encoding Tidy uses for both the input and output. For ascii, Tidy will accept Latin-1 (ISO-8859-1) character values, but will use entities for all characters whose value > 127. For raw, Tidy will output values above 127 without translating them into entities. For latin1, characters above 255 will be written as entities. For utf8, Tidy assumes that both input and output is encoded as UTF-8. You can use iso2022 for files encoded using the ISO-2022 family of encodings e.g. ISO-2022-JP. For mac and win1252, Tidy will accept vendor specific character values, but will use entities for all characters whose value > 127. For unsupported encodings, use an external utility to convert to and from UTF-8. Defaults to "Ascii". - /// - public EncodingType CharacterEncoding - { - get { return (EncodingType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyCharEncoding); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyCharEncoding, (uint) value); } - } - - /// - /// [input-encoding] Gets or sets character encoding Tidy uses for the input. See CharacterEncoding for more info. Defaults to "Latin1". - /// - public EncodingType InputCharacterEncoding - { - get { return (EncodingType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyInCharEncoding); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyInCharEncoding, (uint) value); } - } - - /// - /// [newline] Gets or sets the type of newline. The default is appropriate to the current platform: CRLF on PC-DOS, MS-Windows and OS/2, CR on Classic Mac OS, and LF everywhere else (Unix and Linux). - /// - public NewlineType NewLine - { - get { return (NewlineType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyNewline); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyNewline, (uint) value); } - } - -#if SUPPORT_UTF16_ENCODINGS - /// - /// [output-bom] Gets or sets whether Tidy should write a Unicode Byte Order Mark character (BOM; also known as Zero Width No-Break Space; has value of U+FEFF) to the beginning of the output; only for UTF-8 and UTF-16 output encodings. If set to "auto", this option causes Tidy to write a BOM to the output only if a BOM was present at the beginning of the input. A BOM is always written for XML/XHTML output using UTF-16 output encodings. Defaults to "Auto". - /// - public AutoBool OutputByteOrderMark - { - get { return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyOutputBOM); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyOutputBOM, (uint) value); } - } -#endif - - /// - /// [output-encoding] Gets or sets character encoding Tidy uses for the output. See CharacterEncoding for more info. May only be different from input-encoding for Latin encodings (ascii, latin0, latin1, mac, win1252, ibm858). Defaults to "Ascii". - /// - public EncodingType OutputCharacterEncoding - { - get { return (EncodingType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyOutCharEncoding); } - set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyOutCharEncoding, (uint) value); } - } - - #endregion - - #region Miscellaneous Options - - /// - /// [error-file] Gets or sets the error file Tidy uses for errors and warnings. Normally errors and warnings are output to "stderr". Defaults to null. - /// - public string ErrorFile - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyErrFile); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyErrFile, value); } - } - - /// - /// [force-output] Gets or sets whether Tidy should produce output even if errors are encountered. Use this option with care - if Tidy reports an error, this means Tidy was not able to, or is not sure how to, fix the error, so the resulting output may not reflect your intention. Defaults to false. - /// - public bool ForceOutput - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyForceOutput); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyForceOutput, value); } - } - - /// - /// [gnu-emacs] Gets or sets whether Tidy should change the format for reporting errors and warnings to a format that is more easily parsed by GNU Emacs. Defaults to false. - /// - public bool UseGnuEmacsErrorFormat - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEmacs); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEmacs, value); } - } - - /// - /// [keep-time] Gets or sets whether Tidy should keep the original modification time of files that Tidy modifies in place. The default is no. Setting the option to yes allows you to tidy files without causing these files to be uploaded to a web server when using a tool such as SiteCopy. Note this feature is not supported on some platforms. Defaults to false. - /// - public bool KeepModificationTimestamp - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyKeepFileTimes); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyKeepFileTimes, value); } - } - - /// - /// [output-file] Gets or sets the output file Tidy uses for markup. Normally markup is written to "stdout". Defaults to null. - /// - public string OutputFile - { - get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyOutFile); } - set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyOutFile, value); } - } - - /// - /// [quiet] Gets or sets whether Tidy should output the summary of the numbers of errors and warnings, or the welcome or informational messages. Defaults to false. - /// - public bool Quiet - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuiet); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuiet, value); } - } - - /// - /// [tidy-mark] Gets or sets whether Tidy should add a meta element to the document head to indicate that the document has been tidied. Tidy won't add a meta element if one is already present. Defaults to true. - /// - public bool AddTidyMetaElement - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMark); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMark, value); } - } - - /// - /// [write-back] Gets or sets whether Tidy should write back the tidied markup to the same file it read from. You are advised to keep copies of important files before tidying them, as on rare occasions the result may not be what you expect. Defaults to false. - /// - public bool WriteBack - { - get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWriteBack); } - set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWriteBack, value); } - } - - #endregion - - #endregion - - #region Methods - - /// - /// Parses input markup, and executes configured cleanup and repair operations. - /// - public void CleanAndRepair() - { - if (fromString) - { - EncodingType tempEnc = this.InputCharacterEncoding; - this.InputCharacterEncoding = EncodingType.Utf8; - PInvoke.tidyParseString(this.handle, this.htmlString); - this.InputCharacterEncoding = tempEnc; - } - else - { - InputSource input = new InputSource(this.stream); - PInvoke.tidyParseSource(this.handle, ref input.TidyInputSource); - } - PInvoke.tidyCleanAndRepair(this.handle); - cleaned = true; - } - - /// - /// Saves the processed markup to a string. - /// - /// A string containing the processed markup. - public string Save() - { - if (!cleaned) - throw new InvalidOperationException("CleanAndRepair() must be called before Save()."); - - var tempEnc = this.CharacterEncoding; - var tempBOM = this.OutputByteOrderMark; - this.OutputCharacterEncoding = EncodingType.Utf8; - this.OutputByteOrderMark = AutoBool.No; - - uint bufferLength = 1; - byte[] htmlBytes; - GCHandle handle = new GCHandle(); - do - { - // Buffer was too small - bufferLength should now be the required length, so try again... - if (handle.IsAllocated) handle.Free(); - - // this setting appears to be reset by libtidy after calling tidySaveString; we need to set it each time - this.OutputCharacterEncoding = EncodingType.Utf8; - - htmlBytes = new byte[bufferLength]; - handle = GCHandle.Alloc(htmlBytes, GCHandleType.Pinned); - } while (PInvoke.tidySaveString(this.handle, handle.AddrOfPinnedObject(), ref bufferLength) == -12); - - handle.Free(); - - this.OutputCharacterEncoding = tempEnc; - this.OutputByteOrderMark = tempBOM; - return Encoding.UTF8.GetString(htmlBytes); - } - - /// - /// Saves the processed markup to a file. - /// - /// The full filesystem path of the file to save the markup to. - public void Save(string filePath) - { - if (!cleaned) - throw new InvalidOperationException("CleanAndRepair() must be called before Save()."); - - PInvoke.tidySaveFile(this.handle, filePath); - } - - /// - /// Saves the processed markup to the supplied stream. - /// - /// A to write the markup to. - public void Save(Stream stream) - { - if (!cleaned) - throw new InvalidOperationException("CleanAndRepair() must be called before Save()."); - - EncodingType tempEnc = this.OutputCharacterEncoding; - if (fromString) this.OutputCharacterEncoding = EncodingType.Utf8; - OutputSink sink = new OutputSink(stream); - PInvoke.tidySaveSink(this.handle, ref sink.TidyOutputSink); - if (fromString) this.OutputCharacterEncoding = tempEnc; - } - - #endregion - - #region Static Methods - - /// - /// Creates a new instance from a containing HTML. - /// - /// The HTML string to be processed. - public static Document FromString(string htmlString) - { - if (htmlString == null) - throw new ArgumentNullException("htmlString"); - - return new Document(htmlString); - } - - /// - /// Creates a new instance from a file. - /// - /// The full filesystem path of the HTML document to be processed. - public static Document FromFile(string filePath) - { - if (!File.Exists(filePath)) - throw new FileNotFoundException("File not found.", filePath); - - return new Document(new FileStream(filePath, FileMode.Open)); - } - - /// - /// Creates a new instance from a instance. - /// - /// A instance containing the HTML document to be processed. - public static Document FromStream(Stream stream) - { - if (stream == null) - throw new ArgumentNullException("stream"); - if (!stream.CanRead) - throw new ArgumentException("Stream must be readable."); - if (!stream.CanSeek) - throw new ArgumentException("Stream must be seekable."); - - return new Document(stream); - } - - #endregion - - #region IDisposable Members - - /// - /// Disposes of all unmanaged resources. - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Disposes of all unmanaged resources. - /// - /// Indicates whether the the document is already being disposed of. - protected virtual void Dispose(bool disposing) - { - if (!this.disposed) - { - if (disposing) - { - if (this.stream != null) this.stream.Dispose(); - PInvoke.tidyRelease(this.handle); - } - this.handle = IntPtr.Zero; - this.stream = null; - this.disposed = true; - } - } - - #endregion - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.Globalization; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using TidyManaged.Interop; + +namespace TidyManaged +{ + /// + /// Represents an HTML document (or XML, XHTML) to be processed by Tidy. + /// + public partial class Document : IDisposable + { + #region Constructors + + Document() + { + this.handle = PInvoke.tidyCreate(); + this.disposed = false; + } + + Document(string htmlString) + : this() + { + this.htmlString = htmlString; + this.fromString = true; + } + + Document(Stream stream) + : this() + { + this.stream = stream; + } + + #endregion + + #region Fields + + IntPtr handle; + Stream stream; + string htmlString; + bool fromString; + bool disposed; + bool cleaned; + + #endregion + + #region Properties + + DateTime? _ReleaseDate; + static readonly object releaseDateLock = new object(); + /// + /// Gets the release date of the underlying Tidy library. + /// + [Obsolete("Please use LibraryVersion instead")] + public DateTime ReleaseDate + { + get + { + lock (releaseDateLock) + { + if (!_ReleaseDate.HasValue) + { + DateTime val = DateTime.MinValue; + string release = Marshal.PtrToStringAnsi(PInvoke.tidyReleaseDate()); + if (release != null) + { + string[] tokens = release.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + if (tokens.Length >= 3) + { + DateTime.TryParseExact(tokens[0] + " " + tokens[1] + " " + tokens[2], "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out val); + } + } + _ReleaseDate = val; + } + return _ReleaseDate.Value; + } + } + } + + /// + /// Gets the version of the underlying Tidy library + /// + public VersionInfo LibraryVersion + { + get + { + if (_libVersion == null) + _libVersion = new VersionInfo(Marshal.PtrToStringAnsi(PInvoke.tidyLibraryVersion())); + + return _libVersion; + } + } + private VersionInfo _libVersion; + + #region HTML, XHTML, XML Options + + /// + /// [add-xml-decl] Gets or sets whether Tidy should add the XML declaration when outputting XML or XHTML. Note that if the input already includes an <?xml ... ?> declaration then this option will be ignored. If the encoding for the output is different from "ascii", one of the utf encodings or "raw", the declaration is always added as required by the XML standard. Defaults to false. + /// + public bool AddXmlDeclaration + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlDecl); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlDecl, value); } + } + + /// + /// [add-xml-space] Gets or sets whether Tidy should add xml:space="preserve" to elements such as <PRE>, <STYLE> and <SCRIPT> when generating XML. This is needed if the whitespace in such elements is to be parsed appropriately without having access to the DTD. Defaults to false. + /// + public bool AddXmlSpacePreserve + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlSpace); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlSpace, value); } + } + + /// + /// [alt-text] Gets or sets the default "alt=" text Tidy uses for <IMG> attributes. This feature is dangerous as it suppresses further accessibility warnings. You are responsible for making your documents accessible to people who can not see the images! + /// + public string DefaultAltText + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyAltText); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyAltText, value); } + } + + /// + /// [anchor-as-name] Gets or sets the deletion or addition of the name attribute in elements where it can serve as anchor. If set to true, a name attribute, if not already existing, is added along an existing id attribute if the DTD allows it. If set to false, any existing name attribute is removed if an id attribute exists or has been added. Defaults to true. + /// + public bool AnchorAsName + { + get + { + return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyAnchorAsName); + } + set + { + PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyAnchorAsName, value); + } + } + + /// + /// [assume-xml-procins] Gets or sets whether Tidy should change the parsing of processing instructions to require ?> as the terminator rather than >. This option is automatically set if the input is in XML. Defaults to false. + /// + public bool ChangeXmlProcessingInstructions + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlPIs); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlPIs, value); } + } + + /// + /// [bare] Gets or sets whether Tidy should strip Microsoft specific HTML from Word 2000 documents, and output spaces rather than non-breaking spaces where they exist in the input. Defaults to false. + /// + public bool MakeBare + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMakeBare); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMakeBare, value); } + } + + /// + /// [clean] Gets or sets whether Tidy should strip out surplus presentational tags and attributes replacing them by style rules and structural markup as appropriate. It works well on the HTML saved by Microsoft Office products. Defaults to false. + /// + public bool MakeClean + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMakeClean); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMakeClean, value); } + } + + /// + /// [coerce-endtags] Gets or sets whether Tidy should coerce a start tag into an end tag in cases where it looks like an end tag was probably intended. Defaults to true. + /// + public bool CoerceEndTags + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyCoerceEndTags); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyCoerceEndTags, value); } + } + + /// + /// [css-prefix] Gets or sets the prefix that Tidy uses for styles rules. By default, "c" will be used. + /// + public string CssPrefix + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyCSSPrefix); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyCSSPrefix, value); } + } + + /// + /// [decorate-inferred-ul] Gets or sets whether Tidy should decorate inferred UL elements with some CSS markup to avoid indentation to the right. Defaults to false. + /// + public bool DecorateInferredUL + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDecorateInferredUL); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDecorateInferredUL, value); } + } + + /// + /// [doctype] Gets or sets the DOCTYPE declaration generated by Tidy. If set to "Omit" the output won't contain a DOCTYPE declaration. If set to "Auto" (the default) Tidy will use an educated guess based upon the contents of the document. If set to "Strict", Tidy will set the DOCTYPE to the strict DTD. If set to "Loose", the DOCTYPE is set to the loose (transitional) DTD. Alternatively, you can supply a string for the formal public identifier (FPI). + /// + /// For example: + /// doctype: "-//ACME//DTD HTML 3.14159//EN" + /// + /// If you specify the FPI for an XHTML document, Tidy will set the system identifier to an empty string. For an HTML document, Tidy adds a system identifier only if one was already present in order to preserve the processing mode of some browsers. Tidy leaves the DOCTYPE for generic XML documents unchanged. "Omit" implies OutputNumericEntities = true. This option does not offer a validation of the document conformance. + /// + public DocTypeMode DocType + { + get { return (DocTypeMode) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyDoctypeMode); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyDoctypeMode, (uint) value); } + } + + /// + /// [drop-empty-elements] Gets or sets whether Tidy should discard empty elements. Defaults to true. + /// + public bool DropEmptyElements + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropEmptyElems); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropEmptyElems, value); } + } + + /// + /// [drop-empty-paras] Gets or sets whether Tidy should discard empty paragraphs. Defaults to true. + /// + public bool DropEmptyParagraphs + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropEmptyParas); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropEmptyParas, value); } + } + + /// + /// [drop-font-tags] Gets or sets whether Tidy should discard <FONT> and <CENTER> tags without creating the corresponding style rules. This option can be set independently of the MakeClean option. Defaults to false. + /// + public bool DropFontTags + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropFontTags); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropFontTags, value); } + } + + /// + /// [drop-proprietary-attributes] Gets or sets whether Tidy should strip out proprietary attributes, such as MS data binding attributes. Defaults to false. + /// + public bool DropProprietaryAttributes + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyDropPropAttrs); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyDropPropAttrs, value); } + } + + /// + /// [enclose-block-text] Gets or sets whether Tidy should insert a <P> element to enclose any text it finds in any element that allows mixed content for HTML transitional but not HTML strict. Defaults to false. + /// + public bool EncloseBlockText + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEncloseBlockText); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEncloseBlockText, value); } + } + + /// + /// [enclose-text] Gets or sets whether Tidy should enclose any text it finds in the body element within a <P> element. This is useful when you want to take existing HTML and use it with a style sheet. Defaults to false. + /// + public bool EncloseBodyText + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEncloseBodyText); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEncloseBodyText, value); } + } + + /// + /// [escape-cdata] Gets or sets whether Tidy should convert <![CDATA[]]> sections to normal text. Defaults to false. + /// + public bool EscapeCdata + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEscapeCdata); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEscapeCdata, value); } + } + + /// + /// [fix-backslash] Gets or sets whether Tidy should replace backslash characters "\" in URLs with forward slashes "/". Defaults to true. + /// + public bool FixUrlBackslashes + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyFixBackslash); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyFixBackslash, value); } + } + + /// + /// [fix-bad-comments] Gets or sets whether Tidy should replace unexpected hyphens with "=" characters when it comes across adjacent hyphens. This option is provided for users of Cold Fusion which uses the comment syntax: <!--- --->. Defaults to true. + /// + public bool FixBadComments + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyFixComments); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyFixComments, value); } + } + + /// + /// [fix-uri] Gets or sets whether Tidy should check attribute values that carry URIs for illegal characters and if such are found, escape them as HTML 4 recommends. Defaults to true. + /// + public bool FixAttributeUris + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyFixUri); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyFixUri, value); } + } + + /// + /// [gdoc] Gets or sets whether Tidy should enable specific behavior for cleaning up HTML exported from Google Docs. Defaults to false. + /// + public bool CleanGoogleDocs + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyGDocClean); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyGDocClean, value); } + } + + /// + /// [hide-comments] Gets or sets whether Tidy should print out comments. Defaults to false. + /// + public bool RemoveComments + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyHideComments); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyHideComments, value); } + } + + /// + /// [hide-endtags] Gets or sets whether Tidy should omit optional end-tags when generating the pretty printed markup. This option is ignored if you are outputting to XML. Defaults to false. + /// + public bool RemoveEndTags + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyHideEndTags); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyHideEndTags, value); } + } + + /// + /// [indent-cdata] Gets or sets whether Tidy should indent <![CDATA[]]> sections. Defaults to false. + /// + public bool IndentCdata + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyIndentCdata); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyIndentCdata, value); } + } + + /// + /// [input-xml] Gets or sets whether Tidy use the XML parser rather than the error correcting HTML parser. Defaults to false. + /// + public bool UseXmlParser + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlTags); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlTags, value); } + } + + /// + /// [join-classes] Gets or sets whether Tidy should combine class names to generate a single new class name, if multiple class assignments are detected on an element. Defaults to false. + /// + public bool JoinClasses + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyJoinClasses); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyJoinClasses, value); } + } + + /// + /// [join-styles] Gets or sets whether Tidy should combine styles to generate a single new style, if multiple style values are detected on an element. Defaults to true. + /// + public bool JoinStyles + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyJoinStyles); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyJoinStyles, value); } + } + + /// + /// [literal-attributes] Gets or sets whether Tidy should ensure that whitespace characters within attribute values are passed through unchanged. Defaults to false. + /// + public bool EnsureLiteralAttributes + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyLiteralAttribs); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyLiteralAttribs, value); } + } + + /// + /// [logical-emphasis] Gets or sets whether Tidy should replace any occurrence of <I> by <EM> and any occurrence of <B> by <STRONG>. In both cases, the attributes are preserved unchanged. This option can be set independently of the "MakeClean" and "DropFontTags" properties. Defaults to false. + /// + public bool UseLogicalEmphasis + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyLogicalEmphasis); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyLogicalEmphasis, value); } + } + + /// + /// [lower-literals] Gets or sets whether Tidy should convert the value of an attribute that takes a list of predefined values to lower case. This is required for XHTML documents. Defaults to false. + /// + public bool LowerCaseLiterals + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyLowerLiterals); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyLowerLiterals, value); } + } + + /// + /// [merge-divs] Gets or sets whether Tidy should merge nested <div> such as "<div><divglt;...</div></div>". If set to "Auto", the attributes of the inner <div> are moved to the outer one. As well, nested <div> with ID attributes are not merged. If set to "Yes", the attributes of the inner <div> are discarded with the exception of "class" and "style". Can be used to modify behavior of the "MakeClean" option. Defaults to Auto. + /// + public AutoBool MergeDivs + { + get { return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyMergeDivs); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyMergeDivs, (uint) value); } + } + + /// + /// [merge-emphasis] Gets or sets whether Tidy should merge nested <b> and <i> elements. Defaults to true. + /// + public bool MergeEmphasis + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMergeEmphasis); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMergeEmphasis, value); } + } + + /// + /// [merge-spans] Gets or sets whether Tidy should merge nested <span> such as "<span><span;...</span></span>". The algorithm is identical to the one used by MergeDivs. Can be used to modify behavior of the "MakeClean" option. Defaults to "Auto". + /// + public AutoBool MergeSpans + { + get + { + return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyMergeSpans); + } + set + { + PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyMergeSpans, (uint) value); + } + } + +#if SUPPORT_ASIAN_ENCODINGS + /// + /// [ncr] Gets or sets whether Tidy should allow numeric character references. Defaults to true. + /// + public bool AllowNumericCharacterReferences + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyNCR); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyNCR, value); } + } +#endif + + /// + /// [new-blocklevel-tags] Gets or sets new block-level tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note you can't change the content model for elements such as <TABLE>, <UL>, <OL> and <DL>. This option is ignored in XML mode. + /// + public string NewBlockLevelTags + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyBlockTags); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyBlockTags, value); } + } + + /// + /// [new-empty-tags] Gets or sets new empty inline tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. This option is ignored in XML mode. + /// + public string NewEmptyInlineTags + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyEmptyTags); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyEmptyTags, value); } + } + + /// + /// [new-inline-tags] Gets or sets new non-empty inline tags. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. This option is ignored in XML mode. + /// + public string NewInlineTags + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyInlineTags); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyInlineTags, value); } + } + + /// + /// [new-pre-tags] Gets or sets new tags that are to be processed in exactly the same way as HTML's <PRE> element. This option takes a space or comma separated list of tag names. Unless you declare new tags, Tidy will refuse to generate a tidied file if the input includes previously unknown tags. Note you can not as yet add new CDATA elements (similar to <SCRIPT>). This option is ignored in XML mode. + /// + public string NewPreTags + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyPreTags); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyPreTags, value); } + } + + /// + /// [numeric-entities] Gets or sets whether Tidy should output entities other than the built-in HTML entities (&amp;, &lt;, &gt; and &quot;) in the numeric rather than the named entity form. Only entities compatible with the DOCTYPE declaration generated are used. Entities that can be represented in the output encoding are translated correspondingly. Defaults to false. + /// + public bool OutputNumericEntities + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyNumEntities); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyNumEntities, value); } + } + + /// + /// [omit-optional-tags] Gets or sets whether Tidy should omit optional start tags and end tags when generating output. Defaults to false. + /// + public bool OmitOptionalTags + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyOmitOptionalTags); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyOmitOptionalTags, value); } + } + + /// + /// [output-html] Gets or sets whether Tidy should generate pretty printed output, writing it as HTML. Defaults to false. + /// + public bool OutputHtml + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyHtmlOut); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyHtmlOut, value); } + } + + /// + /// [output-xhtml] Gets or sets whether Tidy should generate pretty printed output, writing it as extensible HTML. This option causes Tidy to set the DOCTYPE and default namespace as appropriate to XHTML. If a DOCTYPE or namespace is given they will checked for consistency with the content of the document. In the case of an inconsistency, the corrected values will appear in the output. For XHTML, entities can be written as named or numeric entities according to the setting of the "OutputNumericEntities" value. The original case of tags and attributes will be preserved, regardless of other options. Defaults to false. + /// + public bool OutputXhtml + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXhtmlOut); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXhtmlOut, value); } + } + + /// + /// [output-xml] Gets or sets whether Tidy should generate pretty printed output, writing it as well-formed XML. Any entities not defined in XML 1.0 will be written as numeric entities to allow them to be parsed by a XML parser. The original case of tags and attributes will be preserved, regardless of other options. Defaults to false. + /// + public bool OutputXml + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyXmlOut); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyXmlOut, value); } + } + + /// + /// [preserve-entities] Gets or sets whether Tidy should preserve the well-formed entitites as found in the input. Defaults to false. + /// + public bool PreserveEntities + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyPreserveEntities); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyPreserveEntities, value); } + } + + /// + /// [quote-ampersand] Gets or sets whether Tidy should output unadorned & characters as &amp;. Defaults to true. + /// + public bool QuoteAmpersands + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuoteAmpersand); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuoteAmpersand, value); } + } + + /// + /// [quote-marks] Gets or sets whether Tidy should output " characters as &quot; as is preferred by some editing environments. The apostrophe character ' is written out as &#39; since many web browsers don't yet support &apos;. Defaults to false. + /// + public bool QuoteMarks + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuoteMarks); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuoteMarks, value); } + } + + /// + /// [quote-nbsp] Gets or sets whether Tidy should output non-breaking space characters as entities, rather than as the Unicode character value 160 (decimal). Defaults to true. + /// + public bool QuoteNonBreakingSpaces + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuoteNbsp); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuoteNbsp, value); } + } + + /// + /// [repeated-attributes] Gets or sets whether Tidy should keep the first or last attribute, if an attribute is repeated, e.g. has two align attributes. Defaults to "KeepLast". + /// + public RepeatedAttributeMode RepeatedAttributeMode + { + get { return (RepeatedAttributeMode) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyDuplicateAttrs); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyDuplicateAttrs, (uint) value); } + } + + /// + /// [replace-color] Gets or sets whether Tidy should replace numeric values in color attributes by HTML/XHTML color names where defined, e.g. replace "#ffffff" with "white". Defaults to false. + /// + public bool UseColorNames + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyReplaceColor); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyReplaceColor, value); } + } + + /// + /// [show-body-only] Gets or sets whether Tidy should print only the contents of the body tag as an HTML fragment. If set to "Auto", this is performed only if the body tag has been inferred. Useful for incorporating existing whole pages as a portion of another page. This option has no effect if XML output is requested. Defaults to "No". + /// + public AutoBool OutputBodyOnly + { + get + { + if(this.LibraryVersion.IsSupportedVersion) + return (AutoBool)PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyBodyOnly); + else + return (PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyBodyOnly) ? AutoBool.Yes : AutoBool.No); + } + set + { + if (this.LibraryVersion.IsSupportedVersion) + PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyBodyOnly, (uint)value); + else + PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyBodyOnly, (value == AutoBool.Yes)); + } + } + + /// + /// [skip-nested] Gets or sets whether Tidy should skip nested tags when parsing script and style data. The default is true. + /// + public bool SkipNestedTags + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidySkipNested); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidySkipNested, value); } + } + + /// + /// [uppercase-attributes] Gets or sets whether Tidy should output attribute names in upper case. The default is false, which results in lower case attribute names, except for XML input, where the original case is preserved. + /// + public bool UpperCaseAttributes + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyUpperCaseAttrs); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyUpperCaseAttrs, value); } + } + + /// + /// [uppercase-tags] Gets or sets whether Tidy should output tag names in upper case. The default is false, which results in lower case tag names, except for XML input, where the original case is preserved. + /// + public bool UpperCaseTags + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyUpperCaseTags); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyUpperCaseTags, value); } + } + + /// + /// [word-2000] Gets or sets whether Tidy should go to great pains to strip out all the surplus stuff Microsoft Word 2000 inserts when you save Word documents as "Web pages". Doesn't handle embedded images or VML. You should consider using Word's "Save As: Web Page, Filtered". Defaults to false. + /// + public bool CleanWord2000 + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWord2000); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWord2000, value); } + } + + #endregion + + #region Diagnostics Options + + /// + /// [accessibility-check] Gets or sets the level of accessibility checking, if any, that Tidy should do. Defaults to TidyClassic. + /// + public AccessibilityCheckLevel AccessibilityCheckLevel + { + get { return (AccessibilityCheckLevel) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyAccessibilityCheckLevel); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyAccessibilityCheckLevel, (uint) value); } + } + + /// + /// [show-errors] Gets or sets the number Tidy uses to determine if further errors should be shown. If set to 0, then no errors are shown. Defaults to 6. + /// + public int MaximumErrors + { + get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyShowErrors); } + set + { + if (value < 0) value = 0; + PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyShowErrors, (uint) value); + } + } + + /// + /// [show-info] Gets or sets whether Tidy should display info-level messages. Defaults to true. + /// + public bool ShowInfo + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyShowInfo); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyShowInfo, value); } + } + + /// + /// [show-warnings] Gets or sets whether Tidy should suppress warnings. This can be useful when a few errors are hidden in a flurry of warnings. Defaults to true. + /// + public bool ShowWarnings + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyShowWarnings); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyShowWarnings, value); } + } + + #endregion + + #region Pretty Print Options + + /// + /// [break-before-br] Gets or sets whether Tidy should output a line break before each <BR> element. Defaults to false. + /// + public bool LineBreakBeforeBR + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyBreakBeforeBR); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyBreakBeforeBR, value); } + } + + /// + /// [indent] Gets or sets whether Tidy should indent block-level tags. If set to Auto, this option causes Tidy to decide whether or not to indent the content of tags such as TITLE, H1-H6, LI, TD, TD, or P depending on whether or not the content includes a block-level element. You are advised to avoid setting indent to Yes as this can expose layout bugs in some browsers. Defaults to No. + /// + public AutoBool IndentBlockElements + { + get { return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyIndentContent); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyIndentContent, (uint) value); } + } + + /// + /// [indent-attributes] Gets or sets whether Tidy should begin each attribute on a new line. Defaults to false. + /// + public bool IndentAttributes + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyIndentAttributes); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyIndentAttributes, value); } + } + + /// + /// [indent-spaces] Gets or sets the number of spaces Tidy uses to indent content, when indentation is enabled. Defaults to 2. + /// + public int IndentSpaces + { + get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyIndentSpaces); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyIndentSpaces, (uint) value); } + } + + /// + /// [indent-with-tabs] Gets or sets whether Tidy should indent with tabs instead of spaces, assuming indent is yes. Defaults to false. + /// + public bool IndentWithTabs + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyPPrintTabs); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyPPrintTabs, value); } + } + + /// + /// [markup] Gets or sets whether Tidy should generate a pretty printed version of the markup. Note that Tidy won't generate a pretty printed version if it finds significant errors (see ForceOutput). Defaults to true. + /// + public bool Markup + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyShowMarkup); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyShowMarkup, value); } + } + +#if SUPPORT_ASIAN_ENCODINGS + /// + /// [punctuation-wrap] Gets or sets whether Tidy should line wrap after some Unicode or Chinese punctuation characters. Defaults to false. + /// + public bool PunctuationWrap + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyPunctWrap); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyPunctWrap, value); } + } +#endif + + /// + /// [sort-attributes] Gets or sets how Tidy should sort attributes within an element using the specified sort algorithm. If set to Alpha, the algorithm is an ascending alphabetic sort. Defaults to None. + /// + public SortStrategy AttributeSortType + { + get + { + return (SortStrategy) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidySortAttributes); + } + set + { + PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidySortAttributes, (uint) value); + } + } + + /// + /// [tab-size] Gets or sets the number of columns that Tidy uses between successive tab stops. It is used to map tabs to spaces when reading the input. Tidy never outputs tabs. Defaults to 8. + /// + public int TabSize + { + get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyTabSize); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyTabSize, (uint) value); } + } + + /// + /// [vertical-space] Gets or sets whether Tidy should add some empty lines for readability. Defaults to false. + /// + public bool AddVerticalSpace + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyVertSpace); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyVertSpace, value); } + } + + /// + /// [wrap] Gets or sets the right margin Tidy uses for line wrapping. Tidy tries to wrap lines so that they do not exceed this length. Set wrap to zero if you want to disable line wrapping. Defaults to 68. + /// + public int WrapAt + { + get { return (int) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyWrapLen); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyWrapLen, (uint) value); } + } + + /// + /// [wrap-asp] Gets or sets whether Tidy should line wrap text contained within ASP pseudo elements, which look like: <% ... %>. Defaults to true. + /// + public bool WrapAsp + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapAsp); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapAsp, value); } + } + + /// + /// [wrap-attributes] Gets or sets whether Tidy should line wrap attribute values, for easier editing. This option can be set independently of WrapAcriptLiterals. Defaults to false. + /// + public bool WrapAttributeValues + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapAttVals); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapAttVals, value); } + } + + /// + /// [wrap-jste] Gets or sets whether Tidy should line wrap text contained within JSTE pseudo elements, which look like: <# ... #>. Defaults to true. + /// + public bool WrapJste + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapJste); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapJste, value); } + } + + /// + /// [wrap-php] Gets or sets whether Tidy should line wrap text contained within PHP pseudo elements, which look like: <?php ... ?>. Defaults to true. + /// + public bool WrapPhp + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapPhp); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapPhp, value); } + } + + /// + /// [wrap-script-literals] Gets or sets whether Tidy should line wrap string literals that appear in script attributes. Tidy wraps long script string literals by inserting a backslash character before the line break. Defaults to false. + /// + public bool WrapScriptLiterals + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapScriptlets); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapScriptlets, value); } + } + + /// + /// [wrap-sections] Gets or sets whether Tidy should line wrap text contained within <![ ... ]> section tags. Defaults to true. + /// + public bool WrapSections + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWrapSection); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWrapSection, value); } + } + + #endregion + + #region Character Encoding Options + + /// + /// [ascii-chars] Gets or sets whether &emdash;, &rdquo;, and other named character entities are downgraded to their closest ascii equivalents when the "MakeClean" option is set to true. Defaults to false. + /// + public bool AsciiEntities + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyAsciiChars); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyAsciiChars, value); } + } + + /// + /// [char-encoding] Gets or sets character encoding Tidy uses for both the input and output. For ascii, Tidy will accept Latin-1 (ISO-8859-1) character values, but will use entities for all characters whose value > 127. For raw, Tidy will output values above 127 without translating them into entities. For latin1, characters above 255 will be written as entities. For utf8, Tidy assumes that both input and output is encoded as UTF-8. You can use iso2022 for files encoded using the ISO-2022 family of encodings e.g. ISO-2022-JP. For mac and win1252, Tidy will accept vendor specific character values, but will use entities for all characters whose value > 127. For unsupported encodings, use an external utility to convert to and from UTF-8. Defaults to "Ascii". + /// + public EncodingType CharacterEncoding + { + get { return (EncodingType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyCharEncoding); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyCharEncoding, (uint) value); } + } + + /// + /// [input-encoding] Gets or sets character encoding Tidy uses for the input. See CharacterEncoding for more info. Defaults to "Latin1". + /// + public EncodingType InputCharacterEncoding + { + get { return (EncodingType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyInCharEncoding); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyInCharEncoding, (uint) value); } + } + + /// + /// [newline] Gets or sets the type of newline. The default is appropriate to the current platform: CRLF on PC-DOS, MS-Windows and OS/2, CR on Classic Mac OS, and LF everywhere else (Unix and Linux). + /// + public NewlineType NewLine + { + get { return (NewlineType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyNewline); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyNewline, (uint) value); } + } + +#if SUPPORT_UTF16_ENCODINGS + /// + /// [output-bom] Gets or sets whether Tidy should write a Unicode Byte Order Mark character (BOM; also known as Zero Width No-Break Space; has value of U+FEFF) to the beginning of the output; only for UTF-8 and UTF-16 output encodings. If set to "auto", this option causes Tidy to write a BOM to the output only if a BOM was present at the beginning of the input. A BOM is always written for XML/XHTML output using UTF-16 output encodings. Defaults to "Auto". + /// + public AutoBool OutputByteOrderMark + { + get { return (AutoBool) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyOutputBOM); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyOutputBOM, (uint) value); } + } +#endif + + /// + /// [output-encoding] Gets or sets character encoding Tidy uses for the output. See CharacterEncoding for more info. May only be different from input-encoding for Latin encodings (ascii, latin0, latin1, mac, win1252, ibm858). Defaults to "Ascii". + /// + public EncodingType OutputCharacterEncoding + { + get { return (EncodingType) PInvoke.tidyOptGetInt(this.handle, TidyOptionId.TidyOutCharEncoding); } + set { PInvoke.tidyOptSetInt(this.handle, TidyOptionId.TidyOutCharEncoding, (uint) value); } + } + + #endregion + + #region Miscellaneous Options + + /// + /// [error-file] Gets or sets the error file Tidy uses for errors and warnings. Normally errors and warnings are output to "stderr". Defaults to null. + /// + public string ErrorFile + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyErrFile); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyErrFile, value); } + } + + /// + /// [force-output] Gets or sets whether Tidy should produce output even if errors are encountered. Use this option with care - if Tidy reports an error, this means Tidy was not able to, or is not sure how to, fix the error, so the resulting output may not reflect your intention. Defaults to false. + /// + public bool ForceOutput + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyForceOutput); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyForceOutput, value); } + } + + /// + /// [gnu-emacs] Gets or sets whether Tidy should change the format for reporting errors and warnings to a format that is more easily parsed by GNU Emacs. Defaults to false. + /// + public bool UseGnuEmacsErrorFormat + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyEmacs); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyEmacs, value); } + } + + /// + /// [keep-time] Gets or sets whether Tidy should keep the original modification time of files that Tidy modifies in place. The default is no. Setting the option to yes allows you to tidy files without causing these files to be uploaded to a web server when using a tool such as SiteCopy. Note this feature is not supported on some platforms. Defaults to false. + /// + public bool KeepModificationTimestamp + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyKeepFileTimes); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyKeepFileTimes, value); } + } + + /// + /// [output-file] Gets or sets the output file Tidy uses for markup. Normally markup is written to "stdout". Defaults to null. + /// + public string OutputFile + { + get { return PInvoke.tidyOptGetValueString(this.handle, TidyOptionId.TidyOutFile); } + set { PInvoke.tidyOptSetValue(this.handle, TidyOptionId.TidyOutFile, value); } + } + + /// + /// [quiet] Gets or sets whether Tidy should output the summary of the numbers of errors and warnings, or the welcome or informational messages. Defaults to false. + /// + public bool Quiet + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyQuiet); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyQuiet, value); } + } + + /// + /// [tidy-mark] Gets or sets whether Tidy should add a meta element to the document head to indicate that the document has been tidied. Tidy won't add a meta element if one is already present. Defaults to true. + /// + public bool AddTidyMetaElement + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyMark); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyMark, value); } + } + + /// + /// [write-back] Gets or sets whether Tidy should write back the tidied markup to the same file it read from. You are advised to keep copies of important files before tidying them, as on rare occasions the result may not be what you expect. Defaults to false. + /// + public bool WriteBack + { + get { return PInvoke.tidyOptGetBool(this.handle, TidyOptionId.TidyWriteBack); } + set { PInvoke.tidyOptSetBool(this.handle, TidyOptionId.TidyWriteBack, value); } + } + + #endregion + + #endregion + + #region Methods + + /// + /// Parses input markup, and executes configured cleanup and repair operations. + /// + public void CleanAndRepair() + { + if (fromString) + { + EncodingType tempEnc = this.InputCharacterEncoding; + this.InputCharacterEncoding = EncodingType.Utf8; + PInvoke.tidyParseString(this.handle, this.htmlString); + this.InputCharacterEncoding = tempEnc; + } + else + { + InputSource input = new InputSource(this.stream); + PInvoke.tidyParseSource(this.handle, ref input.TidyInputSource); + } + PInvoke.tidyCleanAndRepair(this.handle); + cleaned = true; + } + + /// + /// Saves the processed markup to a string. + /// + /// A string containing the processed markup. + public string Save() + { + if (!cleaned) + throw new InvalidOperationException("CleanAndRepair() must be called before Save()."); + + var tempEnc = this.CharacterEncoding; + this.OutputCharacterEncoding = EncodingType.Utf8; + +#if SUPPORT_UTF16_ENCODINGS + var tempBOM = this.OutputByteOrderMark; + this.OutputByteOrderMark = AutoBool.No; +#endif + + uint bufferLength = 1; + byte[] htmlBytes; + GCHandle handle = new GCHandle(); + do + { + // Buffer was too small - bufferLength should now be the required length, so try again... + if (handle.IsAllocated) handle.Free(); + + // this setting appears to be reset by libtidy after calling tidySaveString; we need to set it each time + this.OutputCharacterEncoding = EncodingType.Utf8; + + htmlBytes = new byte[bufferLength]; + handle = GCHandle.Alloc(htmlBytes, GCHandleType.Pinned); + } while (PInvoke.tidySaveString(this.handle, handle.AddrOfPinnedObject(), ref bufferLength) == -12); + + handle.Free(); + + this.OutputCharacterEncoding = tempEnc; + +#if SUPPORT_UTF16_ENCODINGS + this.OutputByteOrderMark = tempBOM; +#endif + + return Encoding.UTF8.GetString(htmlBytes); + } + + /// + /// Saves the processed markup to a file. + /// + /// The full filesystem path of the file to save the markup to. + public void Save(string filePath) + { + if (!cleaned) + throw new InvalidOperationException("CleanAndRepair() must be called before Save()."); + + if (string.IsNullOrEmpty(filePath)) + throw new ArgumentNullException(nameof(filePath)); + + PInvoke.tidySaveFile(this.handle, filePath); + } + + /// + /// Saves the processed markup to the supplied stream. + /// + /// A to write the markup to. + public void Save(Stream stream) + { + if (!cleaned) + throw new InvalidOperationException("CleanAndRepair() must be called before Save()."); + + if(stream == null) + throw new ArgumentNullException(nameof(stream)); + + EncodingType tempEnc = this.OutputCharacterEncoding; + if (fromString) this.OutputCharacterEncoding = EncodingType.Utf8; + OutputSink sink = new OutputSink(stream); + PInvoke.tidySaveSink(this.handle, ref sink.TidyOutputSink); + if (fromString) this.OutputCharacterEncoding = tempEnc; + } + + #endregion + + #region Static Methods + + /// + /// Creates a new instance from a containing HTML. + /// + /// The HTML string to be processed. + public static Document FromString(string htmlString) + { + if (htmlString == null) + throw new ArgumentNullException(nameof(htmlString)); + + return new Document(htmlString); + } + + /// + /// Creates a new instance from a file. + /// + /// The full filesystem path of the HTML document to be processed. + public static Document FromFile(string filePath) + { + if (string.IsNullOrEmpty(filePath)) + throw new ArgumentNullException(nameof(filePath)); + + if (!File.Exists(filePath)) + throw new FileNotFoundException("File not found.", filePath); + + return new Document(new FileStream(filePath, FileMode.Open)); + } + + /// + /// Creates a new instance from a instance. + /// + /// A instance containing the HTML document to be processed. + public static Document FromStream(Stream stream) + { + if (stream == null) + throw new ArgumentNullException(nameof(stream)); + + if (!stream.CanRead) + throw new ArgumentException("Stream must be readable."); + if (!stream.CanSeek) + throw new ArgumentException("Stream must be seekable."); + + return new Document(stream); + } + + #endregion + + #region IDisposable Members + + /// + /// Disposes of all unmanaged resources. + /// + public void Dispose() + { + this.Dispose(true); + GC.SuppressFinalize(this); + } + + /// + /// Disposes of all unmanaged resources. + /// + /// Indicates whether the the document is already being disposed of. + protected virtual void Dispose(bool disposing) + { + if (!this.disposed) + { + if (disposing) + { + if (this.stream != null) this.stream.Dispose(); + PInvoke.tidyRelease(this.handle); + } + this.handle = IntPtr.Zero; + this.stream = null; + this.disposed = true; + } + } + + #endregion + } +} diff --git a/TidyHtml5Managed/DocumentAsync.cs b/TidyHtml5Managed/DocumentAsync.cs new file mode 100644 index 0000000..7e7d6d2 --- /dev/null +++ b/TidyHtml5Managed/DocumentAsync.cs @@ -0,0 +1,44 @@ +using System.IO; +using System.Threading.Tasks; + +namespace TidyManaged +{ + public partial class Document + { + /// + /// Parses input markup, executes configured cleanup, and repair operations asynchronously. + /// + /// + public Task CleanAndRepairAsync() + { + return Task.Run(() => CleanAndRepair()); + } + + /// + /// Saves the processed markup to a string asynchronously. + /// + /// A string containing the processed markup. + public Task SaveAsync() + { + return Task.FromResult(Save()); + } + + /// + /// Saves the processed markup to a file asynchronously. + /// + /// The full filesystem path of the file to save the markup to. + public Task SaveAsync(string filePath) + { + return Task.Run(() => Save(filePath)); + } + + /// + /// Saves the processed markup to the supplied stream asynchronously. + /// + /// A to write the markup to. + public Task SaveAsync(Stream stream) + { + return Task.Run(() => Save(stream)); + } + } +} diff --git a/EncodingType.cs b/TidyHtml5Managed/EncodingType.cs similarity index 96% rename from EncodingType.cs rename to TidyHtml5Managed/EncodingType.cs index b726824..56039c9 100644 --- a/EncodingType.cs +++ b/TidyHtml5Managed/EncodingType.cs @@ -1,123 +1,123 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - /// - /// Represents the supported encodings. - /// - public enum EncodingType - { - /// - /// No or unknown encoding. - /// - Raw = 0, - - /// - /// The American Standard Code for Information Interchange (ASCII) encoding scheme. - /// - Ascii = 1, - - /// - /// The ISO/IEC 8859-15 encoding scheme, also knows as Latin-0 and Latin-9. - /// - Latin0 = 2, - - /// - /// The ISO/IEC 8859-1 encoding scheme, also knows as Latin-1. - /// - Latin1 = 3, - - /// - /// The UTF-8 encoding scheme. - /// - Utf8 = 4, - - /// - /// The ISO/IEC 2022 encoding scheme. - /// - Iso2022 = 5, - - /// - /// The MacRoman encoding scheme. - /// - MacRoman = 6, - - /// - /// The Windows-1252 encoding scheme. - /// - Win1252 = 7, - - /// - /// The Code page 858 encoding scheme, also know as CP 858, IBM 858, or OEM 858. - /// - Ibm858 = 8, - -#if SUPPORT_UTF16_ENCODINGS - - /// - /// The UTF-16LE (Little Endian) encoding scheme. - /// - Utf16LittleEndian = 9, - - /// - /// The UTF-16BE (Big Endian) encoding scheme. - /// - Utf16BigEndian = 10, - - /// - /// The UTF-16 encoding scheme, with endianess detected using a BOM. - /// - Utf16 = 11, - -#endif - -#if SUPPORT_ASIAN_ENCODINGS -#if SUPPORT_UTF16_ENCODINGS - - /// - /// The Big-5 or Big5 encoding scheme, used in Taiwan, Hong Kong, and Macau for Traditional Chinese characters. - /// - Big5 = 12, - - /// - /// The Shift JIS encoding scheme for Japanese characters. - /// - ShiftJIS = 13 - -#else - - /// - /// The Big-5 or Big5 encoding scheme, used in Taiwan, Hong Kong, and Macau for Traditional Chinese characters. - /// - Big5 = 9, - - /// - /// The Shift JIS encoding scheme for Japanese characters. - /// - ShiftJIS = 10 - -#endif -#endif - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents the supported encodings. + /// + public enum EncodingType + { + /// + /// No or unknown encoding. + /// + Raw = 0, + + /// + /// The American Standard Code for Information Interchange (ASCII) encoding scheme. + /// + Ascii = 1, + + /// + /// The ISO/IEC 8859-15 encoding scheme, also knows as Latin-0 and Latin-9. + /// + Latin0 = 2, + + /// + /// The ISO/IEC 8859-1 encoding scheme, also knows as Latin-1. + /// + Latin1 = 3, + + /// + /// The UTF-8 encoding scheme. + /// + Utf8 = 4, + + /// + /// The ISO/IEC 2022 encoding scheme. + /// + Iso2022 = 5, + + /// + /// The MacRoman encoding scheme. + /// + MacRoman = 6, + + /// + /// The Windows-1252 encoding scheme. + /// + Win1252 = 7, + + /// + /// The Code page 858 encoding scheme, also know as CP 858, IBM 858, or OEM 858. + /// + Ibm858 = 8, + +#if SUPPORT_UTF16_ENCODINGS + + /// + /// The UTF-16LE (Little Endian) encoding scheme. + /// + Utf16LittleEndian = 9, + + /// + /// The UTF-16BE (Big Endian) encoding scheme. + /// + Utf16BigEndian = 10, + + /// + /// The UTF-16 encoding scheme, with endianess detected using a BOM. + /// + Utf16 = 11, + +#endif + +#if SUPPORT_ASIAN_ENCODINGS +#if SUPPORT_UTF16_ENCODINGS + + /// + /// The Big-5 or Big5 encoding scheme, used in Taiwan, Hong Kong, and Macau for Traditional Chinese characters. + /// + Big5 = 12, + + /// + /// The Shift JIS encoding scheme for Japanese characters. + /// + ShiftJIS = 13 + +#else + + /// + /// The Big-5 or Big5 encoding scheme, used in Taiwan, Hong Kong, and Macau for Traditional Chinese characters. + /// + Big5 = 9, + + /// + /// The Shift JIS encoding scheme for Japanese characters. + /// + ShiftJIS = 10 + +#endif +#endif + } +} diff --git a/InputSource.cs b/TidyHtml5Managed/InputSource.cs similarity index 97% rename from InputSource.cs rename to TidyHtml5Managed/InputSource.cs index c5c42b4..982749d 100644 --- a/InputSource.cs +++ b/TidyHtml5Managed/InputSource.cs @@ -1,55 +1,55 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.IO; - -namespace TidyManaged -{ - internal class InputSource - { - internal InputSource(Stream stream) - { - this.stream = stream; - this.TidyInputSource = new Interop.TidyInputSource(new Interop.TidyGetByteFunc(OnGetByte), new Interop.TidyUngetByteFunc(OnUngetByte), new Interop.TidyEOFFunc(OnEOF)); - } - - Stream stream; - internal Interop.TidyInputSource TidyInputSource; - - byte OnGetByte(IntPtr sinkData) - { - return (byte) this.stream.ReadByte(); - } - - void OnUngetByte(IntPtr sinkData, byte bt) - { - if (this.stream.Position > 0) this.stream.Position--; - } - - bool OnEOF(IntPtr sinkData) - { - return (this.stream.Position >= this.stream.Length); - } - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.IO; + +namespace TidyManaged +{ + internal class InputSource + { + internal InputSource(Stream stream) + { + this.stream = stream; + this.TidyInputSource = new Interop.TidyInputSource(new Interop.TidyGetByteFunc(OnGetByte), new Interop.TidyUngetByteFunc(OnUngetByte), new Interop.TidyEOFFunc(OnEOF)); + } + + Stream stream; + internal Interop.TidyInputSource TidyInputSource; + + byte OnGetByte(IntPtr sinkData) + { + return (byte) this.stream.ReadByte(); + } + + void OnUngetByte(IntPtr sinkData, byte bt) + { + if (this.stream.Position > 0) this.stream.Position--; + } + + bool OnEOF(IntPtr sinkData) + { + return (this.stream.Position >= this.stream.Length); + } + } +} diff --git a/Interop/PInvoke.cs b/TidyHtml5Managed/Interop/PInvoke.cs similarity index 81% rename from Interop/PInvoke.cs rename to TidyHtml5Managed/Interop/PInvoke.cs index ffd98d0..6479f3a 100644 --- a/Interop/PInvoke.cs +++ b/TidyHtml5Managed/Interop/PInvoke.cs @@ -1,84 +1,87 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Runtime.InteropServices; - -namespace TidyManaged.Interop -{ - internal class PInvoke - { - [DllImport("libtidy.dll")] - internal static extern IntPtr tidyCreate(); - - [DllImport("libtidy.dll")] - internal static extern void tidyRelease(IntPtr tdoc); - - [DllImport("libtidy.dll")] - internal static extern IntPtr tidyReleaseDate(); - - [DllImport("libtidy.dll")] - internal static extern IntPtr tidyOptGetValue(IntPtr tdoc, TidyOptionId optId); - - [DllImport("libtidy.dll")] - internal static extern bool tidyOptSetValue(IntPtr tdoc, TidyOptionId optId, string val); - - [DllImport("libtidy.dll")] - internal static extern uint tidyOptGetInt(IntPtr tdoc, TidyOptionId optId); - - [DllImport("libtidy.dll")] - internal static extern bool tidyOptSetInt(IntPtr tdoc, TidyOptionId optId, uint val); - - [DllImport("libtidy.dll")] - internal static extern bool tidyOptGetBool(IntPtr tdoc, TidyOptionId optId); - - [DllImport("libtidy.dll")] - internal static extern bool tidyOptSetBool(IntPtr tdoc, TidyOptionId optId, bool val); - - [DllImport("libtidy.dll")] - internal static extern int tidyParseFile(IntPtr tdoc, string filename); - - [DllImport("libtidy.dll")] - internal static extern int tidyParseString(IntPtr tdoc, string content); - - [DllImport("libtidy.dll")] - internal static extern int tidyParseSource(IntPtr tdoc, ref TidyInputSource source); - - [DllImport("libtidy.dll")] - internal static extern int tidyCleanAndRepair(IntPtr tdoc); - - [DllImport("libtidy.dll")] - internal static extern int tidySaveFile(IntPtr tdoc, string filname); - - [DllImport("libtidy.dll")] - internal static extern int tidySaveString(IntPtr tdoc, IntPtr buffer, ref uint buflen); - - [DllImport("libtidy.dll")] - internal static extern int tidySaveSink(IntPtr tdoc, ref TidyOutputSink sink); - - internal static string tidyOptGetValueString(IntPtr tdoc, TidyOptionId optId) - { - return Marshal.PtrToStringAnsi(tidyOptGetValue(tdoc, optId)); - } - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.Runtime.InteropServices; + +namespace TidyManaged.Interop +{ + internal class PInvoke + { + [DllImport("tidy.dll")] + internal static extern IntPtr tidyCreate(); + + [DllImport("tidy.dll")] + internal static extern void tidyRelease(IntPtr tdoc); + + [DllImport("tidy.dll")] + internal static extern IntPtr tidyReleaseDate(); + + [DllImport("tidy.dll")] + internal static extern IntPtr tidyLibraryVersion(); + + [DllImport("tidy.dll")] + internal static extern IntPtr tidyOptGetValue(IntPtr tdoc, TidyOptionId optId); + + [DllImport("tidy.dll")] + internal static extern bool tidyOptSetValue(IntPtr tdoc, TidyOptionId optId, string val); + + [DllImport("tidy.dll")] + internal static extern uint tidyOptGetInt(IntPtr tdoc, TidyOptionId optId); + + [DllImport("tidy.dll")] + internal static extern bool tidyOptSetInt(IntPtr tdoc, TidyOptionId optId, uint val); + + [DllImport("tidy.dll")] + internal static extern bool tidyOptGetBool(IntPtr tdoc, TidyOptionId optId); + + [DllImport("tidy.dll")] + internal static extern bool tidyOptSetBool(IntPtr tdoc, TidyOptionId optId, bool val); + + [DllImport("tidy.dll")] + internal static extern int tidyParseFile(IntPtr tdoc, string filename); + + [DllImport("tidy.dll")] + internal static extern int tidyParseString(IntPtr tdoc, string content); + + [DllImport("tidy.dll")] + internal static extern int tidyParseSource(IntPtr tdoc, ref TidyInputSource source); + + [DllImport("tidy.dll")] + internal static extern int tidyCleanAndRepair(IntPtr tdoc); + + [DllImport("tidy.dll")] + internal static extern int tidySaveFile(IntPtr tdoc, string filname); + + [DllImport("tidy.dll")] + internal static extern int tidySaveString(IntPtr tdoc, IntPtr buffer, ref uint buflen); + + [DllImport("tidy.dll")] + internal static extern int tidySaveSink(IntPtr tdoc, ref TidyOutputSink sink); + + internal static string tidyOptGetValueString(IntPtr tdoc, TidyOptionId optId) + { + return Marshal.PtrToStringAnsi(tidyOptGetValue(tdoc, optId)); + } + } +} diff --git a/Interop/TidyEOFFunc.cs b/TidyHtml5Managed/Interop/TidyEOFFunc.cs similarity index 97% rename from Interop/TidyEOFFunc.cs rename to TidyHtml5Managed/Interop/TidyEOFFunc.cs index 79ed421..2858a99 100644 --- a/Interop/TidyEOFFunc.cs +++ b/TidyHtml5Managed/Interop/TidyEOFFunc.cs @@ -1,29 +1,29 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; - -namespace TidyManaged.Interop -{ - internal delegate bool TidyEOFFunc(IntPtr sinkData); -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; + +namespace TidyManaged.Interop +{ + internal delegate bool TidyEOFFunc(IntPtr sinkData); +} diff --git a/Interop/TidyGetByteFunc.cs b/TidyHtml5Managed/Interop/TidyGetByteFunc.cs similarity index 97% rename from Interop/TidyGetByteFunc.cs rename to TidyHtml5Managed/Interop/TidyGetByteFunc.cs index 65f28dd..b05d756 100644 --- a/Interop/TidyGetByteFunc.cs +++ b/TidyHtml5Managed/Interop/TidyGetByteFunc.cs @@ -1,29 +1,29 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; - -namespace TidyManaged.Interop -{ - internal delegate byte TidyGetByteFunc(IntPtr sinkData); -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; + +namespace TidyManaged.Interop +{ + internal delegate byte TidyGetByteFunc(IntPtr sinkData); +} diff --git a/Interop/TidyInputSource.cs b/TidyHtml5Managed/Interop/TidyInputSource.cs similarity index 97% rename from Interop/TidyInputSource.cs rename to TidyHtml5Managed/Interop/TidyInputSource.cs index 0a99669..0e4295a 100644 --- a/Interop/TidyInputSource.cs +++ b/TidyHtml5Managed/Interop/TidyInputSource.cs @@ -1,52 +1,52 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Runtime.InteropServices; - -namespace TidyManaged.Interop -{ - internal struct TidyInputSource - { - internal TidyInputSource(TidyGetByteFunc getByte, TidyUngetByteFunc ungetByte, TidyEOFFunc eof) - { - this.sourceData = IntPtr.Zero; - this.getByte = getByte; - this.ungetByte = ungetByte; - this.eof = eof; - } - -#pragma warning disable 0414 - IntPtr sourceData; - - [MarshalAs(UnmanagedType.FunctionPtr)] - TidyGetByteFunc getByte; - - [MarshalAs(UnmanagedType.FunctionPtr)] - TidyUngetByteFunc ungetByte; - - [MarshalAs(UnmanagedType.FunctionPtr)] - TidyEOFFunc eof; -#pragma warning restore 0414 - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.Runtime.InteropServices; + +namespace TidyManaged.Interop +{ + internal struct TidyInputSource + { + internal TidyInputSource(TidyGetByteFunc getByte, TidyUngetByteFunc ungetByte, TidyEOFFunc eof) + { + this.sourceData = IntPtr.Zero; + this.getByte = getByte; + this.ungetByte = ungetByte; + this.eof = eof; + } + +#pragma warning disable 0414 + IntPtr sourceData; + + [MarshalAs(UnmanagedType.FunctionPtr)] + TidyGetByteFunc getByte; + + [MarshalAs(UnmanagedType.FunctionPtr)] + TidyUngetByteFunc ungetByte; + + [MarshalAs(UnmanagedType.FunctionPtr)] + TidyEOFFunc eof; +#pragma warning restore 0414 + } +} diff --git a/TidyHtml5Managed/Interop/TidyOptionId.cs b/TidyHtml5Managed/Interop/TidyOptionId.cs new file mode 100644 index 0000000..c7a7f82 --- /dev/null +++ b/TidyHtml5Managed/Interop/TidyOptionId.cs @@ -0,0 +1,159 @@ +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; + +namespace TidyManaged.Interop +{ + internal enum TidyOptionId + { + TidyUnknownOption, /*< Unknown option! */ + TidyIndentSpaces, /*< Indentation n spaces/tabs */ + TidyWrapLen, /*< Wrap margin */ + TidyTabSize, /*< Expand tabs to n spaces */ + + TidyCharEncoding, /*< In/out character encoding */ + TidyInCharEncoding, /*< Input character encoding (if different) */ + TidyOutCharEncoding, /*< Output character encoding (if different) */ + TidyNewline, /*< Output line ending (default to platform) */ + + TidyDoctypeMode, /*< See doctype property */ + TidyDoctype, /*< User specified doctype */ + + TidyDuplicateAttrs, /*< Keep first or last duplicate attribute */ + TidyAltText, /*< Default text for alt attribute */ + + [Obsolete] + TidySlideStyle, /*< Style sheet for slides: not used for anything yet */ + + TidyErrFile, /*< File name to write errors to */ + TidyOutFile, /*< File name to write markup to */ + TidyWriteBack, /*< If true then output tidied markup */ + TidyShowMarkup, /*< If false, normal output is suppressed */ + TidyShowInfo, /*< If true, info-level messages are shown */ + TidyShowWarnings, /*< However errors are always shown */ + TidyQuiet, /*< No 'Parsing X', guessed DTD or summary */ + TidyIndentContent, /*< Indent content of appropriate tags */ + /*< "auto" does text/block level content indentation */ + TidyCoerceEndTags, /*< Coerce end tags from start tags where probably intended */ + TidyOmitOptionalTags,/*< Suppress optional start tags and end tags */ + TidyHideEndTags, /*< Legacy name for TidyOmitOptionalTags */ + TidyXmlTags, /*< Treat input as XML */ + TidyXmlOut, /*< Create output as XML */ + TidyXhtmlOut, /*< Output extensible HTML */ + TidyHtmlOut, /*< Output plain HTML, even for XHTML input. Yes means set explicitly. */ + TidyXmlDecl, /*< Add for XML docs */ + TidyUpperCaseTags, /*< Output tags in upper not lower case */ + TidyUpperCaseAttrs, /*< Output attributes in upper not lower case */ + TidyMakeBare, /*< Make bare HTML: remove Microsoft cruft */ + TidyMakeClean, /*< Replace presentational clutter by style rules */ + TidyGDocClean, /*< Clean up HTML exported from Google Docs */ + TidyLogicalEmphasis, /*< Replace i by em and b by strong */ + TidyDropPropAttrs, /*< Discard proprietary attributes */ + TidyDropFontTags, /*< Discard presentation tags */ + TidyDropEmptyElems, /*< Discard empty elements */ + TidyDropEmptyParas, /*< Discard empty p elements */ + TidyFixComments, /*< Fix comments with adjacent hyphens */ + TidyBreakBeforeBR, /*< Output newline before
or not? */ + + [Obsolete] + TidyBurstSlides, /*< Create slides on each h2 element */ + + TidyNumEntities, /*< Use numeric entities */ + TidyQuoteMarks, /*< Output " marks as " */ + TidyQuoteNbsp, /*< Output non-breaking space as entity */ + TidyQuoteAmpersand, /*< Output naked ampersand as & */ + TidyWrapAttVals, /*< Wrap within attribute values */ + TidyWrapScriptlets, /*< Wrap within JavaScript string literals */ + TidyWrapSection, /*< Wrap within section tags */ + TidyWrapAsp, /*< Wrap within ASP pseudo elements */ + TidyWrapJste, /*< Wrap within JSTE pseudo elements */ + TidyWrapPhp, /*< Wrap within PHP pseudo elements */ + TidyFixBackslash, /*< Fix URLs by replacing \ with / */ + TidyIndentAttributes,/*< Newline+indent before each attribute */ + TidyXmlPIs, /*< If set to yes PIs must end with ?> */ + TidyXmlSpace, /*< If set to yes adds xml:space attr as needed */ + TidyEncloseBodyText, /*< If yes text at body is wrapped in P's */ + TidyEncloseBlockText,/*< If yes text in blocks is wrapped in P's */ + TidyKeepFileTimes, /*< If yes last modied time is preserved */ + TidyWord2000, /*< Draconian cleaning for Word2000 */ + TidyMark, /*< Add meta element indicating tidied doc */ + TidyEmacs, /*< If true format error output for GNU Emacs */ + TidyEmacsFile, /*< Name of current Emacs file */ + TidyLiteralAttribs, /*< If true attributes may use newlines */ + TidyBodyOnly, /*< Output BODY content only */ + TidyFixUri, /*< Applies URI encoding if necessary */ + TidyLowerLiterals, /*< Folds known attribute values to lower case */ + TidyHideComments, /*< Hides all (real) comments in output */ + TidyIndentCdata, /*< Indent section */ + TidyForceOutput, /*< Output document even if errors were found */ + TidyShowErrors, /*< Number of errors to put out */ + TidyAsciiChars, /*< Convert quotes and dashes to nearest ASCII char */ + TidyJoinClasses, /*< Join multiple class attributes */ + TidyJoinStyles, /*< Join multiple style attributes */ + TidyEscapeCdata, /*< Replace sections with escaped text */ + +#if SUPPORT_ASIAN_ENCODINGS + TidyLanguage, /*< Language property: not used for anything yet */ + TidyNCR, /*< Allow numeric character references */ +#else + TidyLanguageNotUsed, + TidyNCRNotUsed, +#endif +#if SUPPORT_UTF16_ENCODINGS + TidyOutputBOM, /*< Output a Byte Order Mark (BOM) for UTF-16 encodings */ + /*< auto: if input stream has BOM, we output a BOM */ +#else + TidyOutputBOMNotUsed, +#endif + + TidyReplaceColor, /*< Replace hex color attribute values with names */ + TidyCSSPrefix, /*< CSS class naming for -clean option */ + + TidyInlineTags, /*< Declared inline tags */ + TidyBlockTags, /*< Declared block tags */ + TidyEmptyTags, /*< Declared empty tags */ + TidyPreTags, /*< Declared pre tags */ + + TidyAccessibilityCheckLevel, /*< Accessibility check level 0 (old style), or 1, 2, 3 */ + + TidyVertSpace, /*< degree to which markup is spread out vertically */ + +#if SUPPORT_ASIAN_ENCODINGS + TidyPunctWrap, /*< consider punctuation and breaking spaces for wrapping */ +#else + TidyPunctWrapNotUsed, +#endif + + TidyMergeEmphasis, /*< Merge nested B and I elements */ + TidyMergeDivs, /*< Merge multiple DIVs */ + TidyDecorateInferredUL, /*< Mark inferred UL elements with no indent CSS */ + TidyPreserveEntities, /*< Preserve entities */ + TidySortAttributes, /*< Sort attributes */ + TidyMergeSpans, /*< Merge multiple SPANs */ + TidyAnchorAsName, /*< Define anchors as name attributes */ + TidyPPrintTabs, /*< Indent using tabs istead of spaces */ + TidySkipNested, /*< Skip nested tags in script and style CDATA */ + N_TIDY_OPTIONS /*< Must be last */ + } +} diff --git a/Interop/TidyOutputSink.cs b/TidyHtml5Managed/Interop/TidyOutputSink.cs similarity index 97% rename from Interop/TidyOutputSink.cs rename to TidyHtml5Managed/Interop/TidyOutputSink.cs index fc846db..924e770 100644 --- a/Interop/TidyOutputSink.cs +++ b/TidyHtml5Managed/Interop/TidyOutputSink.cs @@ -1,44 +1,44 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.Runtime.InteropServices; - -namespace TidyManaged.Interop -{ - internal struct TidyOutputSink - { - internal TidyOutputSink(TidyPutByteFunc putByte) - { - this.sinkData = IntPtr.Zero; - this.putByte = putByte; - } - -#pragma warning disable 0414 - IntPtr sinkData; - - [MarshalAs(UnmanagedType.FunctionPtr)] - TidyPutByteFunc putByte; -#pragma warning restore 0414 - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.Runtime.InteropServices; + +namespace TidyManaged.Interop +{ + internal struct TidyOutputSink + { + internal TidyOutputSink(TidyPutByteFunc putByte) + { + this.sinkData = IntPtr.Zero; + this.putByte = putByte; + } + +#pragma warning disable 0414 + IntPtr sinkData; + + [MarshalAs(UnmanagedType.FunctionPtr)] + TidyPutByteFunc putByte; +#pragma warning restore 0414 + } +} diff --git a/Interop/TidyPutByteFunc.cs b/TidyHtml5Managed/Interop/TidyPutByteFunc.cs similarity index 97% rename from Interop/TidyPutByteFunc.cs rename to TidyHtml5Managed/Interop/TidyPutByteFunc.cs index 6b6fcdd..af7b811 100644 --- a/Interop/TidyPutByteFunc.cs +++ b/TidyHtml5Managed/Interop/TidyPutByteFunc.cs @@ -1,29 +1,29 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; - -namespace TidyManaged.Interop -{ - internal delegate void TidyPutByteFunc(IntPtr sinkData, byte bt); -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; + +namespace TidyManaged.Interop +{ + internal delegate void TidyPutByteFunc(IntPtr sinkData, byte bt); +} diff --git a/Interop/TidyUngetByteFunc.cs b/TidyHtml5Managed/Interop/TidyUngetByteFunc.cs similarity index 97% rename from Interop/TidyUngetByteFunc.cs rename to TidyHtml5Managed/Interop/TidyUngetByteFunc.cs index bdf31c0..cc74145 100644 --- a/Interop/TidyUngetByteFunc.cs +++ b/TidyHtml5Managed/Interop/TidyUngetByteFunc.cs @@ -1,29 +1,29 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; - -namespace TidyManaged.Interop -{ - internal delegate void TidyUngetByteFunc(IntPtr sinkData, byte bt); -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; + +namespace TidyManaged.Interop +{ + internal delegate void TidyUngetByteFunc(IntPtr sinkData, byte bt); +} diff --git a/NewlineType.cs b/TidyHtml5Managed/NewlineType.cs similarity index 97% rename from NewlineType.cs rename to TidyHtml5Managed/NewlineType.cs index 7647894..eb4ac64 100644 --- a/NewlineType.cs +++ b/TidyHtml5Managed/NewlineType.cs @@ -1,46 +1,46 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - /// - /// Represents the available newline types. - /// - public enum NewlineType - { - /// - /// LF (used by Mac OS X, Unix, Linux). - /// - Linefeed, - - /// - /// CRLF (used by Microsoft Windows, DOS etc). - /// - CarriageReturnLinefeed, - - /// - /// CR (used by Mac OS 9 and earlier). - /// - CarriageReturn - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents the available newline types. + /// + public enum NewlineType + { + /// + /// LF (used by Mac OS X, Unix, Linux). + /// + Linefeed, + + /// + /// CRLF (used by Microsoft Windows, DOS etc). + /// + CarriageReturnLinefeed, + + /// + /// CR (used by Mac OS 9 and earlier). + /// + CarriageReturn + } +} diff --git a/OutputSink.cs b/TidyHtml5Managed/OutputSink.cs similarity index 97% rename from OutputSink.cs rename to TidyHtml5Managed/OutputSink.cs index 8861a4b..0598088 100644 --- a/OutputSink.cs +++ b/TidyHtml5Managed/OutputSink.cs @@ -1,45 +1,45 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System; -using System.IO; - -namespace TidyManaged -{ - internal class OutputSink - { - internal OutputSink(Stream stream) - { - this.stream = stream; - this.TidyOutputSink = new Interop.TidyOutputSink(new Interop.TidyPutByteFunc(OnPutByte)); - } - - Stream stream; - internal Interop.TidyOutputSink TidyOutputSink; - - void OnPutByte(IntPtr sinkData, byte bt) - { - this.stream.WriteByte(bt); - } - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.IO; + +namespace TidyManaged +{ + internal class OutputSink + { + internal OutputSink(Stream stream) + { + this.stream = stream; + this.TidyOutputSink = new Interop.TidyOutputSink(new Interop.TidyPutByteFunc(OnPutByte)); + } + + Stream stream; + internal Interop.TidyOutputSink TidyOutputSink; + + void OnPutByte(IntPtr sinkData, byte bt) + { + this.stream.WriteByte(bt); + } + } +} diff --git a/AssemblyInfo.cs b/TidyHtml5Managed/Properties/AssemblyInfo.cs similarity index 82% rename from AssemblyInfo.cs rename to TidyHtml5Managed/Properties/AssemblyInfo.cs index 5eb22ca..14f5cfc 100644 --- a/AssemblyInfo.cs +++ b/TidyHtml5Managed/Properties/AssemblyInfo.cs @@ -1,55 +1,55 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("TidyManaged")] -[assembly: AssemblyDescription("Managed .NET wrapper for the HTML Tidy library")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Mark Beaton")] -[assembly: AssemblyProduct("TidyManaged")] -[assembly: AssemblyCopyright("Copyright © Mark Beaton 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("1c09c222-dbe1-44b3-8983-d4116ec3e051")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("TidyHtml5Managed (.Net 4.6)")] +[assembly: AssemblyDescription("Managed .NET (v4.6) wrapper for the HTML 5 Tidy library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Frandi Dwi")] +[assembly: AssemblyProduct("TidyHtml5Managed")] +[assembly: AssemblyCopyright("Copyright © Frandi Dwi 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1c09c222-dbe1-44b3-8983-d4116ec3e051")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/RepeatedAttributeMode.cs b/TidyHtml5Managed/RepeatedAttributeMode.cs similarity index 97% rename from RepeatedAttributeMode.cs rename to TidyHtml5Managed/RepeatedAttributeMode.cs index d5de2e1..d852335 100644 --- a/RepeatedAttributeMode.cs +++ b/TidyHtml5Managed/RepeatedAttributeMode.cs @@ -1,41 +1,41 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - /// - /// Represents the available repeated-attribute handling modes. - /// - public enum RepeatedAttributeMode - { - /// - /// Keep the first attribute. - /// - KeepFirst, - - /// - /// Keep the last attribute. - /// - KeepLast - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents the available repeated-attribute handling modes. + /// + public enum RepeatedAttributeMode + { + /// + /// Keep the first attribute. + /// + KeepFirst, + + /// + /// Keep the last attribute. + /// + KeepLast + } +} diff --git a/SortStrategy.cs b/TidyHtml5Managed/SortStrategy.cs similarity index 97% rename from SortStrategy.cs rename to TidyHtml5Managed/SortStrategy.cs index cbe4bd5..264c1ab 100644 --- a/SortStrategy.cs +++ b/TidyHtml5Managed/SortStrategy.cs @@ -1,40 +1,40 @@ -// Copyright (c) 2009 Mark Beaton -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. - -namespace TidyManaged -{ - /// - /// Represents values used by some Tidy properties. - /// - public enum SortStrategy - { - /// - /// None. - /// - None, - /// - /// Alpha. - /// - Alpha - } -} +// Copyright (c) 2009 Mark Beaton +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +namespace TidyManaged +{ + /// + /// Represents values used by some Tidy properties. + /// + public enum SortStrategy + { + /// + /// None. + /// + None, + /// + /// Alpha. + /// + Alpha + } +} diff --git a/TidyManaged.csproj b/TidyHtml5Managed/TidyHtml5Managed.csproj similarity index 81% rename from TidyManaged.csproj rename to TidyHtml5Managed/TidyHtml5Managed.csproj index 8cf85a2..b199c28 100644 --- a/TidyManaged.csproj +++ b/TidyHtml5Managed/TidyHtml5Managed.csproj @@ -1,69 +1,73 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {D799633D-00EF-437C-B158-315557D930FC} - Library - Properties - TidyManaged - TidyManaged - v2.0 - 512 - - - true - full - false - bin\Debug\ - TRACE;DEBUG;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; - prompt - 4 - - - none - true - bin\Release\ - TRACE;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; - prompt - 4 - bin\Release\TidyManaged.xml - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {D799633D-00EF-437C-B158-315557D930FC} + Library + Properties + TidyManaged + TidyHTML5Managed + v4.6 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; + prompt + 4 + false + + + none + true + bin\Release\ + TRACE;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; + prompt + 4 + bin\Release\TidyHTML5Managed.xml + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TidyHtml5Managed/VersionInfo.cs b/TidyHtml5Managed/VersionInfo.cs new file mode 100644 index 0000000..981c70f --- /dev/null +++ b/TidyHtml5Managed/VersionInfo.cs @@ -0,0 +1,116 @@ +namespace TidyManaged +{ + /// + /// VersionInfo class + /// + public class VersionInfo + { + #region Private Variables + private const string MIN_SUPPORTED_VERSION = "5.0.0"; + + private const int MAJOR = 0; + private const int MINOR = 1; + private const int PATCH = 2; + + private int[] _version; + #endregion + + #region Properties + + /// + /// Major version + /// + public int VersionMajor + { + get { return _version[MAJOR]; } + } + + /// + /// Minor version + /// + public int VersionMinor + { + get { return _version[MINOR]; } + } + + /// + /// Patch version + /// + public int VersionPatch + { + get { return _version[PATCH]; } + } + + /// + /// The underlying Tidy HTML5 library is a supported version or not + /// + public bool IsSupportedVersion + { + get { return IsGreaterThanOrEquals(MinSupported); } + } + + #endregion + + #region Constructors + + /// + /// Instantiate version object + /// + /// Version number in string + public VersionInfo(string sVersion) + { + _version = new int[3]; + + if (!string.IsNullOrEmpty(sVersion)) + { + string[] vArr = sVersion.Split('.'); + if (vArr.Length > 0) + int.TryParse(vArr[0], out _version[MAJOR]); + if (vArr.Length > 1) + int.TryParse(vArr[1], out _version[MINOR]); + if (vArr.Length > 2) + int.TryParse(vArr[2], out _version[PATCH]); + } + } + + #endregion + + #region Methods + + /// + /// Check whether current version is greater than or equals the compared version + /// + /// Compared version + /// + public bool IsGreaterThanOrEquals(VersionInfo versionToCompare) + { + if (_version[MAJOR] > versionToCompare.VersionMajor) + return true; + else if (_version[MAJOR] == versionToCompare.VersionMajor) + { + if (_version[MINOR] > versionToCompare.VersionMinor) + return true; + else if (_version[MINOR] == versionToCompare.VersionMinor) + { + return _version[PATCH] >= versionToCompare.VersionPatch; + } + } + + return false; + } + + #endregion + + #region Static + + /// + /// Minimum supported version of underlying Tidy HTML5 library + /// + public static VersionInfo MinSupported + { + get { return new VersionInfo(MIN_SUPPORTED_VERSION); } + } + + #endregion + } +} diff --git a/TidyHtml5Managed_Net20/Properties/AssemblyInfo.cs b/TidyHtml5Managed_Net20/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fd41903 --- /dev/null +++ b/TidyHtml5Managed_Net20/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TidyHtml5Managed (.Net 2.0)")] +[assembly: AssemblyDescription("Managed .NET (v2.0) wrapper for the HTML 5 Tidy library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Frandi Dwi")] +[assembly: AssemblyProduct("TidyHtml5Managed")] +[assembly: AssemblyCopyright("Copyright © Frandi Dwi 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c9ff4f09-bf5e-4a10-b610-1da0d2bd30da")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/TidyHtml5Managed_Net20/TidyHtml5Managed_Net20.csproj b/TidyHtml5Managed_Net20/TidyHtml5Managed_Net20.csproj new file mode 100644 index 0000000..762bf6f --- /dev/null +++ b/TidyHtml5Managed_Net20/TidyHtml5Managed_Net20.csproj @@ -0,0 +1,105 @@ + + + + + Debug + AnyCPU + {C9FF4F09-BF5E-4A10-B610-1DA0D2BD30DA} + Library + Properties + TidyManaged + TidyHTML5Managed + v2.0 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + AccessibilityCheckLevel.cs + + + AutoBool.cs + + + DocTypeMode.cs + + + Document.cs + + + EncodingType.cs + + + InputSource.cs + + + Interop\PInvoke.cs + + + Interop\TidyEOFFunc.cs + + + Interop\TidyGetByteFunc.cs + + + Interop\TidyInputSource.cs + + + Interop\TidyOptionId.cs + + + Interop\TidyOutputSink.cs + + + Interop\TidyPutByteFunc.cs + + + Interop\TidyUngetByteFunc.cs + + + NewlineType.cs + + + OutputSink.cs + + + RepeatedAttributeMode.cs + + + SortStrategy.cs + + + VersionInfo.cs + + + + + + \ No newline at end of file diff --git a/TidyHtml5Managed_Net35/Properties/AssemblyInfo.cs b/TidyHtml5Managed_Net35/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0db7403 --- /dev/null +++ b/TidyHtml5Managed_Net35/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TidyHtml5Managed (.Net 3.5)")] +[assembly: AssemblyDescription("Managed .NET (v3.5) wrapper for the HTML 5 Tidy library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Frandi Dwi")] +[assembly: AssemblyProduct("TidyHtml5Managed")] +[assembly: AssemblyCopyright("Copyright © Frandi Dwi 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("94b637be-23dc-403d-9369-a40fa2080808")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/TidyHtml5Managed_Net35/TidyHtml5Managed_Net35.csproj b/TidyHtml5Managed_Net35/TidyHtml5Managed_Net35.csproj new file mode 100644 index 0000000..e68139d --- /dev/null +++ b/TidyHtml5Managed_Net35/TidyHtml5Managed_Net35.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {94B637BE-23DC-403D-9369-A40FA2080808} + Library + Properties + TidyManaged + TidyHTML5Managed + v3.5 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + AccessibilityCheckLevel.cs + + + AutoBool.cs + + + DocTypeMode.cs + + + Document.cs + + + EncodingType.cs + + + InputSource.cs + + + Interop\PInvoke.cs + + + Interop\TidyEOFFunc.cs + + + Interop\TidyGetByteFunc.cs + + + Interop\TidyInputSource.cs + + + Interop\TidyOptionId.cs + + + Interop\TidyOutputSink.cs + + + Interop\TidyPutByteFunc.cs + + + Interop\TidyUngetByteFunc.cs + + + NewlineType.cs + + + OutputSink.cs + + + RepeatedAttributeMode.cs + + + SortStrategy.cs + + + VersionInfo.cs + + + + + + + \ No newline at end of file diff --git a/TidyHtml5Managed_Net40/Properties/AssemblyInfo.cs b/TidyHtml5Managed_Net40/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..967a0f7 --- /dev/null +++ b/TidyHtml5Managed_Net40/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TidyHtml5Managed (.Net 4.0)")] +[assembly: AssemblyDescription("Managed .NET (v4.0) wrapper for the HTML 5 Tidy library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Frandi Dwi")] +[assembly: AssemblyProduct("TidyHtml5Managed")] +[assembly: AssemblyCopyright("Copyright © Frandi Dwi 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("840d7069-1605-4dc3-858b-a8f249fedf4a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/TidyHtml5Managed_Net40/TidyHtml5Managed_Net40.csproj b/TidyHtml5Managed_Net40/TidyHtml5Managed_Net40.csproj new file mode 100644 index 0000000..363546d --- /dev/null +++ b/TidyHtml5Managed_Net40/TidyHtml5Managed_Net40.csproj @@ -0,0 +1,109 @@ + + + + + Debug + AnyCPU + {840D7069-1605-4DC3-858B-A8F249FEDF4A} + Library + Properties + TidyManaged + TidyHTML5Managed + v4.0 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + AccessibilityCheckLevel.cs + + + AutoBool.cs + + + DocTypeMode.cs + + + Document.cs + + + EncodingType.cs + + + InputSource.cs + + + Interop\PInvoke.cs + + + Interop\TidyEOFFunc.cs + + + Interop\TidyGetByteFunc.cs + + + Interop\TidyInputSource.cs + + + Interop\TidyOptionId.cs + + + Interop\TidyOutputSink.cs + + + Interop\TidyPutByteFunc.cs + + + Interop\TidyUngetByteFunc.cs + + + NewlineType.cs + + + OutputSink.cs + + + RepeatedAttributeMode.cs + + + SortStrategy.cs + + + VersionInfo.cs + + + + + + \ No newline at end of file diff --git a/TidyHtml5Managed_Net45/Properties/AssemblyInfo.cs b/TidyHtml5Managed_Net45/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4770806 --- /dev/null +++ b/TidyHtml5Managed_Net45/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TidyHtml5Managed (.Net 4.5)")] +[assembly: AssemblyDescription("Managed .NET (v4.5) wrapper for the HTML 5 Tidy library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Frandi Dwi")] +[assembly: AssemblyProduct("TidyHtml5Managed")] +[assembly: AssemblyCopyright("Copyright © Frandi Dwi 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5fe3954b-6430-4b35-b5c7-5b32c515fccd")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] diff --git a/TidyHtml5Managed_Net45/TidyHtml5Managed_Net45.csproj b/TidyHtml5Managed_Net45/TidyHtml5Managed_Net45.csproj new file mode 100644 index 0000000..8db1c82 --- /dev/null +++ b/TidyHtml5Managed_Net45/TidyHtml5Managed_Net45.csproj @@ -0,0 +1,113 @@ + + + + + Debug + AnyCPU + {5FE3954B-6430-4B35-B5C7-5B32C515FCCD} + Library + Properties + TidyManaged + TidyHTML5Managed + v4.5 + 512 + + + true + full + false + bin\Debug\ + TRACE;DEBUG;SUPPORT_UTF16_ENCODINGS;SUPPORT_ASIAN_ENCODINGS; + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + AccessibilityCheckLevel.cs + + + AutoBool.cs + + + DocTypeMode.cs + + + Document.cs + + + DocumentAsync.cs + + + EncodingType.cs + + + InputSource.cs + + + Interop\PInvoke.cs + + + Interop\TidyEOFFunc.cs + + + Interop\TidyGetByteFunc.cs + + + Interop\TidyInputSource.cs + + + Interop\TidyOptionId.cs + + + Interop\TidyOutputSink.cs + + + Interop\TidyPutByteFunc.cs + + + Interop\TidyUngetByteFunc.cs + + + NewlineType.cs + + + OutputSink.cs + + + RepeatedAttributeMode.cs + + + SortStrategy.cs + + + VersionInfo.cs + + + + + + \ No newline at end of file diff --git a/TidyManaged.sln b/TidyManaged.sln deleted file mode 100644 index 7634682..0000000 --- a/TidyManaged.sln +++ /dev/null @@ -1,23 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TidyManaged", "TidyManaged.csproj", "{D799633D-00EF-437C-B158-315557D930FC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D799633D-00EF-437C-B158-315557D930FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D799633D-00EF-437C-B158-315557D930FC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D799633D-00EF-437C-B158-315557D930FC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D799633D-00EF-437C-B158-315557D930FC}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = TidyManaged.csproj - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/images/sampleoutput.gif b/images/sampleoutput.gif new file mode 100644 index 0000000..2034020 Binary files /dev/null and b/images/sampleoutput.gif differ