block level element syntax

This file is copyright © 2004,2005,2006,2011 by Panu Kalliokoski and released under the stx2any license.

Block rules. These are quite simple: we process line at a time, classifying them by the kind of block-level element they begin. Grouping these into logical entities is done on the m4 side.

First, because we want to jump to the end immediately after first matching classification, clear the t flag of sed.

t foo
: foo

Basically, there need not be special support for w_beg and w_end. However, if we process them as their own line type, they won't leave irritating markup in the output (most importantly, no w_bline) and there is less need for whitespace-related quirks in the implementing m4 code.

s#^\( *\)\(w_invoke(`w_beg')(.*)\) *$#w_newindent(len(`\1'))\2`'dnl#
t end
s#^\( *\)\(w_invoke(`w_end')(.*)\) *$#w_newindent(len(`\1'))\2`'dnl#
t end

Next, there are the syntaxes which take the whole line. These don't need a trailing w_eline.

s#^\(!!*\) *\(.*\)$#w_headl(len(\1),`\2')#
t end
s#^ *$#w_para#
t end
s#^---*$#w_sbreak(len(&))#
t end
s#^\( *\)\(.*\)::$#w_term(len(`\1'),`\2')#
t end

Otherwise, add the end-of-line marker. Because this is not a classification, clear the t flag again.

s#$#`'w_eline#
t bar
: bar

Lists are recognised from the beginning of the line. They induce two indent levels (one for the list, one for the item text) so we report both.

s#^\(\( *\)\*  *\)#w_item(len(`\2'),len(`\1'),*)`'#
t end
s#^\(\( *\)-  *\)#w_item(len(`\2'),len(`\1'),-)`'#
t end
s#^\(\( *\)\#  *\)#w_item(len(`\2'),len(`\1'),\#)`'#
t end

Everything else is an ordinary text line. End of classification.

s#^ *#w_bline(len(`&'))`'#
: end