ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* dealing with the lang attribute in XML
@ 2015-01-06 21:12 Pablo Rodriguez
  2015-01-06 23:17 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez @ 2015-01-06 21:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,

I’m trying to write an environment to typeset HTML generated by pandoc
with ConTeXt MkIV.

One of the issues I’m experiencing is dealing with the lang attribute.

The required sample:

\startbuffer[demo]
<doc lang="en">

  <p>This is an English paragraph.</p>

  <p lang="de">Aber dieser Absatz ist auf Deutsch und enthält Spanisch
  (<span lang="es-ES">prueba</span>).</p>

</doc>
\stopbuffer

\starttext
\hsize\zeropoint

\startxmlsetups xml:initialize
     \xmlsetsetup{#1}{p|doc|span}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

\startxmlsetups xml:doc
    \mainlanguage[\xmlatt{#1}{lang}]
    \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:p
     \begingroup\language[\xmlatt{#1}{lang}]\xmlflush{#1}\endgroup\par
\stopxmlsetups

\startxmlsetups xml:span
     \begingroup\language[\xmlatt{#1}{lang}]\xmlflush{#1}\endgroup
\stopxmlsetups

\xmlprocessbuffer{main}{demo}{}

\stoptext

The question is how to deal with the lang attribute in a single
xmlsetup (at least for p and span [not all those elements might have a
lang attribute, they can inherit it]).

And a second question would be: how can I deal with language values in
XML and ConTeXt? A \processaction 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] 5+ messages in thread

* Re: dealing with the lang attribute in XML
  2015-01-06 21:12 dealing with the lang attribute in XML Pablo Rodriguez
@ 2015-01-06 23:17 ` Hans Hagen
  2015-01-07  8:30   ` Pablo Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2015-01-06 23:17 UTC (permalink / raw)
  To: ntg-context

On 1/6/2015 10:12 PM, Pablo Rodriguez wrote:
> Dear list,
>
> I’m trying to write an environment to typeset HTML generated by pandoc
> with ConTeXt MkIV.
>
> One of the issues I’m experiencing is dealing with the lang attribute.
>
> The required sample:
>
> \startbuffer[demo]
> <doc lang="en">
>
>    <p>This is an English paragraph.</p>
>
>    <p lang="de">Aber dieser Absatz ist auf Deutsch und enthält Spanisch
>    (<span lang="es-ES">prueba</span>).</p>
>
> </doc>
> \stopbuffer
>
> \starttext
> \hsize\zeropoint
>
> \startxmlsetups xml:initialize
>       \xmlsetsetup{#1}{p|doc|span}{xml:*}
> \stopxmlsetups
>
> \xmlregistersetup{xml:initialize}
>
> \startxmlsetups xml:doc
>      \mainlanguage[\xmlatt{#1}{lang}]
>      \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:p
>       \begingroup\language[\xmlatt{#1}{lang}]\xmlflush{#1}\endgroup\par
> \stopxmlsetups
>
> \startxmlsetups xml:span
>       \begingroup\language[\xmlatt{#1}{lang}]\xmlflush{#1}\endgroup
> \stopxmlsetups
>
> \xmlprocessbuffer{main}{demo}{}
>
> \stoptext
>
> The question is how to deal with the lang attribute in a single
> xmlsetup (at least for p and span [not all those elements might have a
> lang attribute, they can inherit it]).
>
> And a second question would be: how can I deal with language values in
> XML and ConTeXt? A \processaction command?

there is \xmlval cum suis for mapping attributes but in this case you 
can just use \language and define language synomyms if needed

> Many thanks for your help,

\startxmlsetups xml:initialize
      \xmlsetsetup{#1}{*}{xml:*}
      \xmlsetsetup{#1}{(p|span)[@lang]}{xml:lang}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

\startxmlsetups xml:lang
     \begingroup
         \language[\xmlatt{#1}{lang}]
         \xmlsetup{#1}{xml:\xmltag{#1}}
     \endgroup
\stopxmlsetups

\startxmlsetups xml:doc
     \mainlanguage[\xmlatt{#1}{lang}]
     \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:p
      \xmlflush{#1}
      \par
\stopxmlsetups

\startxmlsetups xml:span
      \xmlflush{#1}
\stopxmlsetups

Here is a solution that can save you some time:

\usemodule[html]

\startxmlsetups xml:initialize
     \xmlsetup{#1}{xml:html:basics}
     \xmlsetup{#1}{xml:html:tables}
     \xmlsetsetup{#1}{(p|span)[@lang]}{xml:lang}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

\startxmlsetups xml:lang
     \begingroup
         \language[\xmlatt{#1}{lang}]
         \xmlsetup{#1}{xml:html:\xmltag{#1}}
     \endgroup
\stopxmlsetups

(some reasonable defaults)

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] 5+ messages in thread

* Re: dealing with the lang attribute in XML
  2015-01-06 23:17 ` Hans Hagen
@ 2015-01-07  8:30   ` Pablo Rodriguez
  2015-01-07 10:05     ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez @ 2015-01-07  8:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 01/07/2015 12:17 AM, Hans Hagen wrote:
>> [...]
>> And a second question would be: how can I deal with language values in
>> XML and ConTeXt? A \processaction command?
> 
> there is \xmlval cum suis for mapping attributes but in this case you 
> can just use \language and define language synomyms if needed

Many thanks for your reply, Hans.

Which is the right way to to define language synonyms?

(I cannot make \setlanguagesynonym work. This is what I found searching
in the wiki.)

> Here is a solution that can save you some time:
> 
> \usemodule[html]

Well, it seems that I was trying to reinvent the wheel.

Where can I find the module and its documentation? (I haven’t found
anything searching for html in the filename.)

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] 5+ messages in thread

* Re: dealing with the lang attribute in XML
  2015-01-07  8:30   ` Pablo Rodriguez
@ 2015-01-07 10:05     ` Hans Hagen
  2015-01-09  9:14       ` Pablo Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2015-01-07 10:05 UTC (permalink / raw)
  To: ntg-context

On 1/7/2015 9:30 AM, Pablo Rodriguez wrote:
> On 01/07/2015 12:17 AM, Hans Hagen wrote:
>>> [...]
>>> And a second question would be: how can I deal with language values in
>>> XML and ConTeXt? A \processaction command?
>>
>> there is \xmlval cum suis for mapping attributes but in this case you
>> can just use \language and define language synomyms if needed
>
> Many thanks for your reply, Hans.
>
> Which is the right way to to define language synonyms?

\installanguage[foo][nl]

> (I cannot make \setlanguagesynonym work. This is what I found searching
> in the wiki.)
>
>> Here is a solution that can save you some time:
>>
>> \usemodule[html]
>
> Well, it seems that I was trying to reinvent the wheel.
>
> Where can I find the module and its documentation? (I haven’t found
> anything searching for html in the filename.)

hm, i forgot to rename the file in the zip maker script .. will be in 
next beta

> Many thanks for your help,

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] 5+ messages in thread

* Re: dealing with the lang attribute in XML
  2015-01-07 10:05     ` Hans Hagen
@ 2015-01-09  9:14       ` Pablo Rodriguez
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez @ 2015-01-09  9:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 01/07/2015 11:05 AM, Hans Hagen wrote:
> On 1/7/2015 9:30 AM, Pablo Rodriguez wrote:
>> [...]
>> Which is the right way to to define language synonyms?
> 
> \installanguage[foo][nl]

Many thanks for your reply and the fixes, Hans.


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] 5+ messages in thread

end of thread, other threads:[~2015-01-09  9:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06 21:12 dealing with the lang attribute in XML Pablo Rodriguez
2015-01-06 23:17 ` Hans Hagen
2015-01-07  8:30   ` Pablo Rodriguez
2015-01-07 10:05     ` Hans Hagen
2015-01-09  9:14       ` 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).