As part of an ANSI standard update, I'm experimenting with replacing the 
rather laborious OpenOffice document process with Asciidoc. So far, things 
have been pretty good, except. . . .

The syntax illustrations (think fancy BNF) are currently implemented rather 
painfully as OpenOffice tables with some of the terms highlighted and 
linked to their definitions. I'd like to use plain TeX to typeset them into 
images (PNGs for the html5 backend, and EPSes for the docbook backend), and 
then output the <img> tag. To that end, I wrote a Python program (tex2img) 
to do just that; it not only does a nice job antialiasing them, but it can 
handle \specials that dvips recognizes to create links (and make them the 
same color as links in the document), and tex2img then writes an imagemap 
to accompany the PNG.

It's still early days in the process, so only PNG support is implemented 
right now, but I'm having trouble integrating it with asciidoc, and I'm 
pretty sure I'm just misunderstanding the process.

This is the current filters/tex/tex-filter.conf file:

# In human-readable form:
#
# tex-style=
#   template="tex{format?-{format}}-block",
#   subs=(),
#   posattrs=('style','target','subdir','format','bgcolor','transparency',
#             
'prologue','epilogue','dpi','magstep','quality','oversampling'),
#   filter='tex2img.py {verbose? -v}
#             {format? --format="{format}"}
#             {bgcolor? --bg="{bgcolor}"}
#             {transparency? --transparency}
#             {prologue? --prologue="{prologue}"}
#             {epilogue? --epilogue="{epilogue}"}
#             {dpi? --dpi="{dpi}"}
#             {magstep? --magstep={magstep}}
#             {quality? --quality="{quality}"}
#             {oversampling?--oversampling="{oversampling}"}
#             -o "{outdir={indir}}/{subdir=}{subdir?/}{target}"
#             -'

#

ifndef::data-uri[]
tex-style=template="tex{format?-{format}}-block",subs=(),posattrs=('style','target','subdir','format','bgcolor','transparency','prologue','epilogue','dpi','magstep','quality','oversampling'),filter='tex2img.py{verbose?
 
-v}{format? --format="{format}"}{bgcolor? --bg="{bgcolor}"}{transparency? 
--transparency}{prologue? --prologue="{prologue}"}{epilogue? 
--epilogue="{epilogue}"}{dpi? --dpi="{dpi}"}{magstep? 
--magstep={magstep}}{quality? 
--quality="{quality}"}{oversampling?--oversampling="{oversampling}"} -o 
"{outdir={indir}}/{subdir=}{subdir?/}{target}" -'
endif::data-uri[]

ifdef::data-uri[]
tex-style=template="tex{format?-{format}}-block",subs=(),posattrs=('style','target','subdir','format','bgcolor','transparency','prologue','epilogue','dpi','magstep','quality','oversampling'),filter='tex2img.py{verbose?
 
-v}{format? --format="{format}"}{bgcolor? --bg="{bgcolor}"}{transparency? 
--transparency}{prologue? --prologue="{prologue}"}{epilogue? 
--epilogue="{epilogue}"}{dpi? --dpi="{dpi}"}{magstep? 
--magstep={magstep}}{quality? 
--quality="{quality}"}{oversampling?--oversampling="{oversampling}"} -o 
"{indir={outdir}}/{subdir=}{subdir?/}{target}" -'
endif::data-uri[]


[blockdef-open]
template::[tex-filter-style]

[blockdef-listing]
template::[tex-filter-style]

[paradef-default]
template::[tex-filter-style]

[tex-block]
template::[filter-image-blockmacro]


Problem one: I'm not sure how posattrs works here. I'd like to be able to 
say (to typeset this somewhat larger, and to prepend a special prologue 
file that defines the \meta and \isdefinedas macros):

[tex, meta-example.png, magstep="2", prologue="prologue.tex"]
.Caption thingy
----------------------------------------------------------------------
$$
  \meta[name] \isdefinedas
    \left| \matrix{
      \literal[\%]\cr
      \meta[ident]\cr
      } \right|\;
    \left[ \matrix{
      \meta[digit]\cr
      \meta[ident]\cr
      } \right]\;\dots
$$
----------------------------------------------------------------------


and have the magstep and prologue variables get used rather than be forced 
to specify each of these positionally. It doesn't seem to matter whether I 
have them in the posattrs list or not. The documentation is a little 
confusing, as single brackets sometimes contain named attributes like this 
and sometimes not. Is there a way to name attributes like this, and/or to 
define default values for these in asciidoc.conf or in the asciidoc source 
(since I want them all to be uniform)?

Problem two: As part of my research on this, I've modeled the tex-whatever 
on graphviz-whatever, and as such, I've also set up parallel statements in 
asciidoc.conf corresponding to all the graphviz definitions. This has led 
to one other issue: I can't seem to get the result of tex2img into the 
appropriate place.

Currently, the block definition parallels the graphviz one exactly:

[tex-block]
{target%}{counter2:target-number}
{target%}{set2:target:{docname}__{target-number}.png}
|
<div class="imageblock{style? {style}}{role? {role}}{unbreakable-option? 
unbreakable}"{id? id="{id}"}{align? style="text-align:{align};"}{float? 
style="float:{float};"}>
<div class="content">
{data-uri%}<img src="{imagesdir=}{imagesdir?/}{target}" 
alt="{alt={target}}"{width? width="{width}"}{height? height="{height}"} />
{data-uri#}<img alt="{alt={target}}"{width? width="{width}"}{height? 
height="{height}"} 
src="data:image/{eval:os.path.splitext(r'{target}')[1][1:]};base64,
{data-uri#}{sys:"{python}" -u -c "import base64,sys; 
base64.encode(sys.stdin,sys.stdout)" < 
"{eval:os.path.join(r"{indir={outdir}}",r"{imagesdir=}",r"{target}")}"}" />
{link#}</a>
</div>
<div class="title">{caption={figure-caption} {counter:figure-number}. 
}{title}</div>
</div>


That said, I have no idea where these parameters come from. {id}? {align}? 
{width}? Which would be fine, except that while the graphviz filter outputs 
this:

<div class="imageblock graphviz">
<div class="content">
<img src="graphviz-test.png" alt="graphviz-test.png" />
</div>
<div class="title">Figure 1. Graphviz (<code>dot</code>) test</div>
</div>


the tex filter outputs this:

<img id="textest" src="textest.png" style="width: 44px; height: 28px;" 
/><div class="imageblock tex">
<div class="content">
<img src="textest.png" alt="textest.png" />
</div>
<div class="title">Figure 2. <code>texmath</code> (<span class="TeX">T<span 
class="texlow">E</span>X</span>) test</div>
</div>


Is the filter program's stdout supposed to be inserted where the vertical 
bar is in the -block definition? (If so, I've tried moving it around, to no 
avail.) How can I get the filter's output into the right place? Or should I 
be assigning values to each of those attributes that are getting used in 
the -block definition somehow, and if so, where and how?

Thanks in advance for your help. Of course, once all this is working, I'll 
be happy to write it up and share it if anyone's interested.

—Ken

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to