removing link data blocks

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

This file has definitions for removing link data blocks. This is the second phase of processing link abbreviations: the link data has already been gathered by gather data for linking constructs.

The logic of this script is weird. We have complicated rules for deleting link data blocks. The basic difficulty is that both the blocks' beginning and end are marked with empty lines. Whether it is a link data block depends on the line that comes after that.

Remove link data blocks.

/^$/,/./{
: del3
/^\[[A-Za-z0-9]\{1,\}\] /,/^$/d
/^%-%/b proceed
}

Generic link syntaces that can be confused with link data blocks. Because labels have not yet been processed, protect against + as the last character.

s#^\[\([^][]*[^][`+]\)\] #w_generic_link(`\1') #g

Now we don't have anything that could be mistaken for beginning of link data block, so we can jump and see whether this line was actually meant to be deleted (because of the range it's in).

s#^#%-%#
b del3
: proceed
s#^%-%##