{"id":21257811,"url":"https://github.com/maroontress/htmlbuilder","last_synced_at":"2025-10-27T17:04:53.845Z","repository":{"id":51534358,"uuid":"173578481","full_name":"maroontress/HtmlBuilder","owner":"maroontress","description":"HtmlBuilder is a .NET library for building HTML documents. It depends on .NET Standard 2.1.","archived":false,"fork":false,"pushed_at":"2025-01-11T08:56:23.000Z","size":176,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T04:12:25.693Z","etag":null,"topics":["csharp","csharp8","dotnet-standard","html","html-document","html-generator"],"latest_commit_sha":null,"homepage":"https://maroontress.github.io/HtmlBuilder/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maroontress.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-03T13:29:10.000Z","updated_at":"2024-07-28T21:30:06.000Z","dependencies_parsed_at":"2025-07-11T02:38:06.853Z","dependency_job_id":"b23858c4-5ea2-4597-adee-b39d43626609","html_url":"https://github.com/maroontress/HtmlBuilder","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/maroontress/HtmlBuilder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroontress%2FHtmlBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroontress%2FHtmlBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroontress%2FHtmlBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroontress%2FHtmlBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maroontress","download_url":"https://codeload.github.com/maroontress/HtmlBuilder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroontress%2FHtmlBuilder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281305277,"owners_count":26478380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","csharp8","dotnet-standard","html","html-document","html-generator"],"created_at":"2024-11-21T04:05:56.874Z","updated_at":"2025-10-27T17:04:53.805Z","avatar_url":"https://github.com/maroontress.png","language":"C#","readme":"# HtmlBuilder\n\nHtmlBuilder is a C# class library building HTML documents. It depends on .NET\nStandard 2.1.\n\n## Examples\n\n### Elements\n\nGenerate the HTML document with HtmlBuilder as follows:\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy first web page\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cp\u003eHello, World!\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThe following code provides the string `result`, which represents\nthe same HTML document (but it does not contain indentation or line breaks).\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar html = nodeOf.Html.Add(\n    nodeOf.Head.Add(\n        nodeOf.Title.Add(\"My first web page\")),\n    nodeOf.Body.Add(\n        nodeOf.P.Add(\"Hello, World!\")));\nvar result = html.ToString();\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/YpuE8T)\n\n### Attributes\n\nYou can manipulate the HTML attributes as follows:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar codeFragment = nodeOf.Pre.AddAttributes((\"lang\", \"csharp\"))\n    .Add(\"var list = new List\u003cstring\u003e();\");\nvar result = codeFragment.ToString();\n```\n\nThe string `result` represents as follows:\n\n```html\n\u003cpre lang=\"csharp\"\u003evar list = new List\u0026lt;string\u0026gt;();\u003c/pre\u003e\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/kScW7Y)\n\nYou can generate the empty attribute as follows:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar div = nodeOf.Div\n    .Add(nodeOf.Input.AddEmptyAttributes(\"disabled\"))\n    // Or, specify null to the value.\n    .Add(nodeOf.Button.AddAttributes((\"disabled\", null)));\nvar result = div.ToString();\n```\n\nThe string `result` represents as follows:\n\n```html\n\u003cdiv\u003e\n  \u003cinput disabled\u003e\n  \u003cbutton disabled\u003e\u003c/button\u003e\n\u003c/div\u003e\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/mi6kIW)\n\nNote that you need to handle the `id` and `class` attributes with  the following dedicated methods:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar header = nodeOf.H1.WithId(\"intro\")\n    .WithClass(\"title\", \"anchor\")\n    .Add(\"Introduction\");\nvar result = header.ToString();\n```\n\nThe string `result` represents as follows:\n\n```html\n\u003ch1 id=\"intro\" class=\"title anchor\"\u003eIntroduction\u003c/h1\u003e\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/KT5GJZ)\n\n`Node` objects are immutable, so the Prototype pattern can be applied as follows:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar reverseSpan = nodeOf.Span.WithClass(\"reverse\");\nvar para = nodeOf.P.Add(\n    reverseSpan.Add(\"reversed text\"),\n    nodeOf.Text(\" means the console output. For example, \"),\n    reverseSpan.Add(\"low battery\"),\n    nodeOf.Text(\" and so on.\"));\nvar result = para.ToString();\n```\n\nThe string `result` represents as follows:\n\n```html\n\u003cp\u003e\u003cspan class=\"reverse\"\u003ereversed text\u003c/span\u003e means the console output.\nFor example, \u003cspan class=\"reverse\"\u003elow battery\u003c/span\u003e and so on.\u003c/p\u003e\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/W3D7AG)\n\n### Character References\n\nTo include Character References, use the `CharacterReference` method as follows:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar span = nodeOf.Span.Add(\n    nodeOf.CharacterReference(0x1f5fc));\nvar result = span.ToString();\n```\n\nThe string `result` represents as follows:\n\n```html\n\u003cspan\u003e\u0026#x1F5FC;\u003c/span\u003e\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/QF0Jjk)\n\n### Named Character References\n\nTo include Named Character References, use `Entity` property as follows:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar span = nodeOf.Span.Add(\n    nodeOf.Text(\"Copyright \"),\n    nodeOf.Entity.copy,\n    nodeOf.Text(\" 2019\"));\nvar result = span.ToString();\n```\n\nThe string `result` represents as follows:\n\n```html\n\u003cspan\u003eCopyright \u0026copy; 2019\u003c/span\u003e\n```\n\n\u003e [See the result in .NET Fiddle](https://dotnetfiddle.net/AJFEnI)\n\n### Format\n\nTo contain indentation and line breaks in the result string, use the\n`ToString(FormatOptions)` method as follows:\n\n```csharp\nvar nodeOf = Nodes.NewFactory();\nvar html = nodeOf.Html().Add(...);\nvar result = html.ToString(FormatOptions.DefaultIndent);\n```\n\n## API Reference\n\n- [Maroontress.Html](https://maroontress.github.io/HtmlBuilder/api/latest/html/Maroontress.Html.html) namespace\n\n## How to build\n\n### Requirements to build\n\n- Visual Studio 2022 Version 17.2\n  or [.NET 6.0 SDK (SDK 6.0.300)][dotnet-sdk]\n\n### How to get started\n\n```plaintext\ngit clone URL\ncd HtmlBuilder\ndotnet build\n```\n\n### Get the test coverage report with Coverlet\n\nInstall [ReportGenerator][report-generator] as follows:\n\n```plaintext\ndotnet tool install -g dotnet-reportgenerator-globaltool\n```\n\nRun all tests and get the report in the file `Coverlet-html/index.html`:\n\n```plaintext\nrm -rf MsTestResults\ndotnet test --collect:\"XPlat Code Coverage\" --results-directory MsTestResults \\\n  \u0026\u0026 reportgenerator -reports:MsTestResults/*/coverage.cobertura.xml \\\n    -targetdir:Coverlet-html\n```\n\n[dotnet-sdk]:\n  https://dotnet.microsoft.com/en-us/download\n[report-generator]:\n  https://github.com/danielpalme/ReportGenerator\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaroontress%2Fhtmlbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaroontress%2Fhtmlbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaroontress%2Fhtmlbuilder/lists"}