Lex:

I think I have found at least a partial solution to this issue. It
turns out that in using a2x that dblatex ignores the contents of the
Docbook <phrase></phrase> tags of the <textobject> element that is
generated as part of the usual Latex math expressions from the
AsciiDoc text source in producing PDF. Example:

<equation>
    <title>First equation</title>
    <alt><![CDATA[\[C = \alpha + \beta Y^{\gamma} + \epsilon\]]]></
alt>
    <mediaobject>
        <textobject>
            <phrase>dblatex ignores this in the rendering of this
element in the PDF output file</phrase>
        </textobject>
    </mediaobject>
</equation>

It also turns out for XSLT using a2x to generate XHTML that the
contents of the <alt> tags are ignored, but the contents of the
<phrase></phrase> is not so if the Docbook XML file generated by a2x
produces:

<equation>
    <title>First equation</title>
    <alt><![CDATA[\[C = \alpha + \beta Y^{\gamma} + \epsilon\]]]></
alt>
    <mediaobject>
        <textobject>
            <phrase><![CDATA[\[C = \alpha + \beta Y^{\gamma} + \epsilon
\]]]></phrase>
        </textobject>
    </mediaobject>
</equation>

for example, then this file can be used to generate either PDF or
(X)HTML with the LaTeX math expressions rendered as intended in each
case without any unwanted side effects such as duplication in the
rendering. To do this the docbook45.conf file has to be modified as:

[macros]
# math macros.
(?su)[\\]?(?P<name>latexmath):(?P<subslist>\S*?)\[(?P<passtext>.*?)(?<!
\\)\]=[]
(?u)^(?P<name>latexmath)::(?P<subslist>\S*?)(\[(?P<passtext>.*?)\])
$=#[]

[latexmath-inlinemacro]
<inlineequation>
<alt><![CDATA[{passtext}]]></alt>
<inlinemediaobject><textobject><phrase><![CDATA[{passtext}]]></
phrase></textobject></inlinemediaobject>
</inlineequation>

[latexmath-blockmacro]
<informalequation>
<alt><![CDATA[{passtext}]]></alt>
<mediaobject><textobject><phrase><![CDATA[{passtext}]]></phrase></
textobject></mediaobject>
</informalequation>

and this will work for these macros without conflict. This is a result
of the way dblatex handles LaTeX expressions using the <alt> element.

However, there is one fly in the ointment here. Due to my ignorance
about how these block passthroughs work I am not able to figure out
how to extend this idea to:

[latexmathblock]
<equation{id? id="{id}"}{role? role="{role}"}{reftext?
xreflabel="{reftext}"}><title>{title}</title>
{title%}<informalequation{id? id="{id}"}{role? role="{role}"}{reftext?
xreflabel="{reftext}"}>
<alt><![CDATA[|]]></alt>
<mediaobject><textobject><phrase></phrase></textobject></mediaobject>
{title#}</equation>
{title%}</informalequation>

Merely sticking <![CDATA[|]]> in as content as in <phrase><!
[CDATA[|]]></phrase> here doesn't do it (it renders "<![CDATA[|]]>"
verbatim, and using <phrase><![CDATA[{passtext}]]></phrase> in there
results in a bunch of exceptions and the a2x process fails with
errors.

So if you have some idea how to make this work for this passthrough
block in the same way as I was able to do for the macros, then I think
there may be a solution at hand. Of course, there still is the issue
of getting the required reference to the LaTeX math Javascripts (e.g.,
MathJax or LaTeXMathML) in the <head> section of the (X)HTML document,
which I presume will require some tweaking of the the XSLT process
when (X)HTML is being generated. This may require an a2x option to
indicate that "LaTeX math" is involved so that the proper reference to
the LaTeX math Javascripts can be included as contents of a <script>
tag in the <head> section of the generated (X)HTML. Example: a2x --
latexmathml -f xhtml mylatexmath.txt or a2x --mathjax -f xhtml
mylatexmath.txt These two options being only meaningful for (X)HTML
formats.

With that in hand I think this may be a somewhat simple solution to
the goal Bruce is after. I am sure this would be useful to others as
well.

Thanks. This is a little lengthy. Sorry.


David





On Jun 15, 7:53 pm, Lex Trotman <[email protected]> wrote:
> > I am not on solid ground with XSLT but it seems to me that the XSL
> > stylesheet being used could be modified to tag the CDATA  LaTeX code
> > usefully for XHTML use instead of merely deleting it from the output.
> > I am also not sure that the required <script> reference to the
> > LatexMathML or MathJax Javascripts could be accommodated in some
> > manner by this process or not. The verbatim Javascript code for
> > LatexMathML does not have to  be part of the document. It can be
> > referenced as a resource by URL ina <script> element. But at a minimum
> > if the LaTeX code can be preserved and tagged usefully during the
> > transformation process, the the same Asciidoc text file could be used
> > to generate XHTML and PDF using a2x with the LaTeX code preserved in
> > both cases. The worst thing that could happen in this case is that
> > without the <script> reference manually added for LatexMathML or
> > MathJax Javascripts, the LaTeX code would render as plain text, which
> > would be a clue that something more has to be done.
>
> Hi again David,
>
> I'm sure Stuart would add a custom xsl stylesheet that does this to
> the distribution if it was available.
>
> Note that asciidoc uses standard docbook-xsl stylesheets unmodified
> since they are shared with other applications.  But you could make a
> customisation layer see:http://www.sagehill.net/docbookxsl/CustomMethods.html.
>
> For math you probably want to look at 
> this:http://www.sagehill.net/docbookxsl/Math.html
>
> Cheers
> Lex

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

Reply via email to