├── .nuke ├── source ├── Drdit.Html.Example │ ├── Drdit.Html.Example.csproj │ └── Program.cs └── Drdit.Html │ ├── HtmlString.cs │ ├── HtmlAttribute.cs │ ├── HtmlContent.cs │ ├── Drdit.Html.csproj │ ├── StringBuilderWriter.cs │ ├── IWriter.cs │ ├── HtmlElement.cs │ ├── HtmlElementRenderer.cs │ ├── HtmlAttributes.cs │ └── HtmlTags.cs ├── Drdit.Html.sln.DotSettings ├── LICENSE ├── README.md ├── Drdit.Html.sln └── .gitignore /.nuke: -------------------------------------------------------------------------------- 1 | Drdit.Html.sln -------------------------------------------------------------------------------- /source/Drdit.Html.Example/Drdit.Html.Example.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Drdit.Html.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlString.cs: -------------------------------------------------------------------------------- 1 | namespace Drdit.Html 2 | { 3 | public class HtmlString : HtmlContent 4 | { 5 | private readonly string _content; 6 | 7 | public HtmlString(string content) 8 | { 9 | _content = content; 10 | } 11 | 12 | public override void Render(IWriter writer) 13 | { 14 | if (string.IsNullOrWhiteSpace(_content)) 15 | { 16 | return; 17 | } 18 | 19 | foreach (var ch in _content) 20 | { 21 | writer.WriteEncoded(ch); 22 | } 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Drdit.Html 2 | { 3 | public class HtmlAttribute 4 | { 5 | public readonly string Name; 6 | public readonly string Value; 7 | 8 | public HtmlAttribute(string name, string value) 9 | { 10 | Name = name; 11 | Value = value; 12 | } 13 | 14 | public static HtmlAttribute operator >(HtmlAttribute name, string value) 15 | { 16 | return new HtmlAttribute(name.Name, value); 17 | } 18 | 19 | public static HtmlAttribute operator <(HtmlAttribute name, string value) 20 | { 21 | return new HtmlAttribute(name.Name, value); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlContent.cs: -------------------------------------------------------------------------------- 1 | namespace Drdit.Html 2 | { 3 | public abstract class HtmlContent 4 | { 5 | public string Render() 6 | { 7 | var writer = new StringBuilderWriter(); 8 | Render(writer); 9 | return writer.ToString(); 10 | } 11 | 12 | public abstract void Render(IWriter writer); 13 | 14 | public static implicit operator HtmlContent(string content) 15 | { 16 | return new HtmlString(content); 17 | } 18 | 19 | public static HtmlContent[] operator +(string str, HtmlContent content) 20 | { 21 | return new[] {new HtmlString(str), content}; 22 | } 23 | 24 | public static HtmlContent[] operator +(HtmlContent content, string str) 25 | { 26 | return new[] {content, new HtmlString(str)}; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /source/Drdit.Html/Drdit.Html.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Drdit.Html 5 | Drdit.Html 6 | Drdit.Html is a simple and lightweight, DSL-based, HTML construction library for C#. 7 | netstandard2.0 8 | Drdit.Html 9 | Drdit.Html 10 | 0.1.0 11 | Kirill Volkov 12 | html,dsl,lightweight,template 13 | https://github.com/volkovku/Drdit.Html 14 | https://github.com/volkovku/Drdit.Html 15 | https://raw.githubusercontent.com/volkovku/Drdit.Html/master/LICENSE 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /source/Drdit.Html.Example/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using static Drdit.Html.HtmlTags; 4 | using a = Drdit.Html.HtmlAttributes; 5 | 6 | namespace Drdit.Html.Example 7 | { 8 | static class Program 9 | { 10 | public static void Main() 11 | { 12 | var chars = new[] {"A", "B", "C", "D"}; 13 | var page = 14 | html[ 15 | head[ 16 | meta[a.charset > "utf-8"], 17 | title["Hello world"] 18 | ], 19 | body[ 20 | div[ 21 | p[a.style > "font-weight: bold"]["List of chars:"], 22 | ul[chars.Select(_ => li[_])], 23 | p["Some text ", b["and another text"], p] 24 | ] 25 | ] 26 | ]; 27 | 28 | Console.WriteLine(page.Render()); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Kirill Volkov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Drdit.Html Project 2 | 3 | Drdit.Html is a simple and lightweight, DSL-based, HTML construction [NuGet library](https://www.nuget.org/packages/Drdit.Html) for C#. 4 | 5 | 6 | # Example 7 | 8 | This C# code: 9 | 10 | ```csharp 11 | // using static Drdit.Html.HtmlTags; 12 | // using a = Drdit.Html.HtmlAttributes; 13 | // var chars = new[] {"A", "B", "C", "D"}; 14 | 15 | html[ 16 | head[ 17 | meta[a.charset > "utf-8"], 18 | title["Hello world"] 19 | ], 20 | body[ 21 | div[ 22 | p[a.style > "font-weight: bold"]["List of chars:"], 23 | ul[chars.Select(_ => li[_])], 24 | p["Some text ", b["and another text"], p] 25 | ] 26 | ] 27 | ]; 28 | ``` 29 | 30 | turns into HTML like: 31 | 32 | ```html 33 | 34 | 35 | 36 | Hello world 37 | 38 | 39 |
40 |

List of chars:

41 | 47 |

48 | Some text and another text 49 |

50 |

51 |
52 | 53 | 54 | ``` 55 | 56 | # Motivation 57 | 58 | Writing HTML in pure C# code without large frameworks like RazorTemplates with alien syntactics elements and slow editor. 59 | This HTML constructing library is closest to HTML as possible in C# language aspects. -------------------------------------------------------------------------------- /Drdit.Html.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Drdit.Html", "source\Drdit.Html\Drdit.Html.csproj", "{EC4C9403-824B-4C5B-B5CE-F4AD3B1180AE}" 4 | EndProject 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Drdit.Html.Example", "source\Drdit.Html.Example\Drdit.Html.Example.csproj", "{95C87CFB-AF26-4F14-8AA5-2D157F672F21}" 6 | EndProject 7 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{2E9B5CED-88B2-4001-AAB8-078348FC5913}" 8 | EndProject 9 | Global 10 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 11 | Debug|Any CPU = Debug|Any CPU 12 | Release|Any CPU = Release|Any CPU 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {2E9B5CED-88B2-4001-AAB8-078348FC5913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 16 | {2E9B5CED-88B2-4001-AAB8-078348FC5913}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {EC4C9403-824B-4C5B-B5CE-F4AD3B1180AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {EC4C9403-824B-4C5B-B5CE-F4AD3B1180AE}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {EC4C9403-824B-4C5B-B5CE-F4AD3B1180AE}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {EC4C9403-824B-4C5B-B5CE-F4AD3B1180AE}.Release|Any CPU.Build.0 = Release|Any CPU 21 | {95C87CFB-AF26-4F14-8AA5-2D157F672F21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {95C87CFB-AF26-4F14-8AA5-2D157F672F21}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {95C87CFB-AF26-4F14-8AA5-2D157F672F21}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {95C87CFB-AF26-4F14-8AA5-2D157F672F21}.Release|Any CPU.Build.0 = Release|Any CPU 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /source/Drdit.Html/StringBuilderWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace Drdit.Html 5 | { 6 | public class StringBuilderWriter : IWriter 7 | { 8 | private readonly StringBuilder _stringBuilder; 9 | private readonly int _indentSize; 10 | private int _indent; 11 | 12 | public StringBuilderWriter(StringBuilder stringBuilder = null, int indentSize = 4) 13 | { 14 | if (indentSize < 0) 15 | { 16 | throw new ArgumentException( 17 | "Indent size should be a positive integer value, " + 18 | $"but {indentSize} was found."); 19 | } 20 | 21 | _stringBuilder = stringBuilder ?? new StringBuilder(); 22 | _indentSize = indentSize; 23 | } 24 | 25 | public void NewLine() 26 | { 27 | _stringBuilder.AppendLine(); 28 | for (var i = 0; i < _indent; i++) 29 | { 30 | _stringBuilder.Append(' '); 31 | } 32 | } 33 | 34 | public void IndentStart() 35 | { 36 | _indent += _indentSize; 37 | } 38 | 39 | public void IndentEnd() 40 | { 41 | _indent -= _indentSize; 42 | } 43 | 44 | public void Write(char ch) 45 | { 46 | _stringBuilder.Append(ch); 47 | } 48 | 49 | public void Write(string content) 50 | { 51 | if (string.IsNullOrEmpty(content)) 52 | { 53 | return; 54 | } 55 | 56 | foreach (var ch in content) 57 | { 58 | if (ch == '\r') 59 | { 60 | continue; 61 | } 62 | 63 | if (ch == '\n') 64 | { 65 | NewLine(); 66 | continue; 67 | } 68 | 69 | _stringBuilder.Append(ch); 70 | } 71 | } 72 | 73 | public override string ToString() 74 | { 75 | return _stringBuilder.ToString(); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /source/Drdit.Html/IWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Drdit.Html 4 | { 5 | public interface IWriter 6 | { 7 | void NewLine(); 8 | void IndentStart(); 9 | void IndentEnd(); 10 | void Write(char ch); 11 | void Write(string content); 12 | } 13 | 14 | public static class WriterCompanion 15 | { 16 | public static void WriteEncoded(this IWriter writer, string str) 17 | { 18 | if (writer == null) 19 | { 20 | throw new ArgumentNullException(nameof(writer)); 21 | } 22 | 23 | foreach (var ch in str) 24 | { 25 | if (ch == '\r') 26 | { 27 | continue; 28 | } 29 | 30 | if (ch == '\n') 31 | { 32 | writer.NewLine(); 33 | continue; 34 | } 35 | 36 | writer.WriteEncoded(ch); 37 | } 38 | } 39 | 40 | public static void WriteEncoded(this IWriter writer, char ch) 41 | { 42 | if (writer == null) 43 | { 44 | throw new ArgumentNullException(nameof(writer)); 45 | } 46 | 47 | switch (ch) 48 | { 49 | case '"': 50 | writer.Write("""); 51 | return; 52 | case '<': 53 | writer.Write("<"); 54 | return; 55 | case '>': 56 | writer.Write(">"); 57 | return; 58 | case '&': 59 | writer.Write("&"); 60 | return; 61 | case '\'': 62 | writer.Write("'"); 63 | return; 64 | case '\r': 65 | return; 66 | case '\n': 67 | writer.Write(' '); 68 | return; 69 | default: 70 | writer.Write(ch); 71 | return; 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlElement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace Drdit.Html 6 | { 7 | public class HtmlElement : HtmlContent 8 | { 9 | public readonly string Tag; 10 | public readonly bool Inline; 11 | 12 | public HtmlElement(string tag, bool inline = false) 13 | { 14 | Tag = tag; 15 | Inline = inline; 16 | } 17 | 18 | public HtmlElementWithAttributes this[params HtmlAttribute[] attributes] => 19 | new HtmlElementWithAttributes(Tag, Inline, attributes); 20 | 21 | public HtmlElementWithAttributesAndContent this[params HtmlContent[] content] => 22 | new HtmlElementWithAttributesAndContent(Tag, Inline, Array.Empty(), content); 23 | 24 | public HtmlElementWithAttributesAndContent this[IEnumerable content] => 25 | new HtmlElementWithAttributesAndContent(Tag, Inline, Array.Empty(), 26 | content.ToArray()); 27 | 28 | public override void Render(IWriter writer) => 29 | HtmlElementRenderer.RenderHtmlElement( 30 | writer, 31 | Tag, 32 | Array.Empty(), 33 | Array.Empty()); 34 | } 35 | 36 | public class HtmlElementWithAttributes : HtmlContent 37 | { 38 | internal readonly string Tag; 39 | internal readonly bool Inline; 40 | internal readonly IReadOnlyList Attributes; 41 | 42 | internal HtmlElementWithAttributes( 43 | string tag, 44 | bool inline, 45 | IReadOnlyList attributes) 46 | { 47 | Tag = tag; 48 | Attributes = attributes; 49 | Inline = inline; 50 | } 51 | 52 | public HtmlElementWithAttributesAndContent this[params HtmlContent[] content] => 53 | new HtmlElementWithAttributesAndContent(Tag, Inline, Attributes, content); 54 | 55 | public HtmlElementWithAttributesAndContent this[IEnumerable content] => 56 | new HtmlElementWithAttributesAndContent(Tag, Inline, Attributes, content.ToArray()); 57 | 58 | public override void Render(IWriter writer) => 59 | HtmlElementRenderer.RenderHtmlElement( 60 | writer, 61 | Tag, 62 | Attributes, 63 | Array.Empty()); 64 | } 65 | 66 | public class HtmlElementWithAttributesAndContent : HtmlContent 67 | { 68 | internal readonly string Tag; 69 | internal readonly bool Inline; 70 | internal readonly IReadOnlyList Attributes; 71 | internal readonly IReadOnlyList Content; 72 | 73 | internal HtmlElementWithAttributesAndContent( 74 | string tag, 75 | bool inline, 76 | IReadOnlyList attributes, 77 | IReadOnlyList content) 78 | { 79 | Tag = tag; 80 | Attributes = attributes; 81 | Content = content; 82 | Inline = inline; 83 | } 84 | 85 | public override void Render(IWriter writer) => 86 | HtmlElementRenderer.RenderHtmlElement( 87 | writer, 88 | Tag, 89 | Attributes, 90 | Content); 91 | } 92 | } -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlElementRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Drdit.Html 4 | { 5 | internal static class HtmlElementRenderer 6 | { 7 | public static void RenderHtmlElement( 8 | IWriter writer, 9 | string tag, 10 | IReadOnlyList attributes, 11 | IReadOnlyList content) 12 | { 13 | writer.Write('<'); 14 | writer.Write(tag); 15 | 16 | foreach (var attr in attributes) 17 | { 18 | writer.Write(' '); 19 | writer.WriteEncoded(attr.Name); 20 | 21 | if (!string.IsNullOrEmpty(attr.Value)) 22 | { 23 | writer.Write('='); 24 | writer.Write('"'); 25 | writer.WriteEncoded(attr.Value); 26 | writer.Write('"'); 27 | } 28 | } 29 | 30 | if (content.Count == 0) 31 | { 32 | writer.Write(' '); 33 | writer.Write('/'); 34 | writer.Write('>'); 35 | return; 36 | } 37 | 38 | writer.Write(">"); 39 | 40 | var indentRequired = IsIndentRequired(content); 41 | var continueInline = false; 42 | foreach (var contentUnit in content) 43 | { 44 | if (continueInline && IsIndentRequired(contentUnit)) 45 | { 46 | continueInline = false; 47 | writer.IndentEnd(); 48 | } 49 | 50 | if (indentRequired && !continueInline) 51 | { 52 | writer.IndentStart(); 53 | writer.NewLine(); 54 | } 55 | 56 | contentUnit.Render(writer); 57 | continueInline = !IsIndentRequired(contentUnit); 58 | 59 | if (indentRequired && !continueInline) 60 | { 61 | writer.IndentEnd(); 62 | } 63 | } 64 | 65 | if (indentRequired) 66 | { 67 | if (continueInline) 68 | { 69 | writer.IndentEnd(); 70 | } 71 | 72 | writer.NewLine(); 73 | } 74 | 75 | writer.Write('<'); 76 | writer.Write('/'); 77 | writer.Write(tag); 78 | writer.Write(">"); 79 | } 80 | 81 | private static bool IsIndentRequired(IEnumerable content) 82 | { 83 | foreach (var unit in content) 84 | { 85 | if (IsIndentRequired(unit)) 86 | { 87 | return true; 88 | } 89 | } 90 | 91 | return false; 92 | } 93 | 94 | private static bool IsIndentRequired(HtmlContent content) 95 | { 96 | if (content is HtmlElement el && !el.Inline) 97 | { 98 | return true; 99 | } 100 | 101 | if (content is HtmlElementWithAttributes elWithAttr && 102 | !elWithAttr.Inline) 103 | { 104 | return true; 105 | } 106 | 107 | if (content is HtmlElementWithAttributesAndContent elWithAttrAndContent && 108 | (!elWithAttrAndContent.Inline || IsIndentRequired(elWithAttrAndContent.Content))) 109 | { 110 | return true; 111 | } 112 | 113 | return false; 114 | } 115 | 116 | 117 | } 118 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015/2017 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # Visual Studio 2017 auto generated files 33 | Generated\ Files/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | 43 | # Build Results of an ATL Project 44 | [Dd]ebugPS/ 45 | [Rr]eleasePS/ 46 | dlldata.c 47 | 48 | # Benchmark Results 49 | BenchmarkDotNet.Artifacts/ 50 | 51 | # .NET Core 52 | project.lock.json 53 | project.fragment.lock.json 54 | artifacts/ 55 | **/Properties/launchSettings.json 56 | 57 | # StyleCop 58 | StyleCopReport.xml 59 | 60 | # Files built by Visual Studio 61 | *_i.c 62 | *_p.c 63 | *_i.h 64 | *.ilk 65 | *.meta 66 | *.obj 67 | *.iobj 68 | *.pch 69 | *.pdb 70 | *.ipdb 71 | *.pgc 72 | *.pgd 73 | *.rsp 74 | *.sbr 75 | *.tlb 76 | *.tli 77 | *.tlh 78 | *.tmp 79 | *.tmp_proj 80 | *.log 81 | *.vspscc 82 | *.vssscc 83 | .builds 84 | *.pidb 85 | *.svclog 86 | *.scc 87 | 88 | # Chutzpah Test files 89 | _Chutzpah* 90 | 91 | # Visual C++ cache files 92 | ipch/ 93 | *.aps 94 | *.ncb 95 | *.opendb 96 | *.opensdf 97 | *.sdf 98 | *.cachefile 99 | *.VC.db 100 | *.VC.VC.opendb 101 | 102 | # Visual Studio profiler 103 | *.psess 104 | *.vsp 105 | *.vspx 106 | *.sap 107 | 108 | # Visual Studio Trace Files 109 | *.e2e 110 | 111 | # TFS 2012 Local Workspace 112 | $tf/ 113 | 114 | # Guidance Automation Toolkit 115 | *.gpState 116 | 117 | # ReSharper is a .NET coding add-in 118 | _ReSharper*/ 119 | *.[Rr]e[Ss]harper 120 | *.DotSettings.user 121 | 122 | # JustCode is a .NET coding add-in 123 | .JustCode 124 | 125 | # TeamCity is a build add-in 126 | _TeamCity* 127 | 128 | # DotCover is a Code Coverage Tool 129 | *.dotCover 130 | 131 | # AxoCover is a Code Coverage Tool 132 | .axoCover/* 133 | !.axoCover/settings.json 134 | 135 | # Visual Studio code coverage results 136 | *.coverage 137 | *.coveragexml 138 | 139 | # NCrunch 140 | _NCrunch_* 141 | .*crunch*.local.xml 142 | nCrunchTemp_* 143 | 144 | # MightyMoose 145 | *.mm.* 146 | AutoTest.Net/ 147 | 148 | # Web workbench (sass) 149 | .sass-cache/ 150 | 151 | # Installshield output folder 152 | [Ee]xpress/ 153 | 154 | # DocProject is a documentation generator add-in 155 | DocProject/buildhelp/ 156 | DocProject/Help/*.HxT 157 | DocProject/Help/*.HxC 158 | DocProject/Help/*.hhc 159 | DocProject/Help/*.hhk 160 | DocProject/Help/*.hhp 161 | DocProject/Help/Html2 162 | DocProject/Help/html 163 | 164 | # Click-Once directory 165 | publish/ 166 | 167 | # Publish Web Output 168 | *.[Pp]ublish.xml 169 | *.azurePubxml 170 | # Note: Comment the next line if you want to checkin your web deploy settings, 171 | # but database connection strings (with potential passwords) will be unencrypted 172 | *.pubxml 173 | *.publishproj 174 | 175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 176 | # checkin your Azure Web App publish settings, but sensitive information contained 177 | # in these scripts will be unencrypted 178 | PublishScripts/ 179 | 180 | # NuGet Packages 181 | *.nupkg 182 | # The packages folder can be ignored because of Package Restore 183 | **/[Pp]ackages/* 184 | # except build/, which is used as an MSBuild target. 185 | !**/[Pp]ackages/build/ 186 | # Uncomment if necessary however generally it will be regenerated when needed 187 | #!**/[Pp]ackages/repositories.config 188 | # NuGet v3's project.json files produces more ignorable files 189 | *.nuget.props 190 | *.nuget.targets 191 | 192 | # Microsoft Azure Build Output 193 | csx/ 194 | *.build.csdef 195 | 196 | # Microsoft Azure Emulator 197 | ecf/ 198 | rcf/ 199 | 200 | # Windows Store app package directories and files 201 | AppPackages/ 202 | BundleArtifacts/ 203 | Package.StoreAssociation.xml 204 | _pkginfo.txt 205 | *.appx 206 | 207 | # Visual Studio cache files 208 | # files ending in .cache can be ignored 209 | *.[Cc]ache 210 | # but keep track of directories ending in .cache 211 | !*.[Cc]ache/ 212 | 213 | # Others 214 | ClientBin/ 215 | ~$* 216 | *~ 217 | *.dbmdl 218 | *.dbproj.schemaview 219 | *.jfm 220 | *.pfx 221 | *.publishsettings 222 | orleans.codegen.cs 223 | 224 | # Including strong name files can present a security risk 225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 226 | #*.snk 227 | 228 | # Since there are multiple workflows, uncomment next line to ignore bower_components 229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 230 | #bower_components/ 231 | 232 | # RIA/Silverlight projects 233 | Generated_Code/ 234 | 235 | # Backup & report files from converting an old project file 236 | # to a newer Visual Studio version. Backup files are not needed, 237 | # because we have git ;-) 238 | _UpgradeReport_Files/ 239 | Backup*/ 240 | UpgradeLog*.XML 241 | UpgradeLog*.htm 242 | ServiceFabricBackup/ 243 | *.rptproj.bak 244 | 245 | # SQL Server files 246 | *.mdf 247 | *.ldf 248 | *.ndf 249 | 250 | # Business Intelligence projects 251 | *.rdl.data 252 | *.bim.layout 253 | *.bim_*.settings 254 | *.rptproj.rsuser 255 | 256 | # Microsoft Fakes 257 | FakesAssemblies/ 258 | 259 | # GhostDoc plugin setting file 260 | *.GhostDoc.xml 261 | 262 | # Node.js Tools for Visual Studio 263 | .ntvs_analysis.dat 264 | node_modules/ 265 | 266 | # Visual Studio 6 build log 267 | *.plg 268 | 269 | # Visual Studio 6 workspace options file 270 | *.opt 271 | 272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 273 | *.vbw 274 | 275 | # Visual Studio LightSwitch build output 276 | **/*.HTMLClient/GeneratedArtifacts 277 | **/*.DesktopClient/GeneratedArtifacts 278 | **/*.DesktopClient/ModelManifest.xml 279 | **/*.Server/GeneratedArtifacts 280 | **/*.Server/ModelManifest.xml 281 | _Pvt_Extensions 282 | 283 | # Paket dependency manager 284 | .paket/paket.exe 285 | paket-files/ 286 | 287 | # FAKE - F# Make 288 | .fake/ 289 | 290 | # JetBrains Rider 291 | .idea/ 292 | *.sln.iml 293 | 294 | # CodeRush 295 | .cr/ 296 | 297 | # Python Tools for Visual Studio (PTVS) 298 | __pycache__/ 299 | *.pyc 300 | 301 | # Cake - Uncomment if you are using it 302 | # tools/** 303 | # !tools/packages.config 304 | 305 | # Tabs Studio 306 | *.tss 307 | 308 | # Telerik's JustMock configuration file 309 | *.jmconfig 310 | 311 | # BizTalk build output 312 | *.btp.cs 313 | *.btm.cs 314 | *.odx.cs 315 | *.xsd.cs 316 | 317 | # OpenCover UI analysis results 318 | OpenCover/ 319 | 320 | # Azure Stream Analytics local run output 321 | ASALocalRun/ 322 | 323 | # MSBuild Binary and Structured Log 324 | *.binlog 325 | 326 | # NVidia Nsight GPU debugger configuration file 327 | *.nvuser 328 | 329 | # MFractors (Xamarin productivity tool) working folder 330 | .mfractor/ 331 | -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlAttributes.cs: -------------------------------------------------------------------------------- 1 | namespace Drdit.Html 2 | { 3 | public static class HtmlAttributes 4 | { 5 | // Disable naming verification rules. It's better for DSL to be closest to native HTML dialect. 6 | // ReSharper disable InconsistentNaming 7 | public static HtmlAttribute hidden = new HtmlAttribute("hidden", null); 8 | public static HtmlAttribute high = new HtmlAttribute("high", null); 9 | public static HtmlAttribute href = new HtmlAttribute("href", null); 10 | public static HtmlAttribute hreflang = new HtmlAttribute("hreflang", null); 11 | public static HtmlAttribute icon = new HtmlAttribute("icon", null); 12 | public static HtmlAttribute id = new HtmlAttribute("id", null); 13 | public static HtmlAttribute ismap = new HtmlAttribute("ismap", null); 14 | public static HtmlAttribute itemprop = new HtmlAttribute("itemprop", null); 15 | public static HtmlAttribute keytype = new HtmlAttribute("keytype", null); 16 | public static HtmlAttribute kind = new HtmlAttribute("kind", null); 17 | public static HtmlAttribute label = new HtmlAttribute("label", null); 18 | public static HtmlAttribute lang = new HtmlAttribute("lang", null); 19 | public static HtmlAttribute language = new HtmlAttribute("language", null); 20 | public static HtmlAttribute list = new HtmlAttribute("list", null); 21 | public static HtmlAttribute loop = new HtmlAttribute("loop", null); 22 | public static HtmlAttribute low = new HtmlAttribute("low", null); 23 | public static HtmlAttribute manifest = new HtmlAttribute("manifest", null); 24 | public static HtmlAttribute max = new HtmlAttribute("max", null); 25 | public static HtmlAttribute maxlength = new HtmlAttribute("maxlength", null); 26 | public static HtmlAttribute media = new HtmlAttribute("media", null); 27 | public static HtmlAttribute method = new HtmlAttribute("method", null); 28 | public static HtmlAttribute min = new HtmlAttribute("min", null); 29 | public static HtmlAttribute multiple = new HtmlAttribute("multiple", null); 30 | public static HtmlAttribute name = new HtmlAttribute("name", null); 31 | public static HtmlAttribute novalidate = new HtmlAttribute("novalidate", null); 32 | public static HtmlAttribute open = new HtmlAttribute("open", null); 33 | public static HtmlAttribute optimum = new HtmlAttribute("optimum", null); 34 | public static HtmlAttribute pattern = new HtmlAttribute("pattern", null); 35 | public static HtmlAttribute ping = new HtmlAttribute("ping", null); 36 | public static HtmlAttribute placeholder = new HtmlAttribute("placeholder", null); 37 | public static HtmlAttribute poster = new HtmlAttribute("poster", null); 38 | public static HtmlAttribute preload = new HtmlAttribute("preload", null); 39 | public static HtmlAttribute pubdate = new HtmlAttribute("pubdate", null); 40 | public static HtmlAttribute radiogroup = new HtmlAttribute("radiogroup", null); 41 | public static HtmlAttribute @readonly = new HtmlAttribute("readonly", null); 42 | public static HtmlAttribute rel = new HtmlAttribute("rel", null); 43 | public static HtmlAttribute required = new HtmlAttribute("required", null); 44 | public static HtmlAttribute reversed = new HtmlAttribute("reversed", null); 45 | public static HtmlAttribute rows = new HtmlAttribute("rows", null); 46 | public static HtmlAttribute rowspan = new HtmlAttribute("rowspan", null); 47 | public static HtmlAttribute sandbox = new HtmlAttribute("sandbox", null); 48 | public static HtmlAttribute spellcheck = new HtmlAttribute("spellcheck", null); 49 | public static HtmlAttribute scope = new HtmlAttribute("scope", null); 50 | public static HtmlAttribute scoped = new HtmlAttribute("scoped", null); 51 | public static HtmlAttribute seamless = new HtmlAttribute("seamless", null); 52 | public static HtmlAttribute selected = new HtmlAttribute("selected", null); 53 | public static HtmlAttribute shape = new HtmlAttribute("shape", null); 54 | public static HtmlAttribute size = new HtmlAttribute("size", null); 55 | public static HtmlAttribute sizes = new HtmlAttribute("sizes", null); 56 | public static HtmlAttribute span = new HtmlAttribute("span", null); 57 | public static HtmlAttribute src = new HtmlAttribute("src", null); 58 | public static HtmlAttribute srcdoc = new HtmlAttribute("srcdoc", null); 59 | public static HtmlAttribute srclang = new HtmlAttribute("srclang", null); 60 | public static HtmlAttribute srcset = new HtmlAttribute("srcset", null); 61 | public static HtmlAttribute start = new HtmlAttribute("start", null); 62 | public static HtmlAttribute step = new HtmlAttribute("step", null); 63 | public static HtmlAttribute style = new HtmlAttribute("style", null); 64 | public static HtmlAttribute summary = new HtmlAttribute("summary", null); 65 | public static HtmlAttribute tabindex = new HtmlAttribute("tabindex", null); 66 | public static HtmlAttribute target = new HtmlAttribute("target", null); 67 | public static HtmlAttribute title = new HtmlAttribute("title", null); 68 | public static HtmlAttribute type = new HtmlAttribute("type", null); 69 | public static HtmlAttribute usemap = new HtmlAttribute("usemap", null); 70 | public static HtmlAttribute value = new HtmlAttribute("value", null); 71 | public static HtmlAttribute width = new HtmlAttribute("width", null); 72 | public static HtmlAttribute wrap = new HtmlAttribute("wrap", null); 73 | public static HtmlAttribute border = new HtmlAttribute("border", null); 74 | public static HtmlAttribute buffered = new HtmlAttribute("buffered", null); 75 | public static HtmlAttribute challenge = new HtmlAttribute("challenge", null); 76 | public static HtmlAttribute charset = new HtmlAttribute("charset", null); 77 | public static HtmlAttribute @checked = new HtmlAttribute("checked", null); 78 | public static HtmlAttribute cite = new HtmlAttribute("cite", null); 79 | public static HtmlAttribute @class = new HtmlAttribute("class", null); 80 | public static HtmlAttribute cls = new HtmlAttribute("class", null); 81 | public static HtmlAttribute code = new HtmlAttribute("code", null); 82 | public static HtmlAttribute codebase = new HtmlAttribute("codebase", null); 83 | public static HtmlAttribute color = new HtmlAttribute("color", null); 84 | public static HtmlAttribute cols = new HtmlAttribute("cols", null); 85 | public static HtmlAttribute colspan = new HtmlAttribute("colspan", null); 86 | public static HtmlAttribute content = new HtmlAttribute("content", null); 87 | public static HtmlAttribute contenteditable = new HtmlAttribute("contenteditable", null); 88 | public static HtmlAttribute contextmenu = new HtmlAttribute("contextmenu", null); 89 | public static HtmlAttribute controls = new HtmlAttribute("controls", null); 90 | public static HtmlAttribute coords = new HtmlAttribute("coords", null); 91 | public static HtmlAttribute @data = new HtmlAttribute("data", null); 92 | public static HtmlAttribute datetime = new HtmlAttribute("datetime", null); 93 | public static HtmlAttribute @default = new HtmlAttribute("default", null); 94 | public static HtmlAttribute defer = new HtmlAttribute("defer", null); 95 | public static HtmlAttribute dir = new HtmlAttribute("dir", null); 96 | public static HtmlAttribute dirname = new HtmlAttribute("dirname", null); 97 | public static HtmlAttribute disabled = new HtmlAttribute("disabled", null); 98 | public static HtmlAttribute download = new HtmlAttribute("download", null); 99 | public static HtmlAttribute draggable = new HtmlAttribute("draggable", null); 100 | public static HtmlAttribute dropzone = new HtmlAttribute("dropzone", null); 101 | public static HtmlAttribute enctype = new HtmlAttribute("enctype", null); 102 | public static HtmlAttribute @for = new HtmlAttribute("for", null); 103 | public static HtmlAttribute form = new HtmlAttribute("form", null); 104 | public static HtmlAttribute formaction = new HtmlAttribute("formaction", null); 105 | public static HtmlAttribute headers = new HtmlAttribute("headers", null); 106 | public static HtmlAttribute height = new HtmlAttribute("height", null); 107 | public static HtmlAttribute accept = new HtmlAttribute("accept", null); 108 | public static HtmlAttribute accesskey = new HtmlAttribute("accesskey", null); 109 | public static HtmlAttribute action = new HtmlAttribute("action", null); 110 | public static HtmlAttribute align = new HtmlAttribute("align", null); 111 | public static HtmlAttribute alt = new HtmlAttribute("alt", null); 112 | public static HtmlAttribute async = new HtmlAttribute("async", null); 113 | public static HtmlAttribute autocomplete = new HtmlAttribute("autocomplete", null); 114 | public static HtmlAttribute autofocus = new HtmlAttribute("autofocus", null); 115 | public static HtmlAttribute autoplay = new HtmlAttribute("autoplay", null); 116 | public static HtmlAttribute autosave = new HtmlAttribute("autosave", null); 117 | public static HtmlAttribute bgcolor = new HtmlAttribute("bgcolor", null); 118 | } 119 | } -------------------------------------------------------------------------------- /source/Drdit.Html/HtmlTags.cs: -------------------------------------------------------------------------------- 1 | namespace Drdit.Html 2 | { 3 | public static class HtmlTags 4 | { 5 | // Disable naming verification rules. It's better for DSL to be closest to native HTML dialect. 6 | // ReSharper disable InconsistentNaming 7 | public static HtmlElement a => new HtmlElement("a", inline: true); 8 | public static HtmlElement abbr => new HtmlElement("abbr", inline: true); 9 | public static HtmlElement acronym => new HtmlElement("acronym", inline: true); 10 | public static HtmlElement address => new HtmlElement("address"); 11 | public static HtmlElement applet => new HtmlElement("applet"); 12 | public static HtmlElement area => new HtmlElement("area"); 13 | public static HtmlElement article => new HtmlElement("article"); 14 | public static HtmlElement aside => new HtmlElement("aside"); 15 | public static HtmlElement audio => new HtmlElement("audio"); 16 | public static HtmlElement b => new HtmlElement("b", inline: true); 17 | public static HtmlElement @base => new HtmlElement("base"); 18 | public static HtmlElement basefont => new HtmlElement("basefont"); 19 | public static HtmlElement bb => new HtmlElement("bb"); 20 | public static HtmlElement bdo => new HtmlElement("bdo", inline: true); 21 | public static HtmlElement big => new HtmlElement("big", inline: true); 22 | public static HtmlElement blockquote => new HtmlElement("blockquote"); 23 | public static HtmlElement body => new HtmlElement("body"); 24 | public static HtmlElement br => new HtmlElement("br", inline: true); 25 | public static HtmlElement button => new HtmlElement("button", inline: true); 26 | public static HtmlElement canvas => new HtmlElement("canvas"); 27 | public static HtmlElement caption => new HtmlElement("caption"); 28 | public static HtmlElement center => new HtmlElement("center"); 29 | public static HtmlElement cite => new HtmlElement("cite", inline: true); 30 | public static HtmlElement code => new HtmlElement("code", inline: true); 31 | public static HtmlElement col => new HtmlElement("col"); 32 | public static HtmlElement colgroup => new HtmlElement("colgroup"); 33 | public static HtmlElement command => new HtmlElement("command"); 34 | public static HtmlElement datagrid => new HtmlElement("datagrid"); 35 | public static HtmlElement datalist => new HtmlElement("datalist"); 36 | public static HtmlElement dd => new HtmlElement("dd"); 37 | public static HtmlElement del => new HtmlElement("del"); 38 | public static HtmlElement details => new HtmlElement("details"); 39 | public static HtmlElement dfn => new HtmlElement("dfn", inline: true); 40 | public static HtmlElement dialog => new HtmlElement("dialog"); 41 | public static HtmlElement dir => new HtmlElement("dir"); 42 | public static HtmlElement div => new HtmlElement("div"); 43 | public static HtmlElement dl => new HtmlElement("dl"); 44 | public static HtmlElement dt => new HtmlElement("dt"); 45 | public static HtmlElement em => new HtmlElement("em", inline: true); 46 | public static HtmlElement embed => new HtmlElement("embed"); 47 | public static HtmlElement eventsource => new HtmlElement("eventsource"); 48 | public static HtmlElement fieldset => new HtmlElement("fieldset"); 49 | public static HtmlElement figcaption => new HtmlElement("figcaption"); 50 | public static HtmlElement figure => new HtmlElement("figure"); 51 | public static HtmlElement font => new HtmlElement("font"); 52 | public static HtmlElement footer => new HtmlElement("footer"); 53 | public static HtmlElement form => new HtmlElement("form"); 54 | public static HtmlElement frame => new HtmlElement("frame"); 55 | public static HtmlElement frameset => new HtmlElement("frameset"); 56 | public static HtmlElement h1 => new HtmlElement("h1", inline: true); 57 | public static HtmlElement h2 => new HtmlElement("h2", inline: true); 58 | public static HtmlElement h3 => new HtmlElement("h3", inline: true); 59 | public static HtmlElement h4 => new HtmlElement("h4", inline: true); 60 | public static HtmlElement h5 => new HtmlElement("h5", inline: true); 61 | public static HtmlElement h6 => new HtmlElement("h6", inline: true); 62 | public static HtmlElement head => new HtmlElement("head"); 63 | public static HtmlElement header => new HtmlElement("header"); 64 | public static HtmlElement hgroup => new HtmlElement("hgroup"); 65 | public static HtmlElement hr => new HtmlElement("hr"); 66 | public static HtmlElement html => new HtmlElement("html"); 67 | public static HtmlElement i => new HtmlElement("i", inline: true); 68 | public static HtmlElement iframe => new HtmlElement("iframe"); 69 | public static HtmlElement img => new HtmlElement("img", inline: true); 70 | public static HtmlElement input => new HtmlElement("input", inline: true); 71 | public static HtmlElement ins => new HtmlElement("ins"); 72 | public static HtmlElement isindex => new HtmlElement("isindex"); 73 | public static HtmlElement kbd => new HtmlElement("kbd", inline: true); 74 | public static HtmlElement keygen => new HtmlElement("keygen"); 75 | public static HtmlElement label => new HtmlElement("label", inline: true); 76 | public static HtmlElement legend => new HtmlElement("legend"); 77 | public static HtmlElement li => new HtmlElement("li"); 78 | public static HtmlElement link => new HtmlElement("link", inline: true); 79 | public static HtmlElement map => new HtmlElement("map", inline: true); 80 | public static HtmlElement mark => new HtmlElement("mark"); 81 | public static HtmlElement menu => new HtmlElement("menu"); 82 | public static HtmlElement meta => new HtmlElement("meta"); 83 | public static HtmlElement meter => new HtmlElement("meter"); 84 | public static HtmlElement nav => new HtmlElement("nav"); 85 | public static HtmlElement noframes => new HtmlElement("noframes"); 86 | public static HtmlElement noscript => new HtmlElement("noscript"); 87 | public static HtmlElement @object => new HtmlElement("object", inline: true); 88 | public static HtmlElement ol => new HtmlElement("ol"); 89 | public static HtmlElement optgroup => new HtmlElement("optgroup"); 90 | public static HtmlElement option => new HtmlElement("option"); 91 | public static HtmlElement output => new HtmlElement("output", inline: true); 92 | public static HtmlElement p => new HtmlElement("p"); 93 | public static HtmlElement param => new HtmlElement("param"); 94 | public static HtmlElement pre => new HtmlElement("pre"); 95 | public static HtmlElement progress => new HtmlElement("progress"); 96 | public static HtmlElement q => new HtmlElement("q", inline: true); 97 | public static HtmlElement rp => new HtmlElement("rp"); 98 | public static HtmlElement rt => new HtmlElement("rt"); 99 | public static HtmlElement ruby => new HtmlElement("ruby"); 100 | public static HtmlElement s => new HtmlElement("s"); 101 | public static HtmlElement samp => new HtmlElement("samp", inline: true); 102 | public static HtmlElement script => new HtmlElement("script"); 103 | public static HtmlElement section => new HtmlElement("section"); 104 | public static HtmlElement select => new HtmlElement("select"); 105 | public static HtmlElement small => new HtmlElement("small", inline: true); 106 | public static HtmlElement source => new HtmlElement("source"); 107 | public static HtmlElement span => new HtmlElement("span", inline: true); 108 | public static HtmlElement strike => new HtmlElement("strike"); 109 | public static HtmlElement strong => new HtmlElement("strong", inline: true); 110 | public static HtmlElement style => new HtmlElement("style"); 111 | public static HtmlElement sub => new HtmlElement("sub", inline: true); 112 | public static HtmlElement sup => new HtmlElement("sup", inline: true); 113 | public static HtmlElement table => new HtmlElement("table"); 114 | public static HtmlElement tbody => new HtmlElement("tbody"); 115 | public static HtmlElement td => new HtmlElement("td"); 116 | public static HtmlElement textarea => new HtmlElement("textarea", inline: true); 117 | public static HtmlElement tfoot => new HtmlElement("tfoot"); 118 | public static HtmlElement th => new HtmlElement("th"); 119 | public static HtmlElement thead => new HtmlElement("thead"); 120 | public static HtmlElement time => new HtmlElement("time", inline: true); 121 | public static HtmlElement title => new HtmlElement("title", inline: true); 122 | public static HtmlElement tr => new HtmlElement("tr"); 123 | public static HtmlElement track => new HtmlElement("track"); 124 | public static HtmlElement tt => new HtmlElement("tt", inline: true); 125 | public static HtmlElement u => new HtmlElement("u"); 126 | public static HtmlElement ul => new HtmlElement("ul"); 127 | public static HtmlElement var => new HtmlElement("var", inline: true); 128 | public static HtmlElement video => new HtmlElement("video"); 129 | public static HtmlElement wbr => new HtmlElement("wbr"); 130 | } 131 | } --------------------------------------------------------------------------------