Kevin
2012-05-28 22:36:17 UTC
Hey guys, it's me again.
I was creating a "config" file to be used in all the documents in a
project and one thing I wanted to do was "auto-anchor" titles.
I have titles like so:
= An Awesome Heading =
and I have the following preproc so far:
%%!preproc: '^=+(.*?)=+$' '\g<0>[\1]'
This gets me this far:
= An Awesome Heading =[ An Awesome Heading ]
I can easily modify the regex to remove the outside spaces:
= An Awesome Heading =[An Awesome Heading]
but that doesn't quite cover it. Is there a way to strip spaces (and
other bad characters) from a section of a line. I have considered
brute-forcing it but that isn't pretty and can only handle a set amount
of words.
%!preproc: '^=+\s*(\S*?)\s*(\S*?)\s*(\S*?)\s*(\S*?)\s*=+$' '\g<0>[\1\2\3\4]'
This last one works but is super ugly. Does anyone have and suggestions?
Thanks, Kevin
I was creating a "config" file to be used in all the documents in a
project and one thing I wanted to do was "auto-anchor" titles.
I have titles like so:
= An Awesome Heading =
and I have the following preproc so far:
%%!preproc: '^=+(.*?)=+$' '\g<0>[\1]'
This gets me this far:
= An Awesome Heading =[ An Awesome Heading ]
I can easily modify the regex to remove the outside spaces:
= An Awesome Heading =[An Awesome Heading]
but that doesn't quite cover it. Is there a way to strip spaces (and
other bad characters) from a section of a line. I have considered
brute-forcing it but that isn't pretty and can only handle a set amount
of words.
%!preproc: '^=+\s*(\S*?)\s*(\S*?)\s*(\S*?)\s*(\S*?)\s*=+$' '\g<0>[\1\2\3\4]'
This last one works but is super ugly. Does anyone have and suggestions?
Thanks, Kevin