{"id":18355870,"url":"https://github.com/anduin2017/hsharp","last_synced_at":"2025-04-10T01:46:15.832Z","repository":{"id":65980287,"uuid":"85605341","full_name":"Anduin2017/HSharp","owner":"Anduin2017","description":"HSharp is a library used to analyse markup language like HTML easily and fastly.","archived":false,"fork":false,"pushed_at":"2025-03-18T07:02:25.000Z","size":163,"stargazers_count":66,"open_issues_count":3,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T23:35:53.052Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/Anduin2017.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-03-20T17:19:46.000Z","updated_at":"2025-03-18T07:02:28.000Z","dependencies_parsed_at":"2023-02-19T19:31:16.204Z","dependency_job_id":"2b63c534-20ad-493b-8d4f-7252bdce7182","html_url":"https://github.com/Anduin2017/HSharp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anduin2017%2FHSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anduin2017%2FHSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anduin2017%2FHSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anduin2017%2FHSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anduin2017","download_url":"https://codeload.github.com/Anduin2017/HSharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142536,"owners_count":21054665,"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","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":[],"created_at":"2024-11-05T22:08:13.003Z","updated_at":"2025-04-10T01:46:15.797Z","avatar_url":"https://github.com/Anduin2017.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HSharp\n\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.aiursoft.cn/anduin/hsharp/-/blob/master/LICENSE)\n[![Pipeline stat](https://gitlab.aiursoft.cn/anduin/hsharp/badges/master/pipeline.svg)](https://gitlab.aiursoft.cn/anduin/hsharp/-/pipelines)\n[![Test Coverage](https://gitlab.aiursoft.cn/anduin/hsharp/badges/master/coverage.svg)](https://gitlab.aiursoft.cn/anduin/hsharp/-/pipelines)\n[![NuGet version)](https://img.shields.io/nuget/v/Anduin.HSharp.svg)](https://www.nuget.org/packages/Anduin.HSharp/)\n[![ManHours](https://manhours.aiursoft.cn/r/gitlab.aiursoft.cn/anduin/hsharp.svg)](https://gitlab.aiursoft.cn/anduin/hsharp/-/commits/master?ref_type=heads)\n\nHSharp is a library used to analyze markup language like HTML easily.\n\n## Only Two Functions\n\n* Deserialize and analyze HTML\n* Build HTML using C#\n\n## How to install\n\n### Using Nuget\n\nTo install Anduin.HSharp, run the following command in the [Package Manager Console](https://docs.nuget.org/docs/start-here/using-the-package-manager-console)\n\n```bash\nPM\u003e Install-Package Anduin.HSharp\n```\n\n### Using .NET CLI tool\n\nTo install Anduin.HSharp, run the following command in any console:\n\n```bash\ndotnet add package Anduin.HSharp\n```\n\n## Examples\n\n### Deserialize HTML\n\nInput some HTML and get the DOM of it.\n\n```csharp\nstring exampleHtml = $@\"\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003cmeta charset=\"\"utf-8\"\"\u003e\n        \u003cmeta name=\"\"viewport\"\"\u003e\n        \u003ctitle\u003eExample\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        Some Text\n        \u003ctable\u003e\n            \u003ctr\u003eOneLine\u003c/tr\u003e\n            \u003ctr\u003eTwoLine\u003c/tr\u003e\n            \u003ctr\u003eThreeLine\u003c/tr\u003e\n        \u003c/table\u003e\n        Other Text\n    \u003c/body\u003e\n\u003c/html\u003e\";\nvar doc = HtmlConvert.DeserializeHtml(exampleHtml);\n\nConsole.WriteLine(doc[\"html\"][\"head\"][\"meta\",0].Properties[\"charset\"]);\nConsole.WriteLine(doc[\"html\"][\"head\"][\"meta\",1].Properties[\"name\"]);\nforeach (var line in doc[\"html\"][\"body\"][\"table\"])\n{\n    Console.WriteLine(line.Son);\n}\n```\n\nOutput:\n\n```html\nutf-8\nviewport\nOneLine\nTwoLine\nThreeLine\n```\n\n### Build HTML\n\nCreate a simple HDoc and add some children to its body.\n\n````CSharp\nvar document = new HDoc(DocumentOptions.BasicHTML);\ndocument[\"html\"][\"body\"].AddChild(\"div\");\ndocument[\"html\"][\"body\"][\"div\"].AddChild(\"a\", new HProp(\"href\", \"/#\"));\nvar result = document.GenerateHTML();\n````\n\nOutput:\n\n````html\n\u003chtml\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\u003c/meta\u003e\n    \u003ctitle\u003e\n        Example\n    \u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cdiv\u003e\n        \u003ca href=\"/#\"\u003e\u003c/a\u003e\n    \u003c/div\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n````\n\nHSharp **can** also operate other Markup languages like XML and XAML\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanduin2017%2Fhsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanduin2017%2Fhsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanduin2017%2Fhsharp/lists"}