This file is copyright © 2004,2005,2006,2011 by Panu Kalliokoski and released under the stx2any 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. This script should come ofter the scriptlet [impl.gatherpara].
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 length(X) > 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# $##