{"id":19682521,"url":"https://github.com/aglasencnik/emmetnetsharp","last_synced_at":"2026-05-06T06:32:09.627Z","repository":{"id":206805572,"uuid":"717523593","full_name":"aglasencnik/EmmetNetSharp","owner":"aglasencnik","description":"EmmetNetSharp: Seamlessly integrate Emmet's HTML/CSS toolkit into your C# development with this powerful NuGet package. Elevate your coding efficiency and streamline web development in C#.","archived":false,"fork":false,"pushed_at":"2024-02-25T17:33:18.000Z","size":213,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-05T00:43:48.902Z","etag":null,"topics":["csharp","css","dotnet","emmet","html","nuget","productivity","snippets","tools","webdevelopment"],"latest_commit_sha":null,"homepage":"","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/aglasencnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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":"2023-11-11T18:14:36.000Z","updated_at":"2023-12-10T19:47:41.000Z","dependencies_parsed_at":"2024-02-25T18:48:29.059Z","dependency_job_id":null,"html_url":"https://github.com/aglasencnik/EmmetNetSharp","commit_stats":null,"previous_names":["aglasencnik/emmetnetsharp"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/aglasencnik/EmmetNetSharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aglasencnik%2FEmmetNetSharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aglasencnik%2FEmmetNetSharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aglasencnik%2FEmmetNetSharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aglasencnik%2FEmmetNetSharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aglasencnik","download_url":"https://codeload.github.com/aglasencnik/EmmetNetSharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aglasencnik%2FEmmetNetSharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278395913,"owners_count":25979691,"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-04T02:00:05.491Z","response_time":63,"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","css","dotnet","emmet","html","nuget","productivity","snippets","tools","webdevelopment"],"created_at":"2024-11-11T18:11:10.628Z","updated_at":"2025-10-05T00:43:52.319Z","avatar_url":"https://github.com/aglasencnik.png","language":"C#","funding_links":["https://www.buymeacoffee.com/aglasencnik"],"categories":[],"sub_categories":[],"readme":"# EmmetNetSharp\n\n[![NuGet version (EmmetNetSharp)](https://img.shields.io/nuget/v/EmmetNetSharp.svg?style=flat-square)](https://www.nuget.org/packages/EmmetNetSharp/)\n\nEmmetNetSharp: Seamlessly integrate Emmet's HTML/CSS toolkit into your C# development with this powerful NuGet package. Elevate your coding efficiency and streamline web development in C#.\n\n## Installation\n\nTo use EmmetNetSharp in your C# project, you need to install the NuGet package. Follow these simple steps:\n\n### Using NuGet Package Manager\n\n1. **Open Your Project**: Open your project in Visual Studio or your preferred IDE.\n2. **Open the Package Manager Console**: Navigate to `Tools` -\u003e `NuGet Package Manager` -\u003e `Package Manager Console`.\n3. **Install EmmetNetSharp**: Type the following command and press Enter:\n   `Install-Package EmmetNetSharp`\n\n### Using .NET CLI\n\nAlternatively, you can use .NET Core CLI to install EmmetNetSharp. Open your command prompt or terminal and run:\n\n`dotnet add package EmmetNetSharp`\n\n### Verifying the Installation\n\nAfter installation, make sure that EmmetNetSharp is listed in your project dependencies to confirm successful installation.\n\n## Usage\n\nTo expand abbreviation, pass it to the `ExpandAbbreviation` method of the `AbbreviationService` class:\n\n```csharp\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nConsole.WriteLine(abbreviationService.ExpandAbbreviation(\"p\u003ea\")); // \u003cp\u003e\u003ca href=\"\"\u003e\u003c/a\u003e\u003c/p\u003e\n```\n\nBy default, Emmet expands *markup* abbreviation, e.g. abbreviation used for producing nested elements with attributes (like HTML, XML, HAML etc.). If you want to expand *stylesheet* abbreviation, you should pass it as a `Type` property of second argument:\n\n```csharp\nusing EmmetNetSharp.Enums;\nusing EmmetNetSharp.Models;\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nvar config = new UserConfig\n{\n    Type = SyntaxType.Stylesheet\n};\n\nConsole.WriteLine(abbreviationService.ExpandAbbreviation(\"p10\", config)); // padding: 10px\n```\n\nA stylesheet abbreviation has slightly different syntax compared to markup one: it doesn’t support nesting and attributes but allows embedded values in element name.\n\nAlternatively, Emmet supports *syntaxes* with predefined snippets and options:\n\n```csharp\nusing EmmetNetSharp.Enums;\nusing EmmetNetSharp.Models;\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nvar configCss = new UserConfig\n{\n    Type = SyntaxType.Stylesheet\n};\n\nConsole.WriteLine(abbreviationService.ExpandAbbreviation(\"p10\", configCss)); // padding: 10px\n\nvar configStylus = new UserConfig\n{\n    Type = \"stylus\"\n};\n\nConsole.WriteLine(abbreviationService.ExpandAbbreviation(\"p10\", configStylus)); // padding 10px\n```\n\nPredefined syntaxes already have `Type` attribute which describes whether given abbreviation is markup or stylesheet, but if you want to use it with your custom syntax name, you should provide `Type` config option as well (default is `markup`):\n\n```csharp\nusing EmmetNetSharp.Enums;\nusing EmmetNetSharp.Models;\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nvar config = new UserConfig\n{\n    Syntax = \"my-custom-syntax\",\n    Type = SyntaxType.Stylesheet,\n    Options = new AbbreviationOptions\n    {\n        StylesheetBetween = \"__\",\n        StylesheetAfter = \"\"\n    }\n};\n\nConsole.WriteLine(abbreviationService.ExpandAbbreviation(\"p10\", config)); // padding__10px\n```\n\nYou can pass `Options` property as well to shape-up final output or enable/disable various features. See emmet's config pages for more info and available options.\n\n## Extracting abbreviations from text\n\nA common workflow with Emmet is to type abbreviation somewhere in source code and then expand it with editor action. To support such workflow, abbreviations must be properly _extracted_ from source code:\n\n```csharp\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\n\nvar source = \"Hello world ul.tabs\u003eli\";\nvar data = abbreviationService.ExtractAbbreviation(source, 22); // { abbreviation: 'ul.tabs\u003eli' }\n\nConsole.WriteLine(abbreviationService.ExpandAbbreviation(data.Abbreviation)); // \u003cul class=\"tabs\"\u003e\u003cli\u003e\u003c/li\u003e\u003c/ul\u003e\n```\n\nThe `ExtractAbbreviation` function accepts source code (most likely, current line) and character location in source from which abbreviation search should be started. The abbreviation is searched in backward direction: the location pointer is moved backward until it finds abbreviation bound. Returned result is an object with `Abbreviation` property and `Start` and `End` properties which describe location of extracted abbreviation in given source.\n\nMost current editors automatically insert closing quote or bracket for `(`, `[` and `{` characters so when user types abbreviation that uses attributes or text, it will end with the following state (`|` is caret location):\n\n```\nul\u003eli[title=\"Foo|\"]\n```\n\nE.g. caret location is not at the end of abbreviation and must be moved a few characters ahead. The `ExtractAbbreviation` function is able to handle such cases with `LookAhead` option (enabled by default). This this option enabled, `ExtractAbbreviation` method automatically detects auto-inserted characters and adjusts location, which will be available as `End` property of the returned result:\n\n```csharp\nusing EmmetNetSharp.Models;\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nvar options = new AbbreviationExtractOptions \n{ \n    LookAhead = false \n};\n\nvar source = \"a div[title] b\";\nvar loc = 11; // right after \"title\" word\n\n// `lookAhead` is enabled by default\nConsole.WriteLine(abbreviationService.ExtractAbbreviation(source, loc)); // { abbreviation: 'div[title]', start: 2, end: 12 }\nConsole.WriteLine(abbreviationService.ExtractAbbreviation(source, loc, options)); // { abbreviation: 'title', start: 6, end: 11 }\n```\n\nBy default, `ExtractAbbreviation` tries to detect _markup_ abbreviations (see above). _stylesheet_ abbreviations has slightly different syntax so in order to extract abbreviations for stylesheet syntaxes like CSS, you should pass `Type = \"stylesheet\"` option:\n\n```csharp\nusing EmmetNetSharp.Enums;\nusing EmmetNetSharp.Models;\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nvar options = new AbbreviationExtractOptions \n{ \n    Type = SyntaxType.Stylesheet \n};\n\nvar source = \"a{b}\";\nvar loc = 3; // right after \"title\" word\n\nConsole.WriteLine(abbreviationService.ExtractAbbreviation(source, loc)); // { abbreviation: 'a{b}', start: 0, end: 4 }\n\n// Stylesheet abbreviations does not have `{text}` syntax\nConsole.WriteLine(abbreviationService.ExtractAbbreviation(source, loc, options)); // { abbreviation: 'b', start: 2, end: 3 }\n```\n\n### Extract abbreviation with custom prefix\n\nLots of developers uses React (or similar) library for writing UI code which mixes JS and XML (JSX) in the same source code. Since _any_ Latin word can be used as Emmet abbreviation, writing JSX code with Emmet becomes pain since it will interfere with native editor snippets and distract user with false positive abbreviation matches for variable names, methods etc.:\n\n```js\nvar div // `div` is a valid abbreviation, Emmet may transform it to `\u003cdiv\u003e\u003c/div\u003e`\n```\n\nA possible solution for this problem it to use _prefix_ for abbreviation: abbreviation can be successfully extracted only if its preceded with given prefix.\n\n```csharp\nusing EmmetNetSharp.Models;\nusing EmmetNetSharp.Services;\n\nvar abbreviationService = new AbbreviationService();\nvar options = new AbbreviationExtractOptions \n{ \n    Prefix = \"\u003c\" \n};\n\nvar source1 = \"() =\u003e div\";\nvar source2 = \"() =\u003e \u003cdiv\";\n\nabbreviationService.ExtractAbbreviation(source1, source1.Length); // Finds `div` abbreviation\nabbreviationService.ExtractAbbreviation(source2, source2.Length); // Finds `div` abbreviation too\n\nabbreviationService.ExtractAbbreviation(source1, source1.Length, options); // No match, `div` abbreviation is not preceded with `\u003c` prefix\nabbreviationService.ExtractAbbreviation(source2, source2.Length, options); // Finds `div` since it preceded with `\u003c` prefix\n```\n\nWith `prefix` option, you can customize your experience with Emmet in any common syntax (HTML, CSS and so on) if user is distracted too much with Emmet completions for any typed word. A `prefix` may contain multiple character but the last one *must* be a character which is not part of Emmet abbreviation. Good candidates are `\u003c`, `\u0026`, `→` (emoji or Unicode symbol) and so on.\n\n## Other Functionality\n\nEmmetNetSharp also offers other functionality from the Emmet's library, such as HTML and CSS matching, Math expressions and much more.\n\nTake a look at the source code to learn more.\n\n## Support the Project\n\nIf you find this project useful, consider supporting it by [buying me a coffee](https://www.buymeacoffee.com/aglasencnik). Your support is greatly appreciated!\n\n\u003ca href=\"https://www.buymeacoffee.com/aglasencnik\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\n## Contributing\n\nContributions are welcome! If you have a feature to propose or a bug to fix, create a new pull request.\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/aglasencnik/EmmetNetSharp/blob/master/LICENSE.txt).\n\n## Acknowledgment\n\nThis project is inspired by and built upon the [Emmet](https://github.com/emmetio) project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faglasencnik%2Femmetnetsharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faglasencnik%2Femmetnetsharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faglasencnik%2Femmetnetsharp/lists"}