On 7/23/2017 9:28 PM, Pablo Rodriguez wrote:
Hans,
I have the following sample:
\startbuffer[demo] <doc> <div> <source>\command[option=value]{text "<&>"}</source> </div>
<div class="sourceCode"> <pre class="sourceCode tex"> <code class="sourceCode latex"> <span class="fu">\command</span>[option=value]{text "<&>"} </code> </pre> </div> </doc> \stopbuffer
\startxmlsetups xml:initialize \xmlsetsetup{#1}{doc|source|div|span}{xml:*} \xmlsetsetup{\xmldocument} {pre[contains(@class,'sourceCode')]/ code[contains(@class,'sourceCode')]} {xml:pre:code} \stopxmlsetups
\xmlregistersetup{xml:initialize}
\startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:div \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:source \xmlprettyprint{#1}{tex} \stopxmlsetups
\startxmlsetups xml:pre:code \xmlflushspacewise{#1} \stopxmlsetups
\startxmlsetups xml:span \bgroup\xmlflush{#1}\egroup \stopxmlsetups
The .sourceCode elements are the standard way in which pandoc serves colored code. I have to deal with them.
In the sample above, for xml:pre:code, I would need and expanded \xmlprettyprint that also ignores tags inside (anything between < and >, but not the entities).
Which is the way to get this expanded \xmlprettyprint? The xml that we see is getting more weird every day .. anyway
\startluacode function lxml.tobufferX(id,pattern,name) local collected = xml.applylpath(lxml.getid(id),pattern) if collected then local t = { } xml.string(collected[1],function(s) t[#t+1] = s end) buffers.assign(name,table.concat(t)) else buffers.erase(name) end end \stopluacode \unprotect \unexpanded\def\xmlprettyprinttext#1#2% {\ctxlua{lxml.tobufferX("#1",".","xml-temp")}% \ifdefined\scitebuffer \scitebuffer[#2][xml-temp]% \else \typebuffer[xml-temp][\c!option=#2]% \fi} \protect I'll add \xmlprettyprinttext to the core (somewhat different implementation) so that you can do \startxmlsetups xml:source \xmlprettyprinttext{#1}{tex} \stopxmlsetups \startxmlsetups xml:pre:code \xmlprettyprinttext{#1}{tex} \stopxmlsetups ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------