Hi,
I have been applying this patch to Asciidoc for a couple of releases now.
It really has been a time saver and allows for more automation. I hope you
will consider it for permanent inclusion in Asciidoc.
Summary:
Rather than quietly deleting an entire line when a simple attribute
reference is missing, --- more often just a fat-finger typo --- leave the
line alone and issue a warning message. In large documents throwing away a
line without notice can be frustrating and time consuming.
Patch:
The patch (diff -u) has been tested on the current Asciidoc release, 8.6.8,
as well as the current trunk.
Attached:
1. Patch
2. Small Asciidoc source example
3. Output from source
Thank you.
Peg Russell
--
You received this message because you are subscribed to the Google Groups
"asciidoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/asciidoc?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
= Test [PATCH] Warning message for missing simple attribute references
:rule1: wet
:rule2: light
:rule3: midnight
Before simple attribute reference.
Three Gremlin ownership rules. Number three is the *MOST* imporant!
. Never get a Gremlin {rule1}.
. Never expose a Gremlin to {rule2}.
. And *most* important, do not feed the Gremlins after {rules3}.
After simple attribute reference.
Oppsss, perhaps a typo. Simple attribute reference misspelled (rules3 vs rule3).
Without patch, line deleted with no warning. With patch, line remains intact
and a warning message is issued to stdout.
// kate: syntax AsciiDoc[PATCH] Warning message for missing simple attribute references
Before simple attribute reference.
Three Gremlin ownership rules. Number three is the MOST imporant!
1. Never get a Gremlin wet.
2. Never expose a Gremlin to light.
3. And most important, do not feed the Gremlins after {rules3}. <--- This
line is gone without the patch.
After simple attribute reference.
Oppsss, perhaps a typo. Simple attribute reference misspelled (rules3 vs rule3).
Without patch, entire line deleted with no warning. With patch, line remains
intact and a warning message is issued to stdout.
asciidoc: WARNING: test-asciidoc-install: line 22: undefined attribute:
{rules3} <--- Warning message--- /usr/bin/asciidoc.py 2013-03-06 16:22:07.000000000 -0600
+++ ./asciidoc.py 2013-03-06 17:14:39.000000000 -0600
@@ -1178,8 +1178,13 @@
# Drop line if it contains unsubstituted {name} references.
skipped = re.search(r'(?su)\{[^\\\W][-\w]*?\}(?!\\)', line)
if skipped:
- trace('dropped line', line)
- continue;
+ if line[0] == '<' or skipped.group(0) == '{zzzzz}' or
skipped.group(0) == '{revnumber}' or skipped.group(0) == '{themedir}' or
skipped.group(0) == '{stylesheet}' or skipped.group(0) == '{float}' or
skipped.group(0) == '{headrows}' or skipped.group(0) == '{footrows}' or
skipped.group(0) == '{attribution}':
+ trace('dropped line', line)
+ continue;
+ else:
+ result.append(line)
+ message.warning('undefined attribute: %s' % skipped.group(0))
+ continue;
# Expand system attributes (eval has precedence).
reos = [
re.compile(r'(?su)\{(?P<action>eval):(?P<expr>.*?)\}(?!\\)'),