Nice. Haven't gone through it fully, but the header parsing stood out for improvement. Use match to capture number of '#' characters and use length, for example:<p><pre><code> $ echo '# ' | awk 'match($0, /^#+ /, m){print length(m[0])-1}'
1
$ echo '### ' | awk 'match($0, /^#+ /, m){print length(m[0])-1}'
3
</code></pre>
You can also use capture groups so that you do not need -1 and remove that substr as well.<p><pre><code> awk 'match($0, /^(#+) (.+)/, m){l=length(m[1]); print "<h" l ">" m[2] "</h" l ">"}'</code></pre>
Would it be ok to use elements of this to improve the one we ship with Werc?<p><a href="http://code.9front.org/hg/werc/file/2ace198c631b/bin/contrib/md2html.awk" rel="nofollow">http://code.9front.org/hg/werc/file/2ace198c631b/bin/contrib...</a>