Re: [dev] Makefile/markdown based static site generator

From: Sam Watkins <sam_AT_nipl.net>
Date: Thu, 21 Feb 2013 16:20:23 +1100

On Thu, Feb 21, 2013 at 12:10:04PM +0800, Kai Hendry wrote:
> Thanks Nick for sharing that Makefile.
> I've decided to use the first HTML comment in the markdown
> as the page title.

Why not make it the same as the main heading?
or use the first line of the markdown?
or use the file name / folder name (for index), somehow filtered?

> If you can suggest something that sucks less than:
> grep -m1 -oP '(?<=<!-- ).*?(?= -->)' # i'd be grateful ;)

Well I kind of misconstrued this as looking for the first HTML comment
in HTML, but it's much the same idea I guess:

        html_comments | head -n1

then you have to write html_comments, which you already did I guess. I'd probably use real perl...

        perl -nE 'say "$1" while /<!--\s*(.*?)\s*-->/g'

or other tools with simpler regexps:

        html_split | grep '^<!--' | sed 's/<!-- *//; s/ *-->$//'

or all in sed, assuming sane html:

        html_split | sed 's/<!-- *//; s/ *-->$//p'

that 'grep' might be better written:

        starts_with '<!--'

and the sed:

        trim '<!--' '-->' | trim_space

 
I want to critique head(1) and tail(1), but I'm getting carried away. ;)

YMMV as to whether making lots of little tools you might never use again
sucks more or less than one somewhat opaque invocation of grep!
Received on Thu Feb 21 2013 - 06:20:23 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 21 2013 - 19:25:32 CET