quoting unmatched apostrophes

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

Pass preformatted blocks through.

/^{{{$/,/^}}}$/ b

Here, we temporarily quote matched quotes. Then we permanently change unmatched closing quotes into macros (so that they won't meddle with quoting). Then, we change the temporarily quoted matched quotes back into real quotes. Result: matched quotes remain the same, unmatched close quotes will be converted back into apostrophes when the macro is expanded, and unmatched open quotes trigger an error.

t morequ
: morequ
s#`\([^']*\)'#REALOPENQUOTE\1REALCLOSEQUOTE#g
t morequ
/`/{
$i\
w_error(Unmatched open quote)
N
/\n{{{$/i\
w_error(Unmatched open quote)
b morequ
}
s#'#`'w_apo`'#g
s#REALOPENQUOTE#`#g
s#REALCLOSEQUOTE#'#g

Convert tabs into spaces outside preformatted text. This is best done in as early a phase as possible, so we don't have to write tabs in our formatting regexps.

s#	#        #g