Nemmet

Class Library
C#
GitHub Repository

What It Is

A tool to expand a string specification to an HTML structure

Status

Just screwed around with it. Originally, it had a horrible manual parser, but re-wrote it using Parlot a few years later.

Details

This was an afternoon project that I did for a challenge and had mixed results with. It’s a C# implementation of , the HTML code expansion tool that’s built into some code editors.

(“Nemmet” = “.NET Emmet”)

I wanted something that would run inside the context of C# that I might use for low-code operations. The README has details about what I implemented from the Emmet “spec” (spoiler: there’s no formal spec).

I put 3-4 hours into this, I think. It might be handy for some applications.

Basic usage:

var code = "div#my-panel.panel > div.heading{Title} + div.content{Content} + div.footer";
var html = NemmetParser.ToHtml(code)
<div id="my-panel" class="panel">
  <div class="heading">
    Title
  </div>
  <div class="content">
    Content
  </div>
  <div class="footer"></div>
</div>

Also, I wrote some pretty good extension points for it.

There’s an example in the source to essentially turn it into something like HAML (of which I am a weird fan).

Something like this:

html  
  head  
    title{Deane was here}  
    link[href='deane.css']  
  body  
    header  
       h1.title{Deane was here} 
       main{...and here}

(Note: the parsing for that is pretty gross. I need to clean that up.)

There’s another extension that allows you to define your own tokens in source that generate something else in the output:

html > head > js{/scripts/deane} + css{/scripts/deane}

The js and css tokens will turn into script and link tags respectively.