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!