w_doc_id(s2aimpl.emph)dnl

This file is copyright (c) 2004,2005,2006 by Panu Kalliokoski
and released under the license in ../LICENSE

Different emphasis-like constructs.  These must not cross paragraph
boundaries and are only recognised in the presence of both an opening
and closing marker, so we handle them one paragraph at a time.

Literal blocks should be passed untouched.  If a literal block was met
when gathering a paragraph's lines (see below), it is processed now.
{{{
x
/^{{{$/ {
G
x
s#.*##
}
x
/^{{{$/,/^}}}$/ b
/^{{{\n/,/^}}}$/ b
}}}

First, gather lines until we reach an empty line or literal block to
process emphasis as paragraphs.  End of file has to be made a special
case.
{{{
: gather
s#
$##
$ b nogather
N
/\n$/ b nogather
/\n{{{$/ {
s###
x
s#.*#{{{#
x
b nogather
}
b gather
: nogather
}}}

Normalise whitespace.  Spaces inserted at the beginning and end of line
are taken away later.
{{{
s#^# #
s#$# #
}}}

Literal formatting.  We previously supported non-quoted versions but the
new quote-protection scheme should avoid them altogether.  This is quite
a regexp because it's complicated to say, in regular expressions, "a
span of text not containing the string /X/" (where len(/X/) w_gt 1).
{{{
s#\([ \n([{<"-]\)`'w_apo`'`'w_apo`'\([^ `]\(\([^`]\(`'w_apo`'[^`]\)*\(`'w_us`'\)*\(`'w[^_]\)*\(`'[^w]\)*\)*[^ `]\)*\)`'w_apo`'`'w_apo`'\([] \n,.;:?!)}>"-]\)#\1w_literal(`\2')\9#g
}}}

Underscores have two forms, depending on whether they are already
quoted.
{{{
s#\([ \n([{<"'-]\)`'w_us`'\([^ `]\(\([^`]\(`'w_apo`'\)*\(`'w[^_]\)*\(`'[^w]\)*\)*[^ `]\)*\)`'w_us`'\([] \n,.;:?!)}>"'-]\)#\1w_emph(`\2')\8#g
s#\([ \n([{<"'-]\)_\([^ _]\(\([^_]\(w_\)*\)*[^ _]\)*\)_\([] \n,.;:?!)}>"'-]\)#\1w_emph(`\2')\6#g
}}}

Other kinds of emphasis.
{{{
s#\([ \n([{<"'-]\)/\([^ /]\([^/]*[^ /]\)*\)/\([] \n,.;:?!)}>"'-]\)#\1w_techemph(`\2')\4#g
s#\([ \n([{<"'-]\)\*\([^ *]\([^*]*[^ *]\)*\)\*\([] \n,.;:?!)}>"'-]\)#\1w_strong(`\2')\4#g
}}}

Quotations are processed last to make it possible to have something
emphasised within quotes.
{{{
s#\([ \n([{<'`-]\)"\([^ "']\([^"]*[^ "]\)*\)"\([] \n,.;:?!)}>'-]\)#\1w_quotation(`\2')\4#g
}}}

Strip whitespace inserted above.
{{{
s#^ ##
s# $##
}}}
