diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2010-08-04 12:24:27 +1200 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2010-08-04 12:24:27 +1200 |
commit | c206ecc3a903696ffe0b47512b8f570aa0afb389 (patch) | |
tree | 9f2d2cc455c7f2a59abf36b542e4fa181065eb30 | |
parent | 38f6518c49c265158ab6c0bcd5cd2b9e2ff1bfff (diff) | |
download | asciidoc-c206ecc3a903696ffe0b47512b8f570aa0afb389.tar.gz |
- FIXED: Filter execution now occurs prior to filter markup template
substitution to ensure image data URI encoding happens after image generation
(see
http://groups.google.com/group/asciidoc/browse_thread/thread/14e8fcb289a135b).
- Suppressed md5 module deprecation warning from music and graphviz filters.
-rw-r--r-- | asciidoc.conf | 11 | ||||
-rwxr-xr-x | asciidoc.py | 18 | ||||
-rw-r--r-- | docbook.conf | 3 | ||||
-rw-r--r-- | filters/graphviz/graphviz-filter.conf | 2 | ||||
-rw-r--r-- | filters/latex/latex-filter.conf | 2 | ||||
-rwxr-xr-x | filters/latex/latex2png.py | 4 | ||||
-rw-r--r-- | filters/music/music-filter.conf | 2 | ||||
-rwxr-xr-x | filters/music/music2png.py | 4 | ||||
-rw-r--r-- | html4.conf | 3 | ||||
-rw-r--r-- | xhtml11-quirks.conf | 3 | ||||
-rw-r--r-- | xhtml11.conf | 3 |
11 files changed, 34 insertions, 21 deletions
diff --git a/asciidoc.conf b/asciidoc.conf index ed5b713..03e05ec 100644 --- a/asciidoc.conf +++ b/asciidoc.conf @@ -521,6 +521,17 @@ template::[pass-blockmacro] [passblock]
|
+[filter-image-blockmacro]
+# Synthesize missing target attribute for filter generated file names.
+# The tag split | ensures missing target file names are auto-generated
+# before the filter is executed, the remainder (the [image-blockmacro])
+# is excuted after the filter to ensure data URI encoding comes after
+# the image is created.
+{target%}{counter2:target-number}
+{target%}{set2:target:{docname}__{target-number}.png}
+|
+template::[image-blockmacro]
+
#----------------------------------
# Default special section templates
#----------------------------------
diff --git a/asciidoc.py b/asciidoc.py index c4dbc51..cc14786 100755 --- a/asciidoc.py +++ b/asciidoc.py @@ -2433,10 +2433,11 @@ class Paragraph(AbstractBlock): body = Lex.subs(body,presubs) template = self.parameters.template template = subs_attrs(template,attrs) - stag,etag = config.section2tags(template, self.attributes) + stag = config.section2tags(template, self.attributes,skipend=True)[0] if self.parameters.filter: body = filter_lines(self.parameters.filter,body,self.attributes) body = Lex.subs(body,postsubs) + etag = config.section2tags(template, self.attributes,skipstart=True)[1] # Write start tag, content, end tag. writer.write(dovetail_tags(stag,body,etag),trace='paragraph') @@ -2774,14 +2775,15 @@ class DelimitedBlock(AbstractBlock): else: template = self.parameters.template template = subs_attrs(template,attrs) - stag,etag = config.section2tags(template,self.attributes) name = self.short_name()+' block' if 'sectionbody' in options: # The body is treated like a section body. + stag,etag = config.section2tags(template,self.attributes) writer.write(stag,trace=name+' open') Section.translate_body(self) writer.write(etag,trace=name+' close') else: + stag = config.section2tags(template,self.attributes,skipend=True)[0] body = reader.read_until(self.delimiter,same_file=True) presubs = self.parameters.presubs postsubs = self.parameters.postsubs @@ -2790,6 +2792,7 @@ class DelimitedBlock(AbstractBlock): body = filter_lines(self.parameters.filter,body,self.attributes) body = Lex.subs(body,postsubs) # Write start tag, content, end tag. + etag = config.section2tags(template,self.attributes,skipstart=True)[1] writer.write(dovetail_tags(stag,body,etag),trace=name) trace(self.short_name()+' block close',etag) if reader.eof(): @@ -4632,10 +4635,11 @@ class Config: for k,v in self.sections.items(): self.sections[k] = self.expand_templates(v) - def section2tags(self, section, d={}): + def section2tags(self, section, d={}, skipstart=False, skipend=False): """Perform attribute substitution on 'section' using document attributes plus 'd' attributes. Return tuple (stag,etag) containing - pre and post | placeholder tags.""" + pre and post | placeholder tags. 'skipstart' and 'skipend' are + used to suppress substitution.""" assert section is not None if section in self.sections: body = self.sections[section] @@ -4664,8 +4668,10 @@ class Config: title = d.get('title') if title: d['title'] = chr(0) # Replace with unused character. - stag = subs_attrs(stag, d) - etag = subs_attrs(etag, d) + if not skipstart: + stag = subs_attrs(stag, d) + if not skipend: + etag = subs_attrs(etag, d) # Put the {title} back. if title: stag = map(lambda x: x.replace(chr(0), title), stag) diff --git a/docbook.conf b/docbook.conf index e98bbb4..04a6974 100644 --- a/docbook.conf +++ b/docbook.conf @@ -76,9 +76,6 @@ latexmath-style=template="latexmathblock",subs=[] </inlinemediaobject>
[image-blockmacro]
-# Synthesize missing target attribute (for filter generated file names).
-{target%}{counter2:target-number}
-{target%}{set2:target:{docname}__{target-number}.png}
<figure{id? id="{id}"}{role? role="{role}"}{reftext? xreflabel="{reftext}"}{pgwide-option? pgwide="1"}><title>{title}</title>
{title%}<informalfigure{id? id="{id}"}{role? role="{role}"}{reftext? xreflabel="{reftext}"}>{pgwide-option?<?dbfo pgwide="1"?>}
# DocBook XSL Stylesheets custom processing instructions.
diff --git a/filters/graphviz/graphviz-filter.conf b/filters/graphviz/graphviz-filter.conf index d95ef95..e735aee 100644 --- a/filters/graphviz/graphviz-filter.conf +++ b/filters/graphviz/graphviz-filter.conf @@ -11,7 +11,7 @@ graphviz-style=template="graphviz{format?-{format}}-block",subs=(),posattrs=("st graphviz-style=template="graphviz{format?-{format}}-block",subs=(),posattrs=("style","target","layout","format"),filter='graphviz2png.py {verbose?-v} -o "{outdir={indir}}/{imagesdir=}{imagesdir?/}{target}" -L {layout=dot} -F {format=png} -' [graphviz-block] -template::[image-blockmacro] +template::[filter-image-blockmacro] # EXPERIMENTAL: xhtml11 backend SVG image block. ifdef::backend-xhtml11[] diff --git a/filters/latex/latex-filter.conf b/filters/latex/latex-filter.conf index 570b7e3..b863839 100644 --- a/filters/latex/latex-filter.conf +++ b/filters/latex/latex-filter.conf @@ -12,4 +12,4 @@ latex-style=template="latex-block",subs=(),posattrs=("style","target","dpi"),fil latex-style=template="latex-block",subs=(),posattrs=("style","target","dpi"),filter='latex2png.py -m{verbose? -v}{dpi? -D {dpi}} -o "{outdir={indir}}/{imagesdir=}{imagesdir?/}{target}" -' [latex-block] -template::[image-blockmacro] +template::[filter-image-blockmacro] diff --git a/filters/latex/latex2png.py b/filters/latex/latex2png.py index 48736c8..7b60146 100755 --- a/filters/latex/latex2png.py +++ b/filters/latex/latex2png.py @@ -56,6 +56,10 @@ COPYING granted under the terms of the MIT License. ''' +# Suppress warning: "the md5 module is deprecated; use hashlib instead" +import warnings +warnings.simplefilter('ignore',DeprecationWarning) + import os, sys, tempfile, md5 VERSION = '0.1.0' diff --git a/filters/music/music-filter.conf b/filters/music/music-filter.conf index 7fb08e2..9db89cd 100644 --- a/filters/music/music-filter.conf +++ b/filters/music/music-filter.conf @@ -12,7 +12,7 @@ music-style=template="music-block",subs=(),posattrs=("style","target","format"), music-style=template="music-block",subs=(),posattrs=("style","target","format"),filter='music2png.py -m{verbose? -v}{format? -f {format}} -o "{outdir={indir}}/{imagesdir=}{imagesdir?/}{target}" -' [music-block] -template::[image-blockmacro] +template::[filter-image-blockmacro] # # DEPRECATED: Pre 8.2.7 filter definition. diff --git a/filters/music/music2png.py b/filters/music/music2png.py index 60d3f9b..7f61b81 100755 --- a/filters/music/music2png.py +++ b/filters/music/music2png.py @@ -50,6 +50,10 @@ COPYING granted under the terms of the GNU General Public License (GPL). ''' +# Suppress warning: "the md5 module is deprecated; use hashlib instead" +import warnings +warnings.simplefilter('ignore',DeprecationWarning) + import os, sys, tempfile, md5 VERSION = '0.1.1' @@ -42,9 +42,6 @@ template::[pi-blockmacro] {link#}</a>
[image-blockmacro]
-# Synthesize missing target attribute (for filter generated file names).
-{target%}{counter2:target-number}
-{target%}{set2:target:{docname}__{target-number}.png}
<div{align? align="{align}"}{float? style="float:{float};"}>
<a name="{id}"></a>
<a href="{link}">
diff --git a/xhtml11-quirks.conf b/xhtml11-quirks.conf index 2e239f6..633708c 100644 --- a/xhtml11-quirks.conf +++ b/xhtml11-quirks.conf @@ -5,9 +5,6 @@ #
[image-blockmacro]
-# Synthesize missing target attribute (for filter generated file names).
-{target%}{counter2:target-number}
-{target%}{set2:target:{docname}__{target-number}.png}
<div class="imageblock{style? {style}}"{id? id="{id}"}{align? style="text-align:{align};"}{float? style="float:{float};"}>
<div class="content">
<a class="image" href="{link}">
diff --git a/xhtml11.conf b/xhtml11.conf index 2b29aa3..30da42e 100644 --- a/xhtml11.conf +++ b/xhtml11.conf @@ -84,9 +84,6 @@ latexmath-style=template="latexmathblock",subs=[] </span>
[image-blockmacro]
-# Synthesize missing target attribute (for filter generated file names).
-{target%}{counter2:target-number}
-{target%}{set2:target:{docname}__{target-number}.png}
<div class="imageblock{style? {style}}"{id? id="{id}"}{align? style="text-align:{align};"}{float? style="float:{float};"}>
<div class="content">
<a class="image" href="{link}">
|