Dear list, I have the following sample: \startbuffer[demo] <doc> <p><code><div>foo</div></code></p> <pre><code>for a > b & c</code></pre> </doc> \stopbuffer \starttext \startxmlsetups xml:initialize \xmlsetsetup{#1}{p|doc|code}{xml:*} \xmlsetsetup{#1}{pre/code}{xml:pre} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups \startxmlsetups xml:code \begingroup\tt\xmlflush{#1}\endgroup\par \xmlinlineverbatim{#1} \stopxmlsetups \startxmlsetups xml:pre \xmlverbatim{#1} \stopxmlsetups \xmlprocessbuffer{main}{demo}{} \stoptext And I experience two issues: Is there a way to handle <code> (or <pre>) as verbatim, but translating the five entities that need to be escaped in XML? Which is the right way to link a <pre> or <code> to a type or typing command? Many thanks for your help, Pablo -- http://www.ousia.tk
On 2/22/2015 6:37 PM, Pablo Rodriguez wrote:
Dear list,
I have the following sample:
\startbuffer[demo] <doc> <p><code><div>foo</div></code></p> <pre><code>for a > b & c</code></pre> </doc> \stopbuffer
\starttext
\startxmlsetups xml:initialize \xmlsetsetup{#1}{p|doc|code}{xml:*} \xmlsetsetup{#1}{pre/code}{xml:pre} \stopxmlsetups
\xmlregistersetup{xml:initialize}
\startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:p \xmlflush{#1}\par \stopxmlsetups
\startxmlsetups xml:code \begingroup\tt\xmlflush{#1}\endgroup\par
\xmlinlineverbatim{#1} \stopxmlsetups
\startxmlsetups xml:pre \xmlverbatim{#1} \stopxmlsetups
\xmlprocessbuffer{main}{demo}{}
\stoptext
And I experience two issues:
Is there a way to handle <code> (or <pre>) as verbatim, but translating the five entities that need to be escaped in XML?
Which is the right way to link a <pre> or <code> to a type or typing command? \startxmlsetups xml:code \begingroup \tt \xmlflushspacewise{#1} \endgroup \stopxmlsetups
\startxmlsetups xml:pre \begingroup \tt \xmlflushspacewise{#1} \endgroup \stopxmlsetups -- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 02/23/2015 03:56 PM, Hans Hagen wrote:
On 2/22/2015 6:37 PM, Pablo Rodriguez wrote:
[...] Is there a way to handle <code> (or <pre>) as verbatim, but translating the five entities that need to be escaped in XML?
Which is the right way to link a <pre> or <code> to a type or typing command? [...] \startxmlsetups xml:pre \begingroup \tt \xmlflushspacewise{#1} \endgroup \stopxmlsetups
Many thanks for your reply, Hans. Your code works fine, but I forgot to mention another issue. Here is another sample: \startbuffer[demo] <doc> <pre><code>for a > b & c</code></pre> <pre class="tex"><code>\ConTeXt\ rocks!</code></pre> </doc> \stopbuffer \starttext \startxmlsetups xml:initialize \xmlsetsetup{#1}{doc}{xml:*} \xmlsetsetup{#1}{pre/code}{xml:pre} \xmlsetsetup{#1}{pre[@class='tex']/code}{xml:texcode} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:pre \begingroup \tt \xmlflushspacewise{#1} \endgroup\par \stopxmlsetups \startxmlsetups xml:texcode \startΤΕΧ \xmlflushspacewise{#1} \stopTEX \stopxmlsetups \xmlprocessbuffer{main}{demo}{} \stoptext And two questions: Is there no way to get xml:texcode with a TEX typing? Isn’t \xmlflushspacewise supposed to respect blank spaces? (Sorry, but I don’t see any differences with \xmlflushlinewise.) Many thanks for your help again, Pablo -- http://www.ousia.tk
On 2/23/2015 7:25 PM, Pablo Rodriguez wrote:
Is there no way to get xml:texcode with a TEX typing?
\xmlcontext{#1}{....}
Isn’t \xmlflushspacewise supposed to respect blank spaces? (Sorry, but I don’t see any differences with \xmlflushlinewise.)
subtle differences (i have no time now to look them up) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 02/23/2015 07:34 PM, Hans Hagen wrote:
On 2/23/2015 7:25 PM, Pablo Rodriguez wrote:
Is there no way to get xml:texcode with a TEX typing?
\xmlcontext{#1}{....}
Sorry, Hans, I’m afraid that I don’t get it. I have been searching the wiki and mailing list, the code (using grep) after I got your reply. The solution may be there, but I haven’t been able to find it. \xmlcontext{#1}{.} compiles in ConTeXt the contents of (in this case): <pre class="tex"><code>\ConTeXt\ rocks!</code></pre> It would be the same as compiling in pure ConTeXt: \starttext \ConTeXt\ rocks! \stoptext And what I need (and haven’t been able to explain) is in pure ConTeXt: \startTEX \ConTeXt\ rocks! \stopTEX If this can be achieved with \xmlcontext{#1}{#2}, I cannot find which values #2 take (I have no idea of what is expected there). Many thanks for your help, Pablo -- http://www.ousia.tk
On 2/23/2015 8:29 PM, Pablo Rodriguez wrote:
On 02/23/2015 07:34 PM, Hans Hagen wrote:
On 2/23/2015 7:25 PM, Pablo Rodriguez wrote:
Is there no way to get xml:texcode with a TEX typing?
\xmlcontext{#1}{....}
Sorry, Hans, I’m afraid that I don’t get it.
I have been searching the wiki and mailing list, the code (using grep) after I got your reply. The solution may be there, but I haven’t been able to find it.
\xmlcontext{#1}{.}
compiles in ConTeXt the contents of (in this case):
<pre class="tex"><code>\ConTeXt\ rocks!</code></pre>
It would be the same as compiling in pure ConTeXt:
\starttext \ConTeXt\ rocks! \stoptext
And what I need (and haven’t been able to explain) is in pure ConTeXt:
\startTEX \ConTeXt\ rocks! \stopTEX
If this can be achieved with \xmlcontext{#1}{#2}, I cannot find which values #2 take (I have no idea of what is expected there).
Many thanks for your help,
\usemodule[scite] \starttexdefinition xmlsaveinbuffer #1 \ctxlua{buffers.assign("foo",xml.content(lxml.id('#1')))} \stoptexdefinition \starttexdefinition xmlprettyprint #1#2 \xmlsaveinbuffer{#1} \typebuffer[foo][option=#2] \stoptexdefinition \starttexdefinition xmlprettyprint #1#2 \start \tt \xmlsaveinbuffer{#1} \setcatcodetable\ctxcatcodes \scitebuffer[foo][#2] \stop \stoptexdefinition \startxmlsetups xml:code \xmlprettyprint{#1}{tex} \stopxmlsetups \startxmlsetups xml:pre \xmlprettyprint{#1}{tex} \stopxmlsetups ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
\startbuffer[demo] <doc> <pre> \def\whatever#1{[whatever #1]} \ctxlua{print("okay")} </pre> </doc> \stopbuffer \usemodule[scite] \startxmlsetups xml:initialize \xmlsetsetup{#1}{doc|pre}{xml:*} \stopxmlsetups \xmlregistersetup{xml:initialize} \starttexdefinition xmlsaveinbuffer #1 \ctxlua{buffers.assign("foo",xml.content(lxml.id('#1')))} \stoptexdefinition \starttexdefinition xmlprettyprint #1#2 \xmlsaveinbuffer{#1} \typebuffer[foo][option=#2] \stoptexdefinition \starttexdefinition xmlprettyprint #1#2 \start \tt \xmlsaveinbuffer{#1} \setcatcodetable\ctxcatcodes \scitebuffer[#2][foo] \stop \stoptexdefinition \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:pre \xmlprettyprint{#1}{tex} \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
In a next upload you can do: \startbuffer[demo] <doc> <pre> \def\whatever#1{[whatever #1]} \ctxlua{print("okay")} </pre> </doc> \stopbuffer \usemodule[scite] % optional \startxmlsetups xml:initialize \xmlsetsetup{#1}{doc|pre}{xml:*} \stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:pre \xmlprettyprint{#1}{tex} \stopxmlsetups \starttext \xmlprocessbuffer{main}{demo}{} \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 02/24/2015 03:41 PM, Hans Hagen wrote:
In a next upload you can do: [...] \startxmlsetups xml:pre \xmlprettyprint{#1}{tex} \stopxmlsetups
Hans, many thanks for your replies and the new feature. Pablo -- http://www.ousia.tk
participants (2)
-
Hans Hagen
-
Pablo Rodriguez