ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* handling code in XML
@ 2017-07-23 19:28 Pablo Rodriguez
  2017-07-24  8:48 ` Hans Hagen
  2017-07-24  8:54 ` Hans Hagen
  0 siblings, 2 replies; 13+ messages in thread
From: Pablo Rodriguez @ 2017-07-23 19:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
&quot;&lt;&amp;&gt;&quot;}
            </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?

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2017-07-23 19:28 handling code in XML Pablo Rodriguez
@ 2017-07-24  8:48 ` Hans Hagen
  2017-07-24 19:34   ` Pablo Rodriguez
  2017-07-24  8:54 ` Hans Hagen
  1 sibling, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2017-07-24  8:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Pablo Rodriguez

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
> &quot;&lt;&amp;&gt;&quot;}
>              </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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2017-07-23 19:28 handling code in XML Pablo Rodriguez
  2017-07-24  8:48 ` Hans Hagen
@ 2017-07-24  8:54 ` Hans Hagen
  1 sibling, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2017-07-24  8:54 UTC (permalink / raw)
  To: ntg-context

On 7/23/2017 9:28 PM, Pablo Rodriguez wrote:
>          \xmlsetsetup{#1}{doc|source|div|span}{xml:*}
also use #1 here:
>          \xmlsetsetup{\xmldocument}
 >          \xmlsetsetup{#1}

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2017-07-24  8:48 ` Hans Hagen
@ 2017-07-24 19:34   ` Pablo Rodriguez
  0 siblings, 0 replies; 13+ messages in thread
From: Pablo Rodriguez @ 2017-07-24 19:34 UTC (permalink / raw)
  To: ntg-context

On 07/24/2017 10:48 AM, Hans Hagen wrote:
> On 7/23/2017 9:28 PM, Pablo Rodriguez wrote:
>> [...]
>> 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) [...]

Many thanks for your reply and the new \xmlprettyprinttext, Hans.

Yesterday, I totally forgot about inline code, such as in the sample below.

Which would be the \xmlprettyprinttext command for inline code?

\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

\startbuffer[demo]
<doc>
<div>
<source>\command[option=value]{text &quot;&lt;&amp;}</source>
</div>

<p>This is inline code <code class="sourceCode latex"><span
class="fu">\command</span>[option=value]{text &quot;&lt;&amp;}</code>.</p>
</doc>
\stopbuffer

\startxmlsetups xml:initialize
    \xmlsetsetup{#1}{doc|source|div}{xml:*}
    \xmlsetsetup{#1}
        {code[contains(@class,'latex')]}
        {xml: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:code
    \xmlprettyprinttext{#1}{tex}
\stopxmlsetups

\starttext
    \xmlprocessbuffer{main}{demo}{}
\stoptext

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-24 14:41         ` Hans Hagen
@ 2015-02-24 16:31           ` Pablo Rodriguez
  0 siblings, 0 replies; 13+ messages in thread
From: Pablo Rodriguez @ 2015-02-24 16:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-23 19:29       ` Pablo Rodriguez
  2015-02-24 14:07         ` Hans Hagen
  2015-02-24 14:17         ` Hans Hagen
@ 2015-02-24 14:41         ` Hans Hagen
  2015-02-24 16:31           ` Pablo Rodriguez
  2 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2015-02-24 14:41 UTC (permalink / raw)
  To: ntg-context

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-23 19:29       ` Pablo Rodriguez
  2015-02-24 14:07         ` Hans Hagen
@ 2015-02-24 14:17         ` Hans Hagen
  2015-02-24 14:41         ` Hans Hagen
  2 siblings, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2015-02-24 14:17 UTC (permalink / raw)
  To: ntg-context

\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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-23 19:29       ` Pablo Rodriguez
@ 2015-02-24 14:07         ` Hans Hagen
  2015-02-24 14:17         ` Hans Hagen
  2015-02-24 14:41         ` Hans Hagen
  2 siblings, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2015-02-24 14:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-23 18:34     ` Hans Hagen
@ 2015-02-23 19:29       ` Pablo Rodriguez
  2015-02-24 14:07         ` Hans Hagen
                           ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Pablo Rodriguez @ 2015-02-23 19:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-23 18:25   ` Pablo Rodriguez
@ 2015-02-23 18:34     ` Hans Hagen
  2015-02-23 19:29       ` Pablo Rodriguez
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2015-02-23 18:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-23 14:56 ` Hans Hagen
@ 2015-02-23 18:25   ` Pablo Rodriguez
  2015-02-23 18:34     ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Pablo Rodriguez @ 2015-02-23 18:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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 &gt; b    &amp; 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: handling code in XML
  2015-02-22 17:37 Pablo Rodriguez
@ 2015-02-23 14:56 ` Hans Hagen
  2015-02-23 18:25   ` Pablo Rodriguez
  0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2015-02-23 14:56 UTC (permalink / raw)
  To: ntg-context

On 2/22/2015 6:37 PM, Pablo Rodriguez wrote:
> Dear list,
>
> I have the following sample:
>
>      \startbuffer[demo]
>      <doc>
>           <p><code>&lt;div&gt;foo&lt;/div&gt;</code></p>
>      <pre><code>for a &gt; b
>      &amp; 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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* handling code in XML
@ 2015-02-22 17:37 Pablo Rodriguez
  2015-02-23 14:56 ` Hans Hagen
  0 siblings, 1 reply; 13+ messages in thread
From: Pablo Rodriguez @ 2015-02-22 17:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,

I have the following sample:

    \startbuffer[demo]
    <doc>
         <p><code>&lt;div&gt;foo&lt;/div&gt;</code></p>
    <pre><code>for a &gt; b
    &amp; 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-07-24 19:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-23 19:28 handling code in XML Pablo Rodriguez
2017-07-24  8:48 ` Hans Hagen
2017-07-24 19:34   ` Pablo Rodriguez
2017-07-24  8:54 ` Hans Hagen
  -- strict thread matches above, loose matches on Subject: below --
2015-02-22 17:37 Pablo Rodriguez
2015-02-23 14:56 ` Hans Hagen
2015-02-23 18:25   ` Pablo Rodriguez
2015-02-23 18:34     ` Hans Hagen
2015-02-23 19:29       ` Pablo Rodriguez
2015-02-24 14:07         ` Hans Hagen
2015-02-24 14:17         ` Hans Hagen
2015-02-24 14:41         ` Hans Hagen
2015-02-24 16:31           ` Pablo Rodriguez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).