Re: [NTG-context] xml nbsp?

2023-06-13 Thread Bruce Horrocks via ntg-context
 is not a pre-defined named character in XML (but it is in HTML which 
lulls you into a false sense of security).

See the link below for some more detail and a fix.



> On 13 Jun 2023, at 11:01, Hans van der Meer via ntg-context 
>  wrote:
> 
> What happened to the non breaking space in XML? It has disappeared in a way. 
> See the minimal example attached.
> 
> dr. Hans van der Meer
> 


test-nbsp.pdf
Description: Adobe PDF document
> 

—
Bruce Horrocks
Hampshire, UK

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-21 Thread Thomas A. Schmitz via ntg-context

On 11/20/22 19:19, Thomas A. Schmitz via ntg-context wrote:
I load data from an external xml file (not the one I'm processing) and 
store some of it in a lua table.


local examples = lxml.load ("my_examples", "examples.xml")


Replying to myself, and sorry for the noise (this was fairly easy, 
should have seen it earlier):


instead of loading the file "examples.xml," I simply include it via 
xmlinclude into the tree; this way the proper setups are applied.


All best

Thomas
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-20 Thread Thomas A. Schmitz via ntg-context

On 11/17/22 11:04, Hans Hagen via ntg-context wrote:


so, basically you collect data and use it later ... for huge datasets 
that saves some time


if you have only chapters to process you can even decide to flush in 
that function


Alright, I'm making very good progress here, but right now I'm stumbling 
upon a problem I can't solve. It's difficult to make a minimal example, 
so bear with some snippets.


I load data from an external xml file (not the one I'm processing) and 
store some of it in a lua table.


local examples = lxml.load ("my_examples", "examples.xml")
local sets = lxml.load ("my_sets", "example_sets.xml")

for e in xml.collected (examples, "/examples/chapter/example") do
local ex_id = e.at.id
all_examples [ex_id] = e
end

This works as expected, with print (inspect (all_examples)), I can see 
that the table looks the way I expect.


I then retrieve some entries of the table by their key:

local current_example = all_examples [key]

Again, this appears to work; when I have a

lxml.displayverbatim (current_example)

in my file, the xml is typeset and looks like I would expect it to look. 
However, whatever I try, I get the serialized xml typeset, with all 
 verbatim, instead of processed. Here's what I've tried:


\startxmlsetups xml:chapter:example
\xmlfirst {#1} {.} \par
\stopxmlsetups

lxml.command (current_example, ".", "xml:chapter:example")

or

xml.sprint (lxml.id (current_example))

or

local problem = xml.text (lxml.id (current_example), "./[text()]")
xml.sprint (problem)

I was expecting at least the last version to retrieve the pure text, but 
it typesets again with the tags included.


So I guess my question is: how can I tell ConTeXt to parse my xml as xml 
and apply the proper setups instead of serializing it?


All best wishes

Thomas
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-17 Thread Thomas A. Schmitz via ntg-context

> On 17. Nov 2022, at 11:04, Hans Hagen via ntg-context  
> wrote:
> 
> so, basically you collect data and use it later ... for huge datasets that 
> saves some time
> 
> if you have only chapters to process you can even decide to flush in that 
> function
> 
> Hans

I think this is exactly the approach I’m looking for: collecting everything in 
Lua tables and then retrieving and typesetting it later. I’m experimenting with 
it right now. I will have to define a proper lxml.command for every xml tag, I 
guess; otherwise, the xml gets serialized? I’ll play some more and will 
certainly be back with questions :-)

Thank you, as always, and all best

Thomas
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-17 Thread Hans Hagen via ntg-context

On 11/16/2022 8:56 PM, mf via ntg-context wrote:

This works:

local metadata = xml.filter (t, '../../topics/topic[@t:id=="' .. ch_id 
.. '"]')


also this:

local lpath = string.format('../../topics/topic[@t:id=="%s"]', ch_id)

local metadata = xml.filter (t, lpath)


It looks like xml.filter supports only 2 arguments (see lxml-tex.lua), 
and so it doesn't let you use string formatting patterns like the 
"context" command does.


You can write:

context('the value of @t:id is "%s"', ch_id)

but you can't write:

xml.filter (t, '../../topics/topic[@t:id=="%s"]', ch_id)

In Thomas example this is also an approach:

\startxmlsetups xml:document
\xmlfunction{#1} {document}
\xmlflush{#1}
\stopxmlsetups

with

\startluacode
local topics   = { }
local chapters = { }

function xml.functions.document(t)
for c in xml.collected(t,"/topics/topic") do
topics[c.at.t_id] = c
end
 -- for c in xml.collected(t,"/chapters/chapter") do
 -- chapters[c.at.ch_id] = c
 -- -- or flush here
 -- end
end

function xml.functions.chapter (t)
local ch_id = t.at.ch_id
local metadata = topics[ch_id]
lxml.command(t, ".", "xml:chapter:content")
context.par ()
context (ch_id)
context.par ()
end
\stopluacode

so, basically you collect data and use it later ... for huge datasets 
that saves some time


if you have only chapters to process you can even decide to flush in 
that function


Hans

-
  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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread Hans Hagen via ntg-context

On 11/16/2022 10:09 PM, Thomas A. Schmitz via ntg-context wrote:

On 11/16/22 21:51, Denis Maier via ntg-context wrote:

Just a quick question regarding this?
Is xml.filter equivalent to \xmlfilter? If so, how do you pass the 
match to a command as you'd do with \xmlfilter?


I'm still digesting and playing with Massi's reply; will probably be 
back with more questions :-)


Anyway:

If you've filtered something out like this

local tree = xml.filter (t, "../chapter[@title='mytitle'")


always keep in mind that some expressions return a list of matches, that 
can be looped over and some commands just process the first


anyway, it can sometimes help to add

print(tstring(tree))

so see what you got

Hans

-
  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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread Thomas A. Schmitz via ntg-context

On 11/16/22 21:51, Denis Maier via ntg-context wrote:

Just a quick question regarding this?
Is xml.filter equivalent to \xmlfilter? If so, how do you pass the match to a 
command as you'd do with \xmlfilter?


I'm still digesting and playing with Massi's reply; will probably be 
back with more questions :-)


Anyway:

If you've filtered something out like this

local tree = xml.filter (t, "../chapter[@title='mytitle'")

you can then apply a command to it

lxml.command(lxml.id(tree), ".", "xml:chapter:command")

and have to define the command as

\startxmlsetups xml:chapter:command
\xmltext {#1} {content}
\stopxmlsetups

for example.

Thomas

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread Denis Maier via ntg-context
Just a quick question regarding this?
Is xml.filter equivalent to \xmlfilter? If so, how do you pass the match to a 
command as you'd do with \xmlfilter?

Best,
Denis

> -Ursprüngliche Nachricht-
> Von: ntg-context  Im Auftrag von mf via ntg-
> context
> Gesendet: Mittwoch, 16. November 2022 20:56
> An: ntg-context@ntg.nl
> Cc: mf 
> Betreff: Re: [NTG-context] Xml filtering in Lua
> 
> This works:
> 
> local metadata = xml.filter (t, '../../topics/topic[@t:id=="' .. ch_id .. 
> '"]')
> 
> also this:
> 
> local lpath = string.format('../../topics/topic[@t:id=="%s"]', ch_id)
> 
> local metadata = xml.filter (t, lpath)
> 
> 
> It looks like xml.filter supports only 2 arguments (see lxml-tex.lua), and so 
> it
> doesn't let you use string formatting patterns like the "context" command
> does.
> 
> You can write:
> 
> context('the value of @t:id is "%s"', ch_id)
> 
> but you can't write:
> 
> xml.filter (t, '../../topics/topic[@t:id=="%s"]', ch_id)
> 
> 
> Best wishes,
> 
> Massi
> 
> __
> _
> If your question is of interest to others as well, please add an entry to the
> Wiki!
> 
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-
> context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net archive
> : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> __
> _

> -Ursprüngliche Nachricht-----
> Von: ntg-context  Im Auftrag von Thomas A.
> Schmitz via ntg-context
> Gesendet: Mittwoch, 16. November 2022 20:56
> An: mailing list for ConTeXt users 
> Cc: Thomas A. Schmitz 
> Betreff: Re: [NTG-context] Xml filtering in Lua
> 
> On 11/16/22 19:56, mf via ntg-context wrote:
> > local ch_id = t.at["ch:id"]
> 
> You're right, of course, using a colon was a stupid idea. When I replace it 
> with
> an underscore, you can see that both are in fact identical:
> 
> \startbuffer[test]
> 
>
>   
>   This is the first test
>   22/11/16
>   
>   
>   This is the second test
>   22/11/17
>   
>
>
>   
>   
> This will be the content of the first chapter.
>   
>   
>   
>
> This will be the content of the second chapter.
>
>   
>
> 
> \stopbuffer
> 
> \startxmlsetups xml:testsetups
> \xmlsetsetup{#1}{*}{-}
>   \xmlsetsetup{#1}{document|chapters|chapter|content|emph}{xml:
> *}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:testsetups}
> 
> \startxmlsetups xml:document
>   \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:chapters
>   \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:chapter
>   \xmlfunction {#1} {chapter}
> %  \xmlflush {#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:chapter:content
>   \xmltext {#1} {content}
> \stopxmlsetups
> 
> \startxmlsetups xml:emph
>{\em \xmlflush {#1}}
> \stopxmlsetups
> 
> \startluacode
> function xml.functions.chapter (t)
>local chapter_id = t.at.ch_id
>local other_chapter_id = t.at["ch_id"]
>context (chapter_id)
>context.par ()
>context (other_chapter_id)
>context.par ()
>   local metadata = xml.filter (t, 
> '../../topics/topic[@t:id=="%s"]',
> ch_id)
>   print (inspect(metadata))
>   lxml.command(t, ".", "xml:chapter:content")
>   context.par ()
> end
> \stopluacode
> 
> \starttext
>   \xmlprocessbuffer{main}{test}{}
> \stoptext
> 
> __
> _
> If your question is of interest to others as well, please add an entry to the
> Wiki!
> 
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-
> context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net archive
> : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
> __
> _
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread mf via ntg-context

This works:

local metadata = xml.filter (t, '../../topics/topic[@t:id=="' .. ch_id 
.. '"]')


also this:

local lpath = string.format('../../topics/topic[@t:id=="%s"]', ch_id)

local metadata = xml.filter (t, lpath)


It looks like xml.filter supports only 2 arguments (see lxml-tex.lua), 
and so it doesn't let you use string formatting patterns like the 
"context" command does.


You can write:

context('the value of @t:id is "%s"', ch_id)

but you can't write:

xml.filter (t, '../../topics/topic[@t:id=="%s"]', ch_id)


Best wishes,

Massi

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread Thomas A. Schmitz via ntg-context

On 11/16/22 19:56, mf via ntg-context wrote:

local ch_id = t.at["ch:id"]


You're right, of course, using a colon was a stupid idea. When I replace 
it with an underscore, you can see that both are in fact identical:


\startbuffer[test]

  
 
This is the first test
22/11/16
 
 
This is the second test
22/11/17
 
  
  
 

  This will be the content of the first chapter.

 
 
 
  This will be the content of the second chapter.
 
 
  

\stopbuffer

\startxmlsetups xml:testsetups
   \xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{document|chapters|chapter|content|emph}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}

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

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

\startxmlsetups xml:chapter
\xmlfunction {#1} {chapter}
%\xmlflush {#1} 
\stopxmlsetups

\startxmlsetups xml:chapter:content
\xmltext {#1} {content}
\stopxmlsetups

\startxmlsetups xml:emph
  {\em \xmlflush {#1}}
\stopxmlsetups

\startluacode
function xml.functions.chapter (t)
 local chapter_id = t.at.ch_id
 local other_chapter_id = t.at["ch_id"]
 context (chapter_id)
 context.par ()
 context (other_chapter_id)
 context.par ()
local metadata = xml.filter (t, 
'../../topics/topic[@t:id=="%s"]', ch_id)
print (inspect(metadata))
lxml.command(t, ".", "xml:chapter:content")
context.par ()
end
\stopluacode

\starttext
\xmlprocessbuffer{main}{test}{}
\stoptext

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread mf via ntg-context

Il 16/11/22 18:33, Thomas A. Schmitz via ntg-context ha scritto:

\startbuffer[test]

   
  
This is the first test
22/11/16
  
  
This is the second test
22/11/17
  
   
   
  

  This will be the content of the first chapter.

  
  
 
  This will be the content of the second chapter.
 
  
   

\stopbuffer

\startxmlsetups xml:testsetups
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{document|chapters|chapter|content|emph}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}

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

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

\startxmlsetups xml:chapter
\xmlfunction {#1} {chapter}
 \xmlflush {#1} 
\stopxmlsetups

\startxmlsetups xml:chapter:content
\xmltext {#1} {content}
\stopxmlsetups

\startxmlsetups xml:emph
   {\em \xmlflush {#1}}
\stopxmlsetups

\startluacode
function xml.functions.chapter (t)
 local ch_id = t.at.ch:id



local ch_id = t.at["ch:id"]



local metadata = xml.filter (t, 
'../../topics/topic[@t:id=="%s"]', ch_id)
print (inspect(metadata))
lxml.command(t, ".", "xml:chapter:content")
context.par ()
context (ch_id)
context.par ()
end
\stopluacode


Best wishes,

Massi

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread Thomas A. Schmitz via ntg-context
Hi Duncan,

Thank you for pointing this out! I knew this was true inside the xmlns 
namespace, so you can’t have identical xml:id tags, but you’re probably right 
that it’s better to avoid this confusion altogether. Alas, this doesn’t help 
with my problem. Since there was a type in my minimal example from my 
experimentations, I include a corrected version, avoiding the identical tags

All best

Thomas

\startbuffer[test]

  
 
This is the first test
22/11/16
 
 
This is the second test
22/11/17
 
  
  
 

  This will be the content of the first chapter.

 
 
 
  This will be the content of the second chapter.
 
 
  

\stopbuffer

\startxmlsetups xml:testsetups
   \xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{document|chapters|chapter|content|emph}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}

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

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

\startxmlsetups xml:chapter
\xmlfunction {#1} {chapter}
 \xmlflush {#1} 
\stopxmlsetups

\startxmlsetups xml:chapter:content
\xmltext {#1} {content}
\stopxmlsetups

\startxmlsetups xml:emph
  {\em \xmlflush {#1}}
\stopxmlsetups

\startluacode
function xml.functions.chapter (t)
 local ch_id = t.at.ch:id
local metadata = xml.filter (t, 
'../../topics/topic[@t:id=="%s"]', ch_id)
print (inspect(metadata))
lxml.command(t, ".", "xml:chapter:content")
context.par ()
context (ch_id)
context.par ()
end
\stopluacode


> On 16. Nov 2022, at 17:18, Duncan Hothersall via ntg-context 
>  wrote:
> 
> I'm not sure about the code, sorry, but I do know that an XML document can't 
> have two IDs of the same value. Typically you would use a linkend attribute 
> on the element which is referencing an id (in this case the topics, I think).
> 
> Probably doesn't help with your problem, but it's likely a prerequisite for 
> it to work.
> 
> Bests,
> 
> Duncan


___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] Xml filtering in Lua

2022-11-16 Thread Duncan Hothersall via ntg-context
Hi Thomas.

I'm not sure about the code, sorry, but I do know that an XML document
can't have two IDs of the same value. Typically you would use a linkend
attribute on the element which is referencing an id (in this case the
topics, I think).

Probably doesn't help with your problem, but it's likely a prerequisite for
it to work.

Bests,

Duncan

On Wed, 16 Nov 2022 at 16:11, Thomas A. Schmitz via ntg-context <
ntg-context@ntg.nl> wrote:

> Hi all,
>
> I thought this was easy, but I overestimated my competence… I want to
> filter xml elements via their attributes and retrieve and typeset parts
> belonging together. Here is a small test file that explains what I’m trying:
>
> \startbuffer[test]
> 
>
>   
> This is the first test
> 22/11/16
>   
>   
> This is the second test
> 22/11/17
>   
>
>
>   
> 
>   This will be the content of the first chapter.
> 
>   
>   
>  
>   This will be the content of the second chapter.
>  
>   
>
> 
> \stopbuffer
>
> \startxmlsetups xml:testsetups
> \xmlsetsetup{#1}{*}{-}
> \xmlsetsetup{#1}{document|chapters|chapter|content|emph}{xml:*}
> \stopxmlsetups
>
> \xmlregistersetup{xml:testsetups}
>
> \startxmlsetups xml:document
> \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:chapters
> \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:chapter
> \xmlfunction {#1} {chapter}
>  \xmlflush {#1}
> \stopxmlsetups
>
> \startxmlsetups xml:chapter:content
> \xmltext {#1} {content}
> \stopxmlsetups
>
> \startxmlsetups xml:emph
>{\em \xmlflush {#1}}
> \stopxmlsetups
>
> \startluacode
> function xml.functions.chapter (t)
>  local ch_id = t.at.id
> local metadata = xml.filter (root,
> '../../topics/topic[@id=="%s"]', ch_id)
> print (inspect(metadata))
> lxml.command(t, ".", "xml:chapter:content")
> context.par ()
> context (ch_id)
> context.par ()
> end
> \stopluacode
>
> \starttext
> \xmlprocessbuffer{main}{test}{}
> \stoptext
>
> The line with xml.filter does not work as I expected. How can I walk the
> tree, find the “topic” element with the same “id” attribute as the chapter
> I’m currently in, and then typeset the different children of the topic
> element?
>
> Thanks a lot and all best
>
> Thomas
>
>
> ___
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : https://contextgarden.net
>
> ___
>
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

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


Re: [NTG-context] XML Namespaces and XML Setups

2022-05-24 Thread Bruce Horrocks via ntg-context
I haven't seen it explicitly documented - my cue to add it to the Wiki I guess!

I work with XML a fair bit and, IMHO, the WWW consortium docs do a very poor 
job of explaining namespaces because they make them seem much more complicated 
than they are. Essentially, a tag with a namespace identifier is just another 
tag i.e. treat all the characters, including the colon, as the tag name. Armed 
with that knowledge I just created a second tag definition in the sample code 
you posted.

> On 24 May 2022, at 09:50, Duncan Hothersall  wrote:
> 
> Yes, it does! Thanks Bruce. Is this documented somewhere already and I missed 
> it?
> 
> Cheers.
> 
> Duncan
> 
> On Mon, 23 May 2022 at 21:14, Bruce Horrocks  wrote:
> Does this help?
> 
> \startxmlsetups xml:demo:base
>   \xmlsetsetup{#1}{tag}{xml:demo:tag}
>   \xmlsetsetup{#1}{o:tag}{xml:demo:otag} %% <---
> \stopxmlsetups
> \xmlregisterdocumentsetup{demo}{xml:demo:base}
> \startxmlsetups xml:demo:tag
>   \xmlflush{#1}
> \stopxmlsetups
> \startxmlsetups xml:demo:otag   %% <---
>   {\bf \xmlflush{#1}}
> \stopxmlsetups
> \starttext
> \startbuffer[test]
> 
>xmlns:o="NameSpaceO">
>   text text
> 
> \stopbuffer
> \xmlprocessbuffer{demo}{test}{}
> \stoptext
> 
> > On 23 May 2022, at 09:07, Duncan Hothersall via ntg-context 
> >  wrote:
> > 
> > I found this unanswered question on the list from November 2020 and find 
> > today that I have the same question. How can one handle elements with the 
> > same name but in different namespaces? How should the different 
> > \startxmlsetups commands be written?
> > 
> > Thanks.
> > 
> > Duncan
> > 
> > On Mon, 16 Nov 2020 at 13:37, Christoph Reller  
> > wrote:
> > Dear List,
> > 
> > Consider the following MWE:
> > 
> > \startxmlsetups xml:demo:base
> >   \xmlsetsetup{#1}{tag}{xml:demo:tag}
> > \stopxmlsetups
> > \xmlregisterdocumentsetup{demo}{xml:demo:base}
> > \startxmlsetups xml:demo:tag
> >   %\doif{\xmlnamespace{#1}}{o}{NameSpaceO:}
> >   \xmlflush{#1}
> > \stopxmlsetups
> > \starttext
> > \startbuffer[test]
> > 
> >  >   xmlns:o="NameSpaceO">
> >   text text
> > 
> > \stopbuffer
> > \xmlprocessbuffer{demo}{test}{}
> > \stoptext
> > 
> > My questions:
> > - Is there a good way to have a separate XML setup for each XML namespace?
> > - Alternatively, one has to do the distinction within the same XML setup. 
> > In this case, how do we get the complete namespace? (In this example: 
> > "NameSpaceA" and "NameSpaceO")
> > 
> > Thanks in advance for your help!
> > 
> > Cheers, Christoph

—
Bruce Horrocks
Hampshire, UK

___
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
___


Re: [NTG-context] XML Namespaces and XML Setups

2022-05-24 Thread Duncan Hothersall via ntg-context
Yes, it does! Thanks Bruce. Is this documented somewhere already and I
missed it?

Cheers.

Duncan

On Mon, 23 May 2022 at 21:14, Bruce Horrocks  wrote:

> Does this help?
>
> \startxmlsetups xml:demo:base
>   \xmlsetsetup{#1}{tag}{xml:demo:tag}
>   \xmlsetsetup{#1}{o:tag}{xml:demo:otag} %% <---
> \stopxmlsetups
> \xmlregisterdocumentsetup{demo}{xml:demo:base}
> \startxmlsetups xml:demo:tag
>   \xmlflush{#1}
> \stopxmlsetups
> \startxmlsetups xml:demo:otag   %% <---
>   {\bf \xmlflush{#1}}
> \stopxmlsetups
> \starttext
> \startbuffer[test]
> 
>xmlns:o="NameSpaceO">
>   text text
> 
> \stopbuffer
> \xmlprocessbuffer{demo}{test}{}
> \stoptext
>
> > On 23 May 2022, at 09:07, Duncan Hothersall via ntg-context <
> ntg-context@ntg.nl> wrote:
> >
> > I found this unanswered question on the list from November 2020 and find
> today that I have the same question. How can one handle elements with the
> same name but in different namespaces? How should the different
> \startxmlsetups commands be written?
> >
> > Thanks.
> >
> > Duncan
> >
> > On Mon, 16 Nov 2020 at 13:37, Christoph Reller <
> christoph.rel...@gmail.com> wrote:
> > Dear List,
> >
> > Consider the following MWE:
> >
> > \startxmlsetups xml:demo:base
> >   \xmlsetsetup{#1}{tag}{xml:demo:tag}
> > \stopxmlsetups
> > \xmlregisterdocumentsetup{demo}{xml:demo:base}
> > \startxmlsetups xml:demo:tag
> >   %\doif{\xmlnamespace{#1}}{o}{NameSpaceO:}
> >   \xmlflush{#1}
> > \stopxmlsetups
> > \starttext
> > \startbuffer[test]
> > 
> >  >   xmlns:o="NameSpaceO">
> >   text text
> > 
> > \stopbuffer
> > \xmlprocessbuffer{demo}{test}{}
> > \stoptext
> >
> > My questions:
> > - Is there a good way to have a separate XML setup for each XML
> namespace?
> > - Alternatively, one has to do the distinction within the same XML
> setup. In this case, how do we get the complete namespace? (In this
> example: "NameSpaceA" and "NameSpaceO")
> >
> > Thanks in advance for your help!
> >
> > Cheers, Christoph
> >
> ___
> > 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
> >
> ___
> >
> >
> >
> ___
> > 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
> >
> ___
>
> —
> Bruce Horrocks
> Hampshire, UK
>
>
___
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
___


Re: [NTG-context] XML Namespaces and XML Setups

2022-05-23 Thread Bruce Horrocks via ntg-context
Does this help?

\startxmlsetups xml:demo:base
  \xmlsetsetup{#1}{tag}{xml:demo:tag}
  \xmlsetsetup{#1}{o:tag}{xml:demo:otag} %% <---
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{xml:demo:base}
\startxmlsetups xml:demo:tag
  \xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:demo:otag   %% <---
  {\bf \xmlflush{#1}}
\stopxmlsetups
\starttext
\startbuffer[test]


  text text

\stopbuffer
\xmlprocessbuffer{demo}{test}{}
\stoptext

> On 23 May 2022, at 09:07, Duncan Hothersall via ntg-context 
>  wrote:
> 
> I found this unanswered question on the list from November 2020 and find 
> today that I have the same question. How can one handle elements with the 
> same name but in different namespaces? How should the different 
> \startxmlsetups commands be written?
> 
> Thanks.
> 
> Duncan
> 
> On Mon, 16 Nov 2020 at 13:37, Christoph Reller  
> wrote:
> Dear List,
> 
> Consider the following MWE:
> 
> \startxmlsetups xml:demo:base
>   \xmlsetsetup{#1}{tag}{xml:demo:tag}
> \stopxmlsetups
> \xmlregisterdocumentsetup{demo}{xml:demo:base}
> \startxmlsetups xml:demo:tag
>   %\doif{\xmlnamespace{#1}}{o}{NameSpaceO:}
>   \xmlflush{#1}
> \stopxmlsetups
> \starttext
> \startbuffer[test]
> 
>xmlns:o="NameSpaceO">
>   text text
> 
> \stopbuffer
> \xmlprocessbuffer{demo}{test}{}
> \stoptext
> 
> My questions:
> - Is there a good way to have a separate XML setup for each XML namespace?
> - Alternatively, one has to do the distinction within the same XML setup. In 
> this case, how do we get the complete namespace? (In this example: 
> "NameSpaceA" and "NameSpaceO")
> 
> Thanks in advance for your help!
> 
> Cheers, Christoph
> ___
> 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
> ___
> 
> 
> ___
> 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
> ___

—
Bruce Horrocks
Hampshire, UK

___
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
___


Re: [NTG-context] XML Namespaces and XML Setups

2022-05-23 Thread Duncan Hothersall via ntg-context
I found this unanswered question on the list from November 2020 and find
today that I have the same question. How can one handle elements with the
same name but in different namespaces? How should the different
\startxmlsetups commands be written?

Thanks.

Duncan

On Mon, 16 Nov 2020 at 13:37, Christoph Reller 
wrote:

> Dear List,
>
> Consider the following MWE:
>
> \startxmlsetups xml:demo:base
>   \xmlsetsetup{#1}{tag}{xml:demo:tag}
> \stopxmlsetups
> \xmlregisterdocumentsetup{demo}{xml:demo:base}
> \startxmlsetups xml:demo:tag
>   %\doif{\xmlnamespace{#1}}{o}{NameSpaceO:}
>   \xmlflush{#1}
> \stopxmlsetups
> \starttext
> \startbuffer[test]
> 
>xmlns:o="NameSpaceO">
>   text text
> 
> \stopbuffer
> \xmlprocessbuffer{demo}{test}{}
> \stoptext
>
> My questions:
> - Is there a good way to have a separate XML setup for each XML namespace?
> - Alternatively, one has to do the distinction within the same XML setup.
> In this case, how do we get the complete namespace? (In this example:
> "NameSpaceA" and "NameSpaceO")
>
> Thanks in advance for your help!
>
> Cheers, Christoph
>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] XML: calculations on attribute values before output

2022-05-05 Thread Duncan Hothersall via ntg-context
Thanks so much Taco, that opens the door to a lot for me. It's a tricky
learning curve.

Just in case anyone else is copying code in future for CALS, there's a tiny
tweak to the rows calculation, it should be (t.at.morerows or 0) + 1.

I see a route to solving lots of other problems here too. Thanks again.

Duncan

On Thu, 5 May 2022 at 08:21, Taco Hoekwater  wrote:

>
>
> > On 4 May 2022, at 22:10, Duncan Hothersall via ntg-context <
> ntg-context@ntg.nl> wrote:
> >
> > Hi.
> >
> > I'm processing an XML table and need to set a row span. Because we use a
> variant of the CALS table model, spans are defined by an attribute saying
> how many *additional* rows should be spanned, as opposed to how many *in
> total*. So to translate this into TABLE \bTD[nr=X] syntax I need to add 1.
> >
> > I'm guessing this is very easily doable (in lua?) but I've tried various
> permutations and can't work it out. If anyone could give me a pointer that
> would be great.
> >
> > (In reality I'm going to need to handle lots of other conversions of
> attribute values into \bTD[...] commands, so if there's a generalised way
> of doing that sort of thing, or even better if someone has already tackled
> CALS tables in this way, that would also be great!)
>
> Not CALS, but I do a lot of HTML table processing. I find it all much
> easier on the lua side, because there the
> attributes are just in a table entry of the argument node t ( t.at ):
>
> set up a lua function in the setups:
>
> \startxmlsetups xml:demo:base
>  \xmlsetsetup{#1}{*}{xml:demo:*}
>  \xmlsetfunction {\xmldocument}{entry}{userdata.xmlfunctions.entry}
> \stopxmlsetups
>
> and then add this lua code:
>
> \startluacode
> userdata.xmlfunctions = {}
> function userdata.xmlfunctions.entry (t)
>   local rows = (t.at.morerows or 1) + 1
>   context.bTD({nr=rows})
>   lxml.flush(t)
>   context.eTD()
> end
> \stopluacode
>
> All of the tex-side commands also exist in lua, in the lxml and/or xml
> table, e.g.:
>
> direct output flushing:
>   lxml.flush(t)
>   lxml.all(t, ‘entry’)
>
> filter for processing:
>   for b in xml.collected(lxml.getid(t),'../row/entry') do … end
>
>
> (those are the ones I use a lot, there are many more)
>
> Best wishes,
> Taco



-- 
Duncan Hothersall, Operations Director
CAPDM Limited - Online Program Enablers
0131 677 2400  www.capdm.com
Registered in Scotland: SC168970   VAT: 682 846 983
Registered address: 20 Forth Street Edinburgh EH1 3LH UK


Capture, author, publish, deliver and manage your learning materials.


*Sign up to the CAPDM newsletter here *
___
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
___


Re: [NTG-context] XML: calculations on attribute values before output

2022-05-05 Thread Taco Hoekwater via ntg-context


> On 4 May 2022, at 22:10, Duncan Hothersall via ntg-context 
>  wrote:
> 
> Hi.
> 
> I'm processing an XML table and need to set a row span. Because we use a 
> variant of the CALS table model, spans are defined by an attribute saying how 
> many *additional* rows should be spanned, as opposed to how many *in total*. 
> So to translate this into TABLE \bTD[nr=X] syntax I need to add 1.
> 
> I'm guessing this is very easily doable (in lua?) but I've tried various 
> permutations and can't work it out. If anyone could give me a pointer that 
> would be great.
> 
> (In reality I'm going to need to handle lots of other conversions of 
> attribute values into \bTD[...] commands, so if there's a generalised way of 
> doing that sort of thing, or even better if someone has already tackled CALS 
> tables in this way, that would also be great!)

Not CALS, but I do a lot of HTML table processing. I find it all much easier on 
the lua side, because there the 
attributes are just in a table entry of the argument node t ( t.at ):

set up a lua function in the setups:

\startxmlsetups xml:demo:base
 \xmlsetsetup{#1}{*}{xml:demo:*}
 \xmlsetfunction {\xmldocument}{entry}{userdata.xmlfunctions.entry}
\stopxmlsetups

and then add this lua code:

\startluacode
userdata.xmlfunctions = {}
function userdata.xmlfunctions.entry (t)
  local rows = (t.at.morerows or 1) + 1
  context.bTD({nr=rows})
  lxml.flush(t) 
  context.eTD()
end
\stopluacode

All of the tex-side commands also exist in lua, in the lxml and/or xml table, 
e.g.:

direct output flushing: 
  lxml.flush(t)
  lxml.all(t, ‘entry’)

filter for processing:
  for b in xml.collected(lxml.getid(t),'../row/entry') do … end


(those are the ones I use a lot, there are many more)

Best wishes,
Taco
___
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
___


Re: [NTG-context] XML processing instructions

2022-05-03 Thread Duncan Hothersall via ntg-context
Just following up on my own question in case anybody else is interested, I
realised that the logic of my preprocessor code wasn't the problem, it was
just my ignorance of lua and character escaping. Both ? and * are special
characters in string.gsub expressions, so they need to be escaped with the
lua escape character which is % (which sends my editor haywire because it
thinks I am putting in a TeX comment, but never mind!).

So my now working code to translate historic processing instructions into
directives without a separate pass is:

\startluacode
function lxml.preprocessor(data)
 data = string.gsub(data, '<%?capdm %*force_line_stop%?>',
'')
 return data
end
\stopluacode

\startsetups xml:directive:injector:newline
 \crlf
\stopsetups

Duncan

On Mon, 2 May 2022 at 09:24, Duncan Hothersall  wrote:

> Many thanks Denis. Very useful tip on the injectors and generalised
> command usage. That will definitely come in useful.
>
> My problem is that I already have a lot of XML data with the existing
> processing instructions in it. I know I could use an external preprocess in
> something like Python to change them into injectors before they are fed
> into ConTeXt, but I was hoping there was a way to handle them directly as
> part of the ConTeXt / lua process.
>
> Thanks again though.
>
> Duncan
>
>
>
>
> On Mon, 2 May 2022, 08:48 ,  wrote:
>
>> That was too quick, sorry.
>>
>>
>>
>> Hi Duncan,
>>
>>
>>
>> I have used context’s own injectors for this :
>>
>>
>>
>> 
>>
>>
>>
>> \startsetups xml:directive:injector:addlinetopage
>>
>>   \adaptlayout[lines=+1]
>>
>> \stopsetups
>>
>>
>>
>> Or, for your line break example :
>>
>>
>>
>> 
>>
>>
>>
>> \startsetups xml:directive:injector:newline
>>
>>   \crlf
>>
>> \stopsetups
>>
>>
>>
>> Also, I have learned that you can just use arbitrary context code in xml:
>>
>>
>>
>> \def\xmltexdirective#1#2{\doif{#1}{command}{#2}}
>>
>>
>>
>> \xmlinstalldirective{tex}{xmltexdirective}
>>
>>
>>
>>  
>>
>>  
>>
>>  
>>
>>
>>
>> Best,
>>
>> Denis
>>
>>
>>
>> *Von:* Maier, Denis Christian (UB)
>> *Gesendet:* Montag, 2. Mai 2022 09:45
>> *An:* 'mailing list for ConTeXt users' 
>> *Cc:* Duncan Hothersall 
>> *Betreff:* AW: [NTG-context] XML processing instructions
>>
>>
>>
>>
>>
>> *Von:* ntg-context  *Im Auftrag von *Duncan
>> Hothersall via ntg-context
>> *Gesendet:* Montag, 2. Mai 2022 09:20
>> *An:* mailing list for ConTeXt users 
>> *Cc:* Duncan Hothersall 
>> *Betreff:* [NTG-context] XML processing instructions
>>
>>
>>
>> I have a big set of existing XML books (held in a derivative of DocBook)
>> which I'm looking to start processing directly with ConTeXt. (Up to now I
>> have a system which converts the XML into ConTeXt code which is then
>> processed, but this is inefficient and lots of the code is now unsupported.)
>>
>>
>>
>> I've had some success producing output, but my first real sticking point
>> has come with processing instructions. The existing XML contains lots of
>> processing instructions of the form
>>
>> , some of which can be conditional and introduce new
>> data etc. But I'd be happy at this stage if I could just process the most
>> basic one of them, which is used to introduce a line stop in a running
>> paragraph of text.
>>
>>
>>
>> My best guess at how to do this was to use the lxml.preprocessor function
>> to convert the processing instruction into an element, and then process the
>> element as normal. But (a) my attempt didn't work, and (b) there may
>> well be a better way.
>>
>>
>>
>> Minimal working example below, except that obviously the processing
>> instruction bit doesn't work!
>>
>>
>>
>> Thanks for any help or insights.
>>
>>
>>
>> Duncan
>>
>>
>>
>>
>>
>> MWE:
>>
>> --
>>
>>
>>
>> \startbuffer[demo]
>> 
>>   A paragraph witha processing
>> instruction.
>> 
>> \stopbuffer
>>
>> \startxmlsetups xml:demo:base
>>  \xmlsetsetup{#1}{*}{xml:demo:*}
>> \stopxmlsetups
>> \xmlregisterdocumentsetup{demo}{xml:demo:base}
>>
>> \startxmlsetups xml:demo:book
>>  \xmlflush{#1}
>> \stopxmlsetups
>>
>> \startxmlsetups xml:demo:para
>>  \xmlflush{#1}\endgraf
>> \stopxmlsetups
>>
>> \startluacode
>>  function lxml.preprocessor(data,settings)
>>   return string.find(data,"")
>>and string.gsub(data,"> *force_line_stop?>","")
>>or data
>>  end
>> \stopluacode
>>
>> \startxmlsetups xml:demo:capdmlinestop
>>  \crlf
>>  \xmlflush{#1}
>> \stopxmlsetups
>>
>> \setupbodyfont[modern]
>> \starttext
>> \xmlprocessbuffer{demo}{demo}{}
>> \stoptext
>>
>>
>>
>> --
>>
>

-- 
Duncan Hothersall, Operations Director
CAPDM Limited - Online Program Enablers
0131 677 2400  www.capdm.com
Registered in Scotland: SC168970   VAT: 682 846 983
Registered address: 20 Forth Street Edinburgh EH1 3LH UK


Capture, author, publish, deliver and manage your learning materials.


*Sign up to the CAPDM newsletter here *

Re: [NTG-context] XML processing instructions

2022-05-02 Thread Duncan Hothersall via ntg-context
Many thanks Denis. Very useful tip on the injectors and generalised command
usage. That will definitely come in useful.

My problem is that I already have a lot of XML data with the existing
processing instructions in it. I know I could use an external preprocess in
something like Python to change them into injectors before they are fed
into ConTeXt, but I was hoping there was a way to handle them directly as
part of the ConTeXt / lua process.

Thanks again though.

Duncan




On Mon, 2 May 2022, 08:48 ,  wrote:

> That was too quick, sorry.
>
>
>
> Hi Duncan,
>
>
>
> I have used context’s own injectors for this :
>
>
>
> 
>
>
>
> \startsetups xml:directive:injector:addlinetopage
>
>   \adaptlayout[lines=+1]
>
> \stopsetups
>
>
>
> Or, for your line break example :
>
>
>
> 
>
>
>
> \startsetups xml:directive:injector:newline
>
>   \crlf
>
> \stopsetups
>
>
>
> Also, I have learned that you can just use arbitrary context code in xml:
>
>
>
> \def\xmltexdirective#1#2{\doif{#1}{command}{#2}}
>
>
>
> \xmlinstalldirective{tex}{xmltexdirective}
>
>
>
>  
>
>  
>
>  
>
>
>
> Best,
>
> Denis
>
>
>
> *Von:* Maier, Denis Christian (UB)
> *Gesendet:* Montag, 2. Mai 2022 09:45
> *An:* 'mailing list for ConTeXt users' 
> *Cc:* Duncan Hothersall 
> *Betreff:* AW: [NTG-context] XML processing instructions
>
>
>
>
>
> *Von:* ntg-context  *Im Auftrag von *Duncan
> Hothersall via ntg-context
> *Gesendet:* Montag, 2. Mai 2022 09:20
> *An:* mailing list for ConTeXt users 
> *Cc:* Duncan Hothersall 
> *Betreff:* [NTG-context] XML processing instructions
>
>
>
> I have a big set of existing XML books (held in a derivative of DocBook)
> which I'm looking to start processing directly with ConTeXt. (Up to now I
> have a system which converts the XML into ConTeXt code which is then
> processed, but this is inefficient and lots of the code is now unsupported.)
>
>
>
> I've had some success producing output, but my first real sticking point
> has come with processing instructions. The existing XML contains lots of
> processing instructions of the form
>
> , some of which can be conditional and introduce new
> data etc. But I'd be happy at this stage if I could just process the most
> basic one of them, which is used to introduce a line stop in a running
> paragraph of text.
>
>
>
> My best guess at how to do this was to use the lxml.preprocessor function
> to convert the processing instruction into an element, and then process the
> element as normal. But (a) my attempt didn't work, and (b) there may well
> be a better way.
>
>
>
> Minimal working example below, except that obviously the processing
> instruction bit doesn't work!
>
>
>
> Thanks for any help or insights.
>
>
>
> Duncan
>
>
>
>
>
> MWE:
>
> --
>
>
>
> \startbuffer[demo]
> 
>   A paragraph witha processing
> instruction.
> 
> \stopbuffer
>
> \startxmlsetups xml:demo:base
>  \xmlsetsetup{#1}{*}{xml:demo:*}
> \stopxmlsetups
> \xmlregisterdocumentsetup{demo}{xml:demo:base}
>
> \startxmlsetups xml:demo:book
>  \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:demo:para
>  \xmlflush{#1}\endgraf
> \stopxmlsetups
>
> \startluacode
>  function lxml.preprocessor(data,settings)
>   return string.find(data,"")
>and string.gsub(data," *force_line_stop?>","")
>or data
>  end
> \stopluacode
>
> \startxmlsetups xml:demo:capdmlinestop
>  \crlf
>  \xmlflush{#1}
> \stopxmlsetups
>
> \setupbodyfont[modern]
> \starttext
> \xmlprocessbuffer{demo}{demo}{}
> \stoptext
>
>
>
> --
>
___
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
___


Re: [NTG-context] XML processing instructions

2022-05-02 Thread Denis Maier via ntg-context
That was too quick, sorry.

Hi Duncan,

I have used context’s own injectors for this :



\startsetups xml:directive:injector:addlinetopage
  \adaptlayout[lines=+1]
\stopsetups

Or, for your line break example :



\startsetups xml:directive:injector:newline
  \crlf
\stopsetups

Also, I have learned that you can just use arbitrary context code in xml:

\def\xmltexdirective#1#2{\doif{#1}{command}{#2}}

\xmlinstalldirective{tex}{xmltexdirective}

 
 
 

Best,
Denis

Von: Maier, Denis Christian (UB)
Gesendet: Montag, 2. Mai 2022 09:45
An: 'mailing list for ConTeXt users' 
Cc: Duncan Hothersall 
Betreff: AW: [NTG-context] XML processing instructions


Von: ntg-context 
mailto:ntg-context-boun...@ntg.nl>> Im Auftrag von 
Duncan Hothersall via ntg-context
Gesendet: Montag, 2. Mai 2022 09:20
An: mailing list for ConTeXt users 
mailto:ntg-context@ntg.nl>>
Cc: Duncan Hothersall mailto:d...@capdm.com>>
Betreff: [NTG-context] XML processing instructions

I have a big set of existing XML books (held in a derivative of DocBook) which 
I'm looking to start processing directly with ConTeXt. (Up to now I have a 
system which converts the XML into ConTeXt code which is then processed, but 
this is inefficient and lots of the code is now unsupported.)

I've had some success producing output, but my first real sticking point has 
come with processing instructions. The existing XML contains lots of processing 
instructions of the form
, some of which can be conditional and introduce new data 
etc. But I'd be happy at this stage if I could just process the most basic one 
of them, which is used to introduce a line stop in a running paragraph of text.

My best guess at how to do this was to use the lxml.preprocessor function to 
convert the processing instruction into an element, and then process the 
element as normal. But (a) my attempt didn't work, and (b) there may well be a 
better way.

Minimal working example below, except that obviously the processing instruction 
bit doesn't work!

Thanks for any help or insights.

Duncan


MWE:
--

\startbuffer[demo]

  A paragraph witha processing 
instruction.

\stopbuffer

\startxmlsetups xml:demo:base
 \xmlsetsetup{#1}{*}{xml:demo:*}
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{xml:demo:base}

\startxmlsetups xml:demo:book
 \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:demo:para
 \xmlflush{#1}\endgraf
\stopxmlsetups

\startluacode
 function lxml.preprocessor(data,settings)
  return string.find(data,"")
   and string.gsub(data,"","")
   or data
 end
\stopluacode

\startxmlsetups xml:demo:capdmlinestop
 \crlf
 \xmlflush{#1}
\stopxmlsetups

\setupbodyfont[modern]
\starttext
\xmlprocessbuffer{demo}{demo}{}
\stoptext

--
___
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
___


Re: [NTG-context] XML processing instructions

2022-05-02 Thread Denis Maier via ntg-context
Hi Duncan,

I have used context’s own injectors for this :



\startsetups xml:directive:injector:addlinetopage
  \adaptlayout[lines=+1]
\stopsetups

Or, for your line break example :

Von: ntg-context  Im Auftrag von Duncan Hothersall 
via ntg-context
Gesendet: Montag, 2. Mai 2022 09:20
An: mailing list for ConTeXt users 
Cc: Duncan Hothersall 
Betreff: [NTG-context] XML processing instructions

I have a big set of existing XML books (held in a derivative of DocBook) which 
I'm looking to start processing directly with ConTeXt. (Up to now I have a 
system which converts the XML into ConTeXt code which is then processed, but 
this is inefficient and lots of the code is now unsupported.)

I've had some success producing output, but my first real sticking point has 
come with processing instructions. The existing XML contains lots of processing 
instructions of the form
, some of which can be conditional and introduce new data 
etc. But I'd be happy at this stage if I could just process the most basic one 
of them, which is used to introduce a line stop in a running paragraph of text.

My best guess at how to do this was to use the lxml.preprocessor function to 
convert the processing instruction into an element, and then process the 
element as normal. But (a) my attempt didn't work, and (b) there may well be a 
better way.

Minimal working example below, except that obviously the processing instruction 
bit doesn't work!

Thanks for any help or insights.

Duncan


MWE:
--

\startbuffer[demo]

  A paragraph witha processing 
instruction.

\stopbuffer

\startxmlsetups xml:demo:base
 \xmlsetsetup{#1}{*}{xml:demo:*}
\stopxmlsetups
\xmlregisterdocumentsetup{demo}{xml:demo:base}

\startxmlsetups xml:demo:book
 \xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:demo:para
 \xmlflush{#1}\endgraf
\stopxmlsetups

\startluacode
 function lxml.preprocessor(data,settings)
  return string.find(data,"")
   and string.gsub(data,"","")
   or data
 end
\stopluacode

\startxmlsetups xml:demo:capdmlinestop
 \crlf
 \xmlflush{#1}
\stopxmlsetups

\setupbodyfont[modern]
\starttext
\xmlprocessbuffer{demo}{demo}{}
\stoptext

--
___
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
___


Re: [NTG-context] XML processing instructions

2022-05-02 Thread Duncan Hothersall via ntg-context
Apologies, there are two rogue * in the lxml.preprocessor code, but even
when they are removed it doesn't work.

On Mon, 2 May 2022 at 08:19, Duncan Hothersall  wrote:

> I have a big set of existing XML books (held in a derivative of DocBook)
> which I'm looking to start processing directly with ConTeXt. (Up to now I
> have a system which converts the XML into ConTeXt code which is then
> processed, but this is inefficient and lots of the code is now unsupported.)
>
> I've had some success producing output, but my first real sticking point
> has come with processing instructions. The existing XML contains lots of
> processing instructions of the form
> , some of which can be conditional and introduce new
> data etc. But I'd be happy at this stage if I could just process the most
> basic one of them, which is used to introduce a line stop in a running
> paragraph of text.
>
> My best guess at how to do this was to use the lxml.preprocessor function
> to convert the processing instruction into an element, and then process the
> element as normal. But (a) my attempt didn't work, and (b) there may well
> be a better way.
>
> Minimal working example below, except that obviously the processing
> instruction bit doesn't work!
>
> Thanks for any help or insights.
>
> Duncan
>
>
> MWE:
> --
>
> \startbuffer[demo]
> 
>   A paragraph witha processing
> instruction.
> 
> \stopbuffer
>
> \startxmlsetups xml:demo:base
>  \xmlsetsetup{#1}{*}{xml:demo:*}
> \stopxmlsetups
> \xmlregisterdocumentsetup{demo}{xml:demo:base}
>
> \startxmlsetups xml:demo:book
>  \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:demo:para
>  \xmlflush{#1}\endgraf
> \stopxmlsetups
>
> \startluacode
>  function lxml.preprocessor(data,settings)
>   return string.find(data,"")
>and string.gsub(data," *force_line_stop?>","")
>or data
>  end
> \stopluacode
>
> \startxmlsetups xml:demo:capdmlinestop
>  \crlf
>  \xmlflush{#1}
> \stopxmlsetups
>
> \setupbodyfont[modern]
> \starttext
> \xmlprocessbuffer{demo}{demo}{}
> \stoptext
>
> --
>


-- 
Duncan Hothersall, Operations Director
CAPDM Limited - Online Program Enablers
0131 677 2400  www.capdm.com
Registered in Scotland: SC168970   VAT: 682 846 983
Registered address: 20 Forth Street Edinburgh EH1 3LH UK


Capture, author, publish, deliver and manage your learning materials.


*Sign up to the CAPDM newsletter here *
___
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
___


Re: [NTG-context] Xml - Lua - context

2022-03-28 Thread Thomas A. Schmitz via ntg-context


> On 28. Mar 2022, at 18:21, Adam Reviczky via ntg-context  
> wrote:
> 
> Hi Thomas,
> 
> Not sure whether it helps or not, but in regards to combinations and Lua I 
> have had some challenges as well, but Hans' and Wolfgangs' solution with 
> externalfigures works fine for me now:
> 
> https://mailman.ntg.nl/pipermail/ntg-context/2021/103822.html
> https://mailman.ntg.nl/pipermail/ntg-context/2021/103827.html
> 
> Adam


Thank you, that’s already very useful! I should have looked if there is a 
“delayed” alternative for externalfigure as well, but I also take Hans’s 
warning to heart that all of this is non-trivial. 

Thank you, best wishes

Thomas
___
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
___


Re: [NTG-context] Xml - Lua - context

2022-03-28 Thread Adam Reviczky via ntg-context
Hi Thomas,

Not sure whether it helps or not, but in regards to combinations and Lua I
have had some challenges as well, but Hans' and Wolfgangs' solution with
externalfigures works fine for me now:

https://mailman.ntg.nl/pipermail/ntg-context/2021/103822.html
https://mailman.ntg.nl/pipermail/ntg-context/2021/103827.html

Adam

On Mon, Mar 28, 2022 at 2:42 PM Thomas A. Schmitz via ntg-context <
ntg-context@ntg.nl> wrote:

> And here comes question 2, a very basic one: on A4 landscape pages, I want
> to place two images next to each other (like the spread pages of a book).
> What would be the preferred way of the really competent users to do this,
> again keeping in mind that I want to loop over page numbers in a pdf file
> and thus am coding in Lua. So far, I have tried or thought about:
>
> 1. Embedded xtable
>
> This is what I’m using now, an xtable of two columns for every A4 page. It
> works, but I wonder if it’s a good method.
>
> 2. combinations
>
> This appeared to be the most natural approach (because it’s what
> combinations are for), but I ran into expansion problems, added a few
> “function () end” in my code, but couldn’t make it compile. Combinations,
> combined with framed and externalfigure, are difficult to write in Lua - or
> am I too stupid to find the winning combination (sorry for the puns).
>
> 3. columns
>
> Again, this would seen like a natural approach, having every A4 page set
> up as two columns, but maybe that’s overkill?
>
> I’d be curious to know what you think!
>
> All best
>
> Thomas
>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] XML, dealing with whitespace

2022-01-17 Thread Denis Maier via ntg-context
Hi Wolfgang,

Von: Wolfgang Schuster 
Gesendet: Samstag, 15. Januar 2022 20:28
An: mailing list for ConTeXt users ; Denis Maier via 
ntg-context 
Cc: Maier, Denis Christian (UB) 
Betreff: Re: [NTG-context] XML, dealing with whitespace

Denis Maier via ntg-context schrieb am 15.01.2022 um 13:04:

Hi all,

I have sources that look like this:

%


   Bla Bla Bla
   
  
 Bla
  , Bla Bla.

%

Typesetting this with context gives me a spurious space after the underlined 
Bla in italics.

There is no spurious space, the line break is just converted to a space and I 
see no reason why this shouldn't happen. To remove space before or after 
certain parts of text within a paragraph you can use the \removeunwantedspace 
and \ignorespaces commands.

Yes, it's absolutely true. From tex's point of view, the space is not spurious. 
It's absolutely adaquate to treat the newline as a space here.

As I've outlined in my original post the problem occurs because xslt adds these 
indentations here. FWIW, I finally found this solution, which seems has been 
added to xslt 3.0 (after being available as a saxon extension: there's a new 
attribute  on xsl:output that can be used to control this:

(https://www.saxonica.com/documentation9.5/xsl-elements/output.html)

So, the solution to my problem is this:



Denis



 begin example
\starttexdefinition RemovePreceding #1
\removeunwantedspaces
#1
\stoptexdefinition

\starttexdefinition RemoveFollowing #1
#1
\ignorespaces
\stoptexdefinition

\starttext

Bla \RemovePreceding{Bla} Bla

Bla \RemoveFollowing{Bla} Bla

\stoptext
 end example

When only  following spaces are a problem a better alternative to \ignorespace 
is \autoinsertnextspace which checks the following token which ensures there is 
space when the next character is punctuation.

 begin example
\starttexdefinition Italic #1
\emphasized{#1}
\autoinsertnextspace
\stoptexdefinition

\starttexdefinition Underbar #1
\underbar{#1}
\stoptexdefinition

\starttext

Bla Bla Bla

\Underbar{\Italic{Bla} , Bla Bla.}

\stoptext
 end example

Wolfgang
___
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
___


Re: [NTG-context] XML, dealing with whitespace

2022-01-15 Thread Wolfgang Schuster via ntg-context

Denis Maier via ntg-context schrieb am 15.01.2022 um 13:04:


Hi all,

I have sources that look like this:

%





   Bla Bla Bla



  

 Bla

  , Bla Bla.



%

Typesetting this with context gives me a spurious space after the 
underlined Bla in italics.




There is no spurious space, the line break is just converted to a space 
and I see no reason why this shouldn't happen. To remove space before or 
after certain parts of text within a paragraph you can use the 
\removeunwantedspace and \ignorespaces commands.


 begin example
\starttexdefinition RemovePreceding #1
    \removeunwantedspaces
    #1
\stoptexdefinition

\starttexdefinition RemoveFollowing #1
    #1
    \ignorespaces
\stoptexdefinition

\starttext

Bla \RemovePreceding{Bla} Bla

Bla \RemoveFollowing{Bla} Bla

\stoptext
 end example

When only  following spaces are a problem a better alternative to 
\ignorespace is \autoinsertnextspace which checks the following token 
which ensures there is space when the next character is punctuation.


 begin example
\starttexdefinition Italic #1
    \emphasized{#1}
    \autoinsertnextspace
\stoptexdefinition

\starttexdefinition Underbar #1
    \underbar{#1}
\stoptexdefinition

\starttext

Bla Bla Bla

\Underbar{\Italic{Bla} , Bla Bla.}

\stoptext
 end example

Wolfgang

___
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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-10 Thread Denis Maier via ntg-context
Well, it was more a question out of curiosity, not a specific problem that 
needs to be solved. (Or actually, I found another solution for the problem I've 
had first.)
Anyway, I still think this would be handy as that would be a more maintainble 
control structure. I'll try to come up with an example next week... 

Denis 

> -Ursprüngliche Nachricht-
> Von: Wolfgang Schuster 
> Gesendet: Donnerstag, 9. Dezember 2021 18:32
> An: mailing list for ConTeXt users ; Denis Maier via ntg-
> context 
> Cc: Maier, Denis Christian (UB) 
> Betreff: Re: [NTG-context] xml processing: if elseif else / switch case
> 
> Denis Maier via ntg-context schrieb am 09.12.2021 um 18:24:
> > Thanks for all the answers. That's helpful. But I think that does not work
> with the xml tests, or does it? I mean, is this a general mechanism?
> 
> Since you didn't provide a example with your problem there is no way to tell
> how to improve it.
> 
> Wolfgang

___
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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Wolfgang Schuster via ntg-context

Denis Maier via ntg-context schrieb am 09.12.2021 um 18:24:

Thanks for all the answers. That's helpful. But I think that does not work with 
the xml tests, or does it? I mean, is this a general mechanism?


Since you didn't provide a example with your problem there is no way to 
tell how to improve it.


Wolfgang

___
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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Denis Maier via ntg-context
Thanks for all the answers. That's helpful. But I think that does not work with 
the xml tests, or does it? I mean, is this a general mechanism?

Denis

Von: ntg-context  im Auftrag von Hans Hagen via 
ntg-context 
Gesendet: Donnerstag, 9. Dezember 2021 17:53:42
An: mailing list for ConTeXt users
Cc: Hans Hagen
Betreff: Re: [NTG-context] xml processing: if elseif else / switch case

On 12/9/2021 5:30 PM, Joey McCollum via ntg-context wrote:
> Thanks for correcting that, Wolfgang. I must have added the other \fi
> instances because I was trying to use \orelse in MKIV and couldn't get
> it to work. Is it only supported in LMTX?
yes, it's one of the native luametatex features (already there for a while)

Hans

-
   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
___
___
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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Hans Hagen via ntg-context

On 12/9/2021 5:30 PM, Joey McCollum via ntg-context wrote:
Thanks for correcting that, Wolfgang. I must have added the other \fi 
instances because I was trying to use \orelse in MKIV and couldn't get 
it to work. Is it only supported in LMTX?

yes, it's one of the native luametatex features (already there for a while)

Hans

-
  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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Joey McCollum via ntg-context
Thanks for correcting that, Wolfgang. I must have added the other \fi
instances because I was trying to use \orelse in MKIV and couldn't get it
to work. Is it only supported in LMTX?

Joey

On Thu, Dec 9, 2021 at 11:30 AM Hans Hagen via ntg-context <
ntg-context@ntg.nl> wrote:

> On 12/9/2021 5:11 PM, Wolfgang Schuster via ntg-context wrote:
> > Joey McCollum via ntg-context schrieb am 09.12.2021 um 15:08:
> >> I believe \orelse might be what you want. It works with most \if...
> >> macros, and it avoids nesting of \doifelse constructs. Here's an
> >> example, which I use in conditionally removing preceding punctuation
> >> if any other keys are defined before a specific one in an assignment:
> >>
> >> ```
> >>   % If any of the preceding keys was specified, then replace any
> >> preceding punctuation with a space
> >> % and typeset the number with its CSL abbreviation, followed by a
> >> comma
> >>   \ifdefined\btxsbllocvol
> >> \removeunwantedspaces\removepunctuation\btxspace
> >> \orelse\ifdefined\btxsbllocno
> >> \removeunwantedspaces\removepunctuation\btxspace
> >>   \fi
> >> \orelse\ifdefined\btxsbllocpt
> >>   [...]
> >>   \fi
> >> ```
> >
> > The \fi at the end of each \orelse branch is wrong.
> >
> > \ifdefined\btxsbllocvol
> >  ...
> > \orelse\ifdefined\btxsbllocno
> >  ...
> > \else
> >  ...
> > \fi
> and when 'string' comparison is needed one can do:
>
> \starttext
>
> \def\foo{foo}
> \def\ofo{ofo}
> \def\oof{oof}
>
> \def\XXX{ofo}
>
> \ifcstok\XXX\foo
>  FOO
> \orelse\ifcstok\XXX\ofo
>  OFO
> \orelse\ifcstok\XXX\oof
>  OOF
> \else
>  XXX
> \fi
>
> \def\XXX{\ofo}
>
> \iftok{\XXX}{\foo}%
>  FOO
> \orelse\iftok{\XXX}{\ofo}%
>  OFO
> \orelse\iftok{\XXX}{\oof}%
>  OOF
> \else
>  XXX
> \fi
>
> \ifcstok{\XXX}\foo
>  FOO
> \orelse\ifcstok{\XXX}\ofo
>  OFO
> \orelse\ifcstok\XXX}\oof
>  OOF
> \else
>  XXX
> \fi
>
> \stoptext
>
> watch the subtle differences. It all makes coding in tex primitives a
> bit more visual appealing and readable. Oone of the objectives of lmtx
> is that users can read the context code without pondering too much about
> the syntax or getting depressed by possibly obscure helper macros and
> expansion trickery.
>
> Hans
>
>
> -
>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
>
> ___
>
___
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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Hans Hagen via ntg-context

On 12/9/2021 5:11 PM, Wolfgang Schuster via ntg-context wrote:

Joey McCollum via ntg-context schrieb am 09.12.2021 um 15:08:
I believe \orelse might be what you want. It works with most \if... 
macros, and it avoids nesting of \doifelse constructs. Here's an 
example, which I use in conditionally removing preceding punctuation 
if any other keys are defined before a specific one in an assignment:


```
      % If any of the preceding keys was specified, then replace any 
preceding punctuation with a space
    % and typeset the number with its CSL abbreviation, followed by a 
comma

      \ifdefined\btxsbllocvol
\removeunwantedspaces\removepunctuation\btxspace
\orelse\ifdefined\btxsbllocno
\removeunwantedspaces\removepunctuation\btxspace
      \fi
\orelse\ifdefined\btxsbllocpt
      [...]
      \fi
```


The \fi at the end of each \orelse branch is wrong.

\ifdefined\btxsbllocvol
     ...
\orelse\ifdefined\btxsbllocno
     ...
\else
     ...
\fi

and when 'string' comparison is needed one can do:

\starttext

\def\foo{foo}
\def\ofo{ofo}
\def\oof{oof}

\def\XXX{ofo}

\ifcstok\XXX\foo
FOO
\orelse\ifcstok\XXX\ofo
OFO
\orelse\ifcstok\XXX\oof
OOF
\else
XXX
\fi

\def\XXX{\ofo}

\iftok{\XXX}{\foo}%
FOO
\orelse\iftok{\XXX}{\ofo}%
OFO
\orelse\iftok{\XXX}{\oof}%
OOF
\else
XXX
\fi

\ifcstok{\XXX}\foo
FOO
\orelse\ifcstok{\XXX}\ofo
OFO
\orelse\ifcstok\XXX}\oof
OOF
\else
XXX
\fi

\stoptext

watch the subtle differences. It all makes coding in tex primitives a 
bit more visual appealing and readable. Oone of the objectives of lmtx 
is that users can read the context code without pondering too much about 
the syntax or getting depressed by possibly obscure helper macros and 
expansion trickery.


Hans


-
  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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Wolfgang Schuster via ntg-context

Joey McCollum via ntg-context schrieb am 09.12.2021 um 15:08:
I believe \orelse might be what you want. It works with most \if... 
macros, and it avoids nesting of \doifelse constructs. Here's an 
example, which I use in conditionally removing preceding punctuation 
if any other keys are defined before a specific one in an assignment:


```
      % If any of the preceding keys was specified, then replace any 
preceding punctuation with a space
    % and typeset the number with its CSL abbreviation, followed by a 
comma

      \ifdefined\btxsbllocvol
\removeunwantedspaces\removepunctuation\btxspace
\orelse\ifdefined\btxsbllocno
\removeunwantedspaces\removepunctuation\btxspace
      \fi
\orelse\ifdefined\btxsbllocpt
      [...]
      \fi
```


The \fi at the end of each \orelse branch is wrong.

\ifdefined\btxsbllocvol
    ...
\orelse\ifdefined\btxsbllocno
    ...
\else
    ...
\fi

Wolfgang

___
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
___


Re: [NTG-context] xml processing: if elseif else / switch case

2021-12-09 Thread Joey McCollum via ntg-context
I believe \orelse might be what you want. It works with most \if... macros,
and it avoids nesting of \doifelse constructs. Here's an example, which I
use in conditionally removing preceding punctuation if any other keys are
defined before a specific one in an assignment:

```
  % If any of the preceding keys was specified, then replace any
preceding punctuation with a space
  % and typeset the number with its CSL abbreviation, followed by a
comma
  \ifdefined\btxsbllocvol
\removeunwantedspaces\removepunctuation\btxspace
  \orelse\ifdefined\btxsbllocno
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocpt
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocp
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocn
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocfig
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocop
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocbk
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocep
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocchap
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocv
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocfol
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocfrag
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocpl
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsblloccol
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocl
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocsv
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \orelse\ifdefined\btxsbllocsec
\removeunwantedspaces\removepunctuation\btxspace
  \fi
  \fi
```

Joey

On Thu, Dec 9, 2021, 3:19 AM Denis Maier via ntg-context 
wrote:

> Hi,
>
>
>
> I was wondering whether we have tests similar to «if-else if-else» or
> «switch case» in context’s xml processing. (And even in context more
> general...) I have found these doifelse tests, but elseif doesn’t seem to
> exist. Is that correct? If yes, could that be added? Of course, you can
> always just nest doifelse-constructs, but that will become ugly quickly.
> Being able to specify multiple branches would be handy.
>
>
>
> Best,
>
> Denis
>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Thangalin via ntg-context
Confirmed that the following worked:

   1. Run: rm -rf /tmp/luatex-cache/   (your cache directory location will
   differ)
   2. Edit ./tex/texmf-context/tex/context/base/mkiv/scrn-ref.lua
   3. Replace line 15 to assign the empty function as Hans indicated
   4. Save the file
   5. Run: ./bin/mtxrun --generate
   6. Run: ./tex/texmf-linux-64/bin/context --make

Typesetting XML succeeds again.
___
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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Pablo Rodriguez via ntg-context
On 12/1/21 2:03 PM, Denis Maier via ntg-context wrote:
> Sorry for spamming the list, but I was able to narrow it further down:
> [...]
> \setupinteraction
>   [state=start,
>openaction=FitWidth] % comment this out to make it work
> [...]
> Can anyone confirm this?

Hi Denis,

I can confirm the issue. I get the following error message:

registered function call [929]:
...ext/tex/texmf-context/tex/context/base/mkiv/scrn-ref.lua:31: attempt
to call a nil value (upvalue 'expandcurrent')
stack traceback:
...ext/tex/texmf-context/tex/context/base/mkiv/scrn-ref.lua:31: in
function <...ext/tex/texmf-context/tex/context/base/mkiv/scrn-ref.lua:27>
(...tail calls...)

I hope it helps,

Pablo
___
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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Hans Hagen via ntg-context

On 12/1/2021 2:03 PM, denis.ma...@unibe.ch wrote:

Sorry for spamming the list, but I was able to narrow it further down:

%
\setupinteraction
[
state=start,
openaction=FitWidth, % comment this out to make it work
]

\starttext

asdf

\stoptext
%

Can anyone confirm this?



-Ursprüngliche Nachricht-
Von: ntg-context  Im Auftrag von Denis Maier
via ntg-context
Gesendet: Mittwoch, 1. Dezember 2021 11:44
An: j.ha...@xs4all.nl; ntg-context@ntg.nl
Cc: Maier, Denis Christian (UB) 
Betreff: Re: [NTG-context] xml processing errors after latest upgrade

Ok, seems unrelated to XML.

This here shows the problem:


% no problems withouth setupinteraction
\setupinteraction [
state=start,
focus=standard,
openaction=FitWidth,
color=,
contrastcolor=,
style=,
]

\starttext

asdf

\stoptext


you can patch this in scrn-ref.lua (and remakle the format)

local expandcurrent = structures.references.expandcurrent or function() end



-
  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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Denis Maier via ntg-context
Sorry for spamming the list, but I was able to narrow it further down:

%
\setupinteraction 
[
state=start,
openaction=FitWidth, % comment this out to make it work
]

\starttext

asdf

\stoptext
%

Can anyone confirm this?


> -Ursprüngliche Nachricht-
> Von: ntg-context  Im Auftrag von Denis Maier
> via ntg-context
> Gesendet: Mittwoch, 1. Dezember 2021 11:44
> An: j.ha...@xs4all.nl; ntg-context@ntg.nl
> Cc: Maier, Denis Christian (UB) 
> Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> 
> Ok, seems unrelated to XML.
> 
> This here shows the problem:
> 
> 
> % no problems withouth setupinteraction
> \setupinteraction [
>   state=start,
>   focus=standard,
>   openaction=FitWidth,
>   color=,
>   contrastcolor=,
>   style=,
>   ]
> 
> \starttext
> 
> asdf
> 
> \stoptext
> 
> 
> Best,
> Denis
> 
> > -Ursprüngliche Nachricht-
> > Von: Hans Hagen 
> > Gesendet: Mittwoch, 1. Dezember 2021 10:52
> > An: mailing list for ConTeXt users 
> > Cc: Maier, Denis Christian (UB) 
> > Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> >
> > On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:
> >
> > > Not sure what is going wrong. Any hints how I can start debugging?
> > > Any ideas what could have caused that change?
> > >
> > > (Ok, let’s build a MWE..)
> > a mix of old / new files?
> >
> >
> > -
> >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
> __
> _
___
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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Denis Maier via ntg-context
Another problem. Maybe that's related?

Running the file with the --luatex flag gives me this error message:

tx-context | redirect luametatex -> luatex: luatex --luaonly 
"C:/context/tex/texmf-win64/bin/mtxrun.lua" --script mtx-context --luatex debug 
--redirected
mtxrun  | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'

Denis

> -Ursprüngliche Nachricht-
> Von: ntg-context  Im Auftrag von Denis Maier
> via ntg-context
> Gesendet: Mittwoch, 1. Dezember 2021 11:44
> An: j.ha...@xs4all.nl; ntg-context@ntg.nl
> Cc: Maier, Denis Christian (UB) 
> Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> 
> Ok, seems unrelated to XML.
> 
> This here shows the problem:
> 
> 
> % no problems withouth setupinteraction
> \setupinteraction [
>   state=start,
>   focus=standard,
>   openaction=FitWidth,
>   color=,
>   contrastcolor=,
>   style=,
>   ]
> 
> \starttext
> 
> asdf
> 
> \stoptext
> 
> 
> Best,
> Denis
> 
> > -Ursprüngliche Nachricht-
> > Von: Hans Hagen 
> > Gesendet: Mittwoch, 1. Dezember 2021 10:52
> > An: mailing list for ConTeXt users 
> > Cc: Maier, Denis Christian (UB) 
> > Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> >
> > On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:
> >
> > > Not sure what is going wrong. Any hints how I can start debugging?
> > > Any ideas what could have caused that change?
> > >
> > > (Ok, let’s build a MWE..)
> > a mix of old / new files?
> >
> >
> > -
> >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
> __
> _
___
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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Denis Maier via ntg-context
Ok, seems unrelated to XML.

This here shows the problem:


% no problems withouth setupinteraction
\setupinteraction [
state=start,
focus=standard,
openaction=FitWidth,
color=,
contrastcolor=,
style=,
]

\starttext

asdf

\stoptext


Best,
Denis

> -Ursprüngliche Nachricht-
> Von: Hans Hagen 
> Gesendet: Mittwoch, 1. Dezember 2021 10:52
> An: mailing list for ConTeXt users 
> Cc: Maier, Denis Christian (UB) 
> Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> 
> On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:
> 
> > Not sure what is going wrong. Any hints how I can start debugging? Any
> > ideas what could have caused that change?
> >
> > (Ok, let’s build a MWE..)
> a mix of old / new files?
> 
> 
> -
>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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Denis Maier via ntg-context
Still the same error.

> -Ursprüngliche Nachricht-
> Von: Maier, Denis Christian (UB)
> Gesendet: Mittwoch, 1. Dezember 2021 11:02
> An: 'Hans Hagen' ; 'mailing list for ConTeXt users'  cont...@ntg.nl>
> Betreff: AW: [NTG-context] xml processing errors after latest upgrade
> 
> Trying a fresh installation.
> 
> > -Ursprüngliche Nachricht-
> > Von: Maier, Denis Christian (UB)
> > Gesendet: Mittwoch, 1. Dezember 2021 10:59
> > An: 'Hans Hagen' ; mailing list for ConTeXt users
> > 
> > Betreff: AW: [NTG-context] xml processing errors after latest upgrade
> >
> > You mean a problem with the update?
> >
> > I've wiped the cache and ran
> > mtxrun --generate
> > context --make
> >
> > But, no change.
> >
> > Denis
> >
> > > -Ursprüngliche Nachricht-
> > > Von: Hans Hagen 
> > > Gesendet: Mittwoch, 1. Dezember 2021 10:52
> > > An: mailing list for ConTeXt users 
> > > Cc: Maier, Denis Christian (UB) 
> > > Betreff: Re: [NTG-context] xml processing errors after latest
> > > upgrade
> > >
> > > On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:
> > >
> > > > Not sure what is going wrong. Any hints how I can start debugging?
> > > > Any ideas what could have caused that change?
> > > >
> > > > (Ok, let’s build a MWE..)
> > > a mix of old / new files?
> > >
> > >
> > > -
> > >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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Denis Maier via ntg-context
Trying a fresh installation.

> -Ursprüngliche Nachricht-
> Von: Maier, Denis Christian (UB)
> Gesendet: Mittwoch, 1. Dezember 2021 10:59
> An: 'Hans Hagen' ; mailing list for ConTeXt users  cont...@ntg.nl>
> Betreff: AW: [NTG-context] xml processing errors after latest upgrade
> 
> You mean a problem with the update?
> 
> I've wiped the cache and ran
> mtxrun --generate
> context --make
> 
> But, no change.
> 
> Denis
> 
> > -Ursprüngliche Nachricht-
> > Von: Hans Hagen 
> > Gesendet: Mittwoch, 1. Dezember 2021 10:52
> > An: mailing list for ConTeXt users 
> > Cc: Maier, Denis Christian (UB) 
> > Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> >
> > On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:
> >
> > > Not sure what is going wrong. Any hints how I can start debugging?
> > > Any ideas what could have caused that change?
> > >
> > > (Ok, let’s build a MWE..)
> > a mix of old / new files?
> >
> >
> > -
> >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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Denis Maier via ntg-context
You mean a problem with the update?

I've wiped the cache and ran 
mtxrun --generate
context --make

But, no change.

Denis

> -Ursprüngliche Nachricht-
> Von: Hans Hagen 
> Gesendet: Mittwoch, 1. Dezember 2021 10:52
> An: mailing list for ConTeXt users 
> Cc: Maier, Denis Christian (UB) 
> Betreff: Re: [NTG-context] xml processing errors after latest upgrade
> 
> On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:
> 
> > Not sure what is going wrong. Any hints how I can start debugging? Any
> > ideas what could have caused that change?
> >
> > (Ok, let’s build a MWE..)
> a mix of old / new files?
> 
> 
> -
>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
___


Re: [NTG-context] xml processing errors after latest upgrade

2021-12-01 Thread Hans Hagen via ntg-context

On 12/1/2021 10:41 AM, Denis Maier via ntg-context wrote:

Not sure what is going wrong. Any hints how I can start debugging? Any 
ideas what could have caused that change?


(Ok, let’s build a MWE..)

a mix of old / new files?


-
  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
___


Re: [NTG-context] XML-processing: Error with hyphenatedurl

2021-10-27 Thread Hans Hagen via ntg-context

On 10/27/2021 5:37 PM, Denis Maier via ntg-context wrote:


Oh, actually that leads to a similar problem as in my original question where 
Wolfgang suggested using \expandUx: if the URL is broken across lines, the link 
content is also broken. Interestingly, the plain

\startxmlsetups xml:ext-link-var-var
\goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlflush{#1})]
\stopxmlsetups

seems to work now correctly.
it depends abit on what gets flushed, in those cases a low level flush 
has to be used


\xmltext
\xmltextonly
\xmlraw

to get the raw data .. depends on content

Hans

-
  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
___


Re: [NTG-context] XML-processing: Error with hyphenatedurl

2021-10-27 Thread Pablo Rodriguez via ntg-context
On 10/27/21 5:37 PM, Denis Maier via ntg-context wrote:
> [...]
> Oh, actually that leads to a similar problem as in my original
> question where Wolfgang suggested using \expandUx: if the URL is
> broken across lines, the link content is also broken. Interestingly,
> the plain>
> \startxmlsetups xml:ext-link-var-var
>   \goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlflush{#1})]
> \stopxmlsetups
>
> seems to work now correctly.

Sorry, it was the wrong order:

\expanded{\goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlflush{#1})]}

\xmlpure is for \hyphenatedurl, not for url.

But your plain \goto is what I use and I have been using it without
problems for long.

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
___


Re: [NTG-context] XML-processing: Error with hyphenatedurl

2021-10-27 Thread Denis Maier via ntg-context
> -Ursprüngliche Nachricht-
> Von: Maier, Denis Christian (UB)
> Gesendet: Mittwoch, 27. Oktober 2021 16:31
> An: 'mailing list for ConTeXt users' 
> Cc: Pablo Rodriguez 
> Betreff: AW: [NTG-context] XML-processing: Error with hyphenatedurl
> 
> > -Ursprüngliche Nachricht-
> > Von: ntg-context  Im Auftrag von Pablo
> > Rodriguez via ntg-context
> > Gesendet: Mittwoch, 27. Oktober 2021 15:43
> > An: Denis Maier via ntg-context 
> > Cc: Pablo Rodriguez 
> > Betreff: Re: [NTG-context] XML-processing: Error with hyphenatedurl
> >
> > On 10/27/21 3:03 PM, Denis Maier via ntg-context wrote:
> > > [...]
> > > I’ve receiving errors that seem to be related to hyphenatedurl. The
> > > problem is I cannot really reproduce it in a MWE. The example below
> > > works, but if I include the link in my real document, I’am getting
> > > this error message (copied from -error.log):
> > > [...]
> > > Two things seemed to make it work:
> > > 1. Remove the link.
> > > 2. Comment out \expandUx in this setup:
> >
> > Hi Denis,
> >
> > in my environments to typeset XML sources, I never need \expandUx, why
> > do you needit?
> 
> I've had a problem with special characters in URLs. Wolfgang suggested to use
> \expandUx: https://www.mail-archive.com/ntg-context@ntg.nl/msg95959.html
> 
> 
> >
> > Another approach (I don’t know whether this will work in your
> > real-world
> > document) might be using \xmlpure instead of \xmlflush as in:
> >
> >   \goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlpure{#1})]
> 
> That works. Thank  you.

Oh, actually that leads to a similar problem as in my original question where 
Wolfgang suggested using \expandUx: if the URL is broken across lines, the link 
content is also broken. Interestingly, the plain

\startxmlsetups xml:ext-link-var-var
\goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlflush{#1})]
\stopxmlsetups

seems to work now correctly.

Best,
Denis

%%%
\setuppapersize[A6]
\setupinteraction[state=start]

\startxmlsetups xml:test
\xmlsetsetup{#1}{*}{-}
\xmlsetsetup{#1}{article|ext-link|ext-link-var|ext-link-var-var}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:test}

\startxmlsetups xml:article
\starttext
\xmlflush{#1}
\stoptext
\stopxmlsetups

\startxmlsetups xml:ext-link
\begingroup
\expandUx 

\expanded{\goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlflush{#1})]}
\endgroup
\stopxmlsetups

\startxmlsetups xml:ext-link-var
\goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlpure{#1})]
\stopxmlsetups

\startxmlsetups xml:ext-link-var-var
\goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlflush{#1})]
\stopxmlsetups


\startbuffer[test]



asdfasdf asdkflöasj asdf
https://wiki.contextgarden.net/Main_Page

asdfasdf asdkflöasj asdf
https://wiki.contextgarden.net/Main_Page

asdfasdf asdkflöasj asdf
https://wiki.contextgarden.net/Main_Page

\stopbuffer

\xmlprocessbuffer{test}{test}{}
%%%




___
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
___


Re: [NTG-context] XML-processing: Error with hyphenatedurl

2021-10-27 Thread Denis Maier via ntg-context
> -Ursprüngliche Nachricht-
> Von: ntg-context  Im Auftrag von Pablo
> Rodriguez via ntg-context
> Gesendet: Mittwoch, 27. Oktober 2021 15:43
> An: Denis Maier via ntg-context 
> Cc: Pablo Rodriguez 
> Betreff: Re: [NTG-context] XML-processing: Error with hyphenatedurl
> 
> On 10/27/21 3:03 PM, Denis Maier via ntg-context wrote:
> > [...]
> > I’ve receiving errors that seem to be related to hyphenatedurl. The
> > problem is I cannot really reproduce it in a MWE. The example below
> > works, but if I include the link in my real document, I’am getting
> > this error message (copied from -error.log):
> > [...]
> > Two things seemed to make it work:
> > 1. Remove the link.
> > 2. Comment out \expandUx in this setup:
> 
> Hi Denis,
> 
> in my environments to typeset XML sources, I never need \expandUx, why do
> you needit?

I've had a problem with special characters in URLs. Wolfgang suggested to use 
\expandUx: https://www.mail-archive.com/ntg-context@ntg.nl/msg95959.html


> 
> Another approach (I don’t know whether this will work in your real-world
> document) might be using \xmlpure instead of \xmlflush as in:
> 
>   \goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlpure{#1})]

That works. Thank  you.

Denis
___
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
___


Re: [NTG-context] XML-processing: Error with hyphenatedurl

2021-10-27 Thread Pablo Rodriguez via ntg-context
On 10/27/21 3:03 PM, Denis Maier via ntg-context wrote:
> [...]
> I’ve receiving errors that seem to be related to hyphenatedurl. The
> problem is I cannot really reproduce it in a MWE. The example below
> works, but if I include the link in my real document, I’am getting this
> error message (copied from -error.log):
> [...]
> Two things seemed to make it work:
> 1. Remove the link.
> 2. Comment out \expandUx in this setup:

Hi Denis,

in my environments to typeset XML sources, I never need \expandUx, why
do you needit?

Another approach (I don’t know whether this will work in your real-world
document) might be using \xmlpure instead of \xmlflush as in:

  \goto{\hyphenatedurl{\xmlflush{#1}}}[url(\xmlpure{#1})]

The background for both commands can be found on
https://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#page=103.

I hope it helps,

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
___


Re: [NTG-context] xml processing in latest

2021-04-21 Thread Thomas A. Schmitz


On 4/21/21 10:34 AM, denis.ma...@ub.unibe.ch wrote:

Hi

What's the exact issue?



You're not using the latest version:

2021.04.20 18:45

Thomas
___
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
___


Re: [NTG-context] xml processing in latest

2021-04-21 Thread denis.maier
Ah, now I see
ConTeXt  ver: 2021.04.20 18:45 LMTX  fmt: 2021.4.21  int: english/english
gives me the attached result.

Denis

> -Ursprüngliche Nachricht-
> Von: Maier, Denis Christian (UB)
> Gesendet: Mittwoch, 21. April 2021 10:34
> An: ntg-context@ntg.nl
> Betreff: AW: [NTG-context] xml processing in latest
> 
> Hi
> 
> What's the exact issue?
> 
> I get the same results on my TeXLive version and on the latext lmtx:
> ConTeXt  ver: 2020.01.26 18:34 MKIV beta  fmt: 2020.10.2  int: english/english
> ConTeXt  ver: 2021.04.18 18:12 LMTX  fmt: 2021.4.20  int: english/english
> 
> And even with --luatex
> ConTeXt  ver: 2021.04.18 18:12 MKIV  fmt: 2021.4.21  int: english/english
> 
> Always the result as attached.
> 
> Denis
> 
> 
> > -Ursprüngliche Nachricht-
> > Von: ntg-context  Im Auftrag von Thomas
> A.
> > Schmitz
> > Gesendet: Mittwoch, 21. April 2021 08:45
> > An: ntg-context@ntg.nl
> > Betreff: [NTG-context] xml processing in latest
> >
> >
> > Hi all,
> >
> > the latest has some strange problems with xml processing. The example
> > below shows an issue with itemize. In my real file, I also get pages
> > that are filled only two thirds and rugged right instead of justified,
> > but I haven't been able to reproduce this in a MWE. Maybe this one can
> > give a start; I assume it's some fundamental typo somewhere.
> >
> > All best
> >
> > Thomas
> >
> > \startbuffer[test]
> > 
> >test
> > 
> > 
> > one
> > 
> > 
> > two
> > 
> > 
> > 
> > \stopbuffer
> >
> > \startxmlsetups xml:testsetups
> >  \xmlsetsetup{#1}{*}{-}
> > \xmlsetsetup{#1}{document|p|numbered|item}{xml:*}
> > \stopxmlsetups
> >
> > \xmlregistersetup{xml:testsetups}
> >
> > \startxmlsetups xml:document
> > \xmlflush{#1}
> > \stopxmlsetups
> >
> > \startxmlsetups xml:p
> > \xmlflush{#1} \par
> > \stopxmlsetups
> >
> > \startxmlsetups xml:numbered
> > \startitemize [n]
> > \xmlflush{#1}
> > \stopitemize
> > \stopxmlsetups
> >
> > \startxmlsetups xml:item
> > \startitem
> > \xmlflush{#1}
> > \stopitem
> > \stopxmlsetups
> >
> > \starttext
> > \xmlprocessbuffer{main}{test}{}
> > \stoptext
> >
> __
> > _
> > 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
> >
> __
> > _


test.pdf
Description: test.pdf
___
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
___


Re: [NTG-context] xml processing in latest

2021-04-21 Thread denis.maier
Hi

What's the exact issue? 

I get the same results on my TeXLive version and on the latext lmtx:
ConTeXt  ver: 2020.01.26 18:34 MKIV beta  fmt: 2020.10.2  int: english/english
ConTeXt  ver: 2021.04.18 18:12 LMTX  fmt: 2021.4.20  int: english/english

And even with --luatex
ConTeXt  ver: 2021.04.18 18:12 MKIV  fmt: 2021.4.21  int: english/english

Always the result as attached.

Denis


> -Ursprüngliche Nachricht-
> Von: ntg-context  Im Auftrag von Thomas A.
> Schmitz
> Gesendet: Mittwoch, 21. April 2021 08:45
> An: ntg-context@ntg.nl
> Betreff: [NTG-context] xml processing in latest
> 
> 
> Hi all,
> 
> the latest has some strange problems with xml processing. The example
> below shows an issue with itemize. In my real file, I also get pages that are
> filled only two thirds and rugged right instead of justified, but I haven't 
> been
> able to reproduce this in a MWE. Maybe this one can give a start; I assume 
> it's
> some fundamental typo somewhere.
> 
> All best
> 
> Thomas
> 
> \startbuffer[test]
> 
>test
>   
>   
>   one
>   
>   
>   two
>   
>   
> 
> \stopbuffer
> 
> \startxmlsetups xml:testsetups
>  \xmlsetsetup{#1}{*}{-}
>   \xmlsetsetup{#1}{document|p|numbered|item}{xml:*}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:testsetups}
> 
> \startxmlsetups xml:document
>   \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:p
>   \xmlflush{#1} \par
> \stopxmlsetups
> 
> \startxmlsetups xml:numbered
>   \startitemize [n]
>   \xmlflush{#1}
>   \stopitemize
> \stopxmlsetups
> 
> \startxmlsetups xml:item
>   \startitem
>   \xmlflush{#1}
>   \stopitem
> \stopxmlsetups
> 
> \starttext
>   \xmlprocessbuffer{main}{test}{}
> \stoptext
> __
> _
> 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
> __
> _


test.pdf
Description: test.pdf
___
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
___


Re: [NTG-context] XML/MathML namespace handling bug

2021-03-26 Thread Hans Hagen

On 3/26/2021 6:02 AM, Hugo Landau wrote:

in x-math.mkiv search for

\startxmlsetups mml:apply

and replace this bit:

 \edef\mmlapplyaction{\xmlfilter{#1}{/*/tag()}}
 \doifelsesetups {mml:apply:mml:\mmlapplyaction} {
 \xmlsetup{#1}{mml:apply:mml:\mmlapplyaction}
  } {
 \xmlsetup{#1}{mml:\mmlapplyaction}
  }

(btw, isn't content mathml more fun than presentation mathml?)

Works nicely. For  I also had to change this part from name() to
tag():

\startxmlsetups mml:relation
 \edef\mmlapplyaction{\xmlfilter{#1}{/*/tag()}}
 \MMLcreset 
\xmlsetup{#1}{mml:relation:\xmlattdef{#1}{align}{\MMLrelationalign}}
\stopxmlsetups

can you also check

\startxmlsetups mml:apply:inverse
\settrue\xmlinversefunction
\xmlsetup{#1}{mml:\xmlfilter{#1}{/mml:apply/*[2]/tag()}}
\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
___


Re: [NTG-context] XML/MathML namespace handling bug

2021-03-25 Thread Hugo Landau
> in x-math.mkiv search for
> 
>\startxmlsetups mml:apply
> 
> and replace this bit:
> 
> \edef\mmlapplyaction{\xmlfilter{#1}{/*/tag()}}
> \doifelsesetups {mml:apply:mml:\mmlapplyaction} {
> \xmlsetup{#1}{mml:apply:mml:\mmlapplyaction}
>  } {
> \xmlsetup{#1}{mml:\mmlapplyaction}
>  }
> 
> (btw, isn't content mathml more fun than presentation mathml?)
Works nicely. For  I also had to change this part from name() to
tag():

\startxmlsetups mml:relation
\edef\mmlapplyaction{\xmlfilter{#1}{/*/tag()}}
\MMLcreset 
\xmlsetup{#1}{mml:relation:\xmlattdef{#1}{align}{\MMLrelationalign}}
\stopxmlsetups
___
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
___


Re: [NTG-context] XML/MathML namespace handling bug

2021-03-20 Thread Hans Hagen

On 3/20/2021 10:52 PM, Hugo Landau wrote:

Thanks for ConTeXt, it is an amazing system.

The following test case demonstrates the bug.

   \usemodule[mathml]
   \starttext
   \xmlprocessdata{}{
   
   http://www.example.com/ns/foo; 
xmlns:m="http://www.w3.org/1998/Math/MathML;>
   
 ab
   
   
 ab
   
   
   }{}
   \stoptext

No output is produced. This has been verified with live.contextgarden.net.

In order for output to be produced,  must be changed to  and
 must be changed to , but these are in the wrong
namespace in this context. In other words, this bug applies to the keyword
element in an apply element.

in x-math.mkiv search for

   \startxmlsetups mml:apply

and replace this bit:

\edef\mmlapplyaction{\xmlfilter{#1}{/*/tag()}}
\doifelsesetups {mml:apply:mml:\mmlapplyaction} {
\xmlsetup{#1}{mml:apply:mml:\mmlapplyaction}
 } {
\xmlsetup{#1}{mml:\mmlapplyaction}
 }

(btw, isn't content mathml more fun than presentation mathml?)

Hans

-
  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
___


Re: [NTG-context] xml bookmarks + chapter no. in header

2020-10-07 Thread Pablo Rodriguez
On 10/7/20 5:06 PM, Tomas Hala wrote:
> Hi,
>
> I tried
> \setuphead[section][expansion=yes]
> with no effect before I wrote my question to the list here.
>
> With the \setuphead, the .tuc file still contains macro names instead of the 
> text:
>  ["title"]="\\expanded \\name ",
> whereas without it only:
>  ["title"]=" \\name ",
>
> So is there any way how to solve it?

Sorry, Tomáš, for not giving a reply to you.

I noticed that your case didn’t work with my approach.

But the problem is different in that case, I think (Wolfgang may correct
me [or explain this better]).

Expansion in list and bookmarks seems to be different:

\setupinteraction[state=start]
\setupinteractionscreen[option=bookmarks]
\placebookmarks[section][section]
\setuphead[title][page=no]
\starttext

%~ \placelist[section] % this doesn’t work
\def\name{aa}
\placelist[section]
 \startsection[title=\name, list=\expanded\name] \stopsection
\def\name{bb}
\startsection[title=\name, list=\expanded\name] \stopsection
\completecontent

\stoptext

I’m afraid I don’t know why.

Sorry not helping,

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
___


Re: [NTG-context] xml bookmarks + chapter no. in header

2020-10-07 Thread Tomas Hala
Hi,

I tried 
\setuphead[section][expansion=yes]
with no effect before I wrote my question to the list here.

With the \setuphead, the .tuc file still contains macro names instead of the 
text:
 ["title"]="\\expanded \\name ",
whereas without it only:
 ["title"]=" \\name ",

So is there any way how to solve it?

Best wishes,

Tomáš 

Wed, Oct 07, 2020 ve 04:36:48PM +0200 Jano Kula napsal(a):
#On Wed, 7 Oct 2020 at 15:04, Pablo Rodriguez <[1]oi...@gmx.es> wrote:
# 
#  On 10/7/20 1:28 PM, Jano Kula wrote:
#  > Hello to everybody!
#  >
#  > I have a similar problem as Tomas two days ago. When inserting
#  bookmarks
#  > from XML the reference to the node is stored in TUC file
#  >
#  >   ["titledata"]={
#  >    ["label"]="section",
#  >    ["title"]="\\xmlatt {xml:name::4}{title}"
#  >
#  > and this reference ends up in bookmarks. Any advice on how to change
#  it
#  > to text in bookmarks?
# 
#  Hi Jano,
# 
#  I think I had a similar problem.
# 
#  You may try:
# 
#    \setuphead
#      [section]
#      [expansion=yes]
# 
#  As I reported before "expansion=xml" was problematic for me (but it may
#  work for you, if "expansion=yes" doesn’t).
# 
#  Just in case it helps,
# 
#  Pablo
#  [2]http://www.ousia.tk
# 
#Hi Pablo,
#That's likely the problem of Tomas, too: when and how to do the expansion
#(his use case is different). Thank you, problem solved and [3]wikified.
#Jano
# 
# References
# 
#Visible links
#1. mailto:oi...@gmx.es
#2. http://www.ousia.tk/
#3. https://wiki.contextgarden.net/Interaction#XML_source

# 
___
# 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
# 
___


 Tomáš Hála

Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky
Zemědělská 1, CZ-613 00 Brno,  tel. +420 545 13 22 28

http://akela.mendelu.cz/~thala
___
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
___


Re: [NTG-context] xml bookmarks

2020-10-07 Thread Jano Kula
On Wed, 7 Oct 2020 at 15:04, Pablo Rodriguez  wrote:

> On 10/7/20 1:28 PM, Jano Kula wrote:
> > Hello to everybody!
> >
> > I have a similar problem as Tomas two days ago. When inserting bookmarks
> > from XML the reference to the node is stored in TUC file
> >
> >   ["titledata"]={
> >["label"]="section",
> >["title"]="\\xmlatt {xml:name::4}{title}"
> >
> > and this reference ends up in bookmarks. Any advice on how to change it
> > to text in bookmarks?
>
> Hi Jano,
>
> I think I had a similar problem.
>
> You may try:
>
>   \setuphead
> [section]
> [expansion=yes]
>
> As I reported before "expansion=xml" was problematic for me (but it may
> work for you, if "expansion=yes" doesn’t).
>
> Just in case it helps,
>
> Pablo
> http://www.ousia.tk
>

Hi Pablo,

That's likely the problem of Tomas, too: when and how to do the expansion
(his use case is different). Thank you, problem solved and wikified
.

Jano
___
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
___


Re: [NTG-context] xml bookmarks

2020-10-07 Thread Pablo Rodriguez
On 10/7/20 1:28 PM, Jano Kula wrote:
> Hello to everybody!
>
> I have a similar problem as Tomas two days ago. When inserting bookmarks
> from XML the reference to the node is stored in TUC file
>
>   ["titledata"]={
>    ["label"]="section",
>    ["title"]="\\xmlatt {xml:name::4}{title}"
>
> and this reference ends up in bookmarks. Any advice on how to change it
> to text in bookmarks?

Hi Jano,

I think I had a similar problem.

You may try:

  \setuphead
[section]
[expansion=yes]

As I reported before "expansion=xml" was problematic for me (but it may
work for you, if "expansion=yes" doesn’t).

Just in case it helps,

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
___


Re: [NTG-context] XML to ConTeXt: converting date attribute from ISO date

2020-03-11 Thread Hans Hagen

On 3/11/2020 4:54 PM, Axel Kielhorn wrote:

Hello Hans and mailing list!

Thank you so much.

With this example and the help I received earlier from Massi,
I’ve been able to write my first finalizer today.

It is amazing how powerful luatex is.


indeed (and luametatex is supposed to be even bit more powerful)


My project needs some cleanup and documentation but I hope to put it on GitHub 
soon.
After that I will try to put a minimal version into the wiki.

that would be nice. thanks

Hans

-
  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
___


Re: [NTG-context] XML to ConTeXt: converting date attribute from ISO date

2020-03-11 Thread Axel Kielhorn
Hello Hans and mailing list!

Thank you so much.

With this example and the help I received earlier from Massi, 
I’ve been able to write my first finalizer today.

It is amazing how powerful luatex is.

My project needs some cleanup and documentation but I hope to put it on GitHub 
soon.
After that I will try to put a minimal version into the wiki.

Greetings Axel
___
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
___


Re: [NTG-context] XML to ConTeXt: converting date attribute from ISO date

2020-03-11 Thread Axel Kielhorn


> Am 11.03.2020 um 15:19 schrieb Hans Hagen :
> 
> On 3/11/2020 3:12 PM, Axel Kielhorn wrote:
>>> Am 11.03.2020 um 15:01 schrieb Hans Hagen :
>>> 
>>> On 3/11/2020 2:14 PM, Axel Kielhorn wrote:
 
 Had to change it to:
 \startluacode
function xml.finalizers.tex.MyDate(e,what,how)
local ee = e[1].at[what]
local t = (string.split(ee,"-"))
context.date(
{ y = t[1], m = t[2], d = t[3] },
{ how }
)
end
 \stopluacode
>>> You mean the () around the split? weird. Anyway, there's also a time 
>>> splitter (dedicated to Alan who needed one):
>> No, sorry that’s an artifact from testing.
>> I had to assign:
>> local ee = e[1].at[what]
>> and
>> string.split(ee,"-")
>> in two steps while the original had
>> local t = string.split(e[1].at[what],"-")
> still strange because it's one value, if it were multiple you could do

This is strange.
Now it works.

Earlier I had context.date complaining that it got a table and not a string.
That’s why I took the t = assignment apart into pieces.

Now I copied the code from the original reply and it works.

Sorry for the noise.

Axel


___
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
___


Re: [NTG-context] XML to ConTeXt: converting date attribute from ISO date

2020-03-11 Thread Hans Hagen

On 3/11/2020 2:14 PM, Axel Kielhorn wrote:




Am 15.08.2018 um 14:04 schrieb Hans Hagen :

On 8/15/2018 12:27 PM, Mike O'Connor wrote:

G’Day,
Having a first go at converting TEI XML to ConTeXt.
Steep learning curve, but easier (for me) than XSLT, and first results were 
amazing.  Using http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf as a 
guide.
Currently stuck on converting an ISO format date (eg. 1908-01-10) into 
something more readable (eg. 10 January 1908) in the output.  I presume I 
should create a function (?luacode) that can take any ISO value and output the 
readable form.  The following works but seems to me inefficient.
Grateful for any pointers.
Mike
Here is my MWE:
\startbuffer[demo]

 
 
 
 
 10.I.08
 
 
19 Mar '08
 
 
 
 

\stopbuffer
\startxmlsetups xml:initialize
\xmlsetsetup{#1}{date}{xml:date}
\stopxmlsetups
\xmlregistersetup{xml:initialize}
\startxmlsetups xml:date
\xmldoifelse {#1}{.[@type='divDate']} {
\def\docdate{\ctxlua{
local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4)
local tmonth = string.sub('\xmlatt{#1}{when-iso}',6,7)
local tday = string.sub('\xmlatt{#1}{when-iso}',9,10)
context.date{d = tday, m = tmonth, y = tyear}
}}
\docdate[day,month,year] = Document Date \par
 } {
\def\docdate{\ctxlua{
local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4)
local tmonth = string.sub('\xmlatt{#1}{when-iso}',6,7)
local tday = string.sub('\xmlatt{#1}{when-iso}',9,10)
context.date{d = tday, m = tmonth, y = tyear}
}}
\docdate[day,month,year] = Event Date\par
}
\stopxmlsetups
\starttext
\xmlprocessbuffer{main}{demo}{}
\stoptext

Can be wikified ...

\startluacode
function xml.finalizers.tex.MyDate(e,what,how)
local t = string.split(e[1].at[what],"-")
context.date(
{ y = t[1], m = t[2], d = t[3] },
{ how }
)
end
\stopluacode

\startxmlsetups xml:date

\xmldoifelse {#1}{.[@type='divDate']} {
\xmlfilter{#1}{./MyDate("when-iso","day,month,year")}\
Document Date \par
} {
\xmlfilter{#1}{./MyDate("when-iso","day,month,year")}\
Event Date\par

}
\stopxmlsetups


I couldn’t get this to work.
Had to change it to:

\startluacode
function xml.finalizers.tex.MyDate(e,what,how)
local ee = e[1].at[what]
local t = (string.split(ee,"-"))
context.date(
{ y = t[1], m = t[2], d = t[3] },
{ how }
)
end
\stopluacode
You mean the () around the split? weird. Anyway, there's also a time 
splitter (dedicated to Alan who needed one):


print(os.time(utilities.parsers.totime("2019-03-05 12:12:12")))
print(os.time(utilities.parsers.totime("2019/03/05 12:12:12")))
print(os.time(utilities.parsers.totime("05-03-2019 12:12:12")))
print(os.time(utilities.parsers.totime("05/03/2019 12:12:12")))

inspect(utilities.parsers.totime("2019-03-05 12:12:12"))
inspect(utilities.parsers.totime("2019/03/05 12:12:12"))
inspect(utilities.parsers.totime("05-03-2019 12:12:12"))
inspect(utilities.parsers.totime("05/03/2019 12:12:12"))


-
  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
___


Re: [NTG-context] XML to ConTeXt: converting date attribute from ISO date

2020-03-11 Thread Axel Kielhorn


> Am 15.08.2018 um 14:04 schrieb Hans Hagen :
> 
> On 8/15/2018 12:27 PM, Mike O'Connor wrote:
>> G’Day,
>> Having a first go at converting TEI XML to ConTeXt.
>> Steep learning curve, but easier (for me) than XSLT, and first results were 
>> amazing.  Using http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf as a 
>> guide.
>> Currently stuck on converting an ISO format date (eg. 1908-01-10) into 
>> something more readable (eg. 10 January 1908) in the output.  I presume I 
>> should create a function (?luacode) that can take any ISO value and output 
>> the readable form.  The following works but seems to me inefficient.
>> Grateful for any pointers.
>> Mike
>> Here is my MWE:
>> \startbuffer[demo]
>> 
>> 
>> 
>> 
>> 
>> 10.I.08
>> 
>> 
>> 19 Mar '08
>> 
>> 
>> 
>> 
>> 
>> \stopbuffer
>> \startxmlsetups xml:initialize
>> \xmlsetsetup{#1}{date}{xml:date}
>> \stopxmlsetups
>> \xmlregistersetup{xml:initialize}
>> \startxmlsetups xml:date
>> \xmldoifelse {#1}{.[@type='divDate']} {
>> \def\docdate{\ctxlua{
>> local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4)
>> local tmonth = string.sub('\xmlatt{#1}{when-iso}',6,7)
>> local tday = string.sub('\xmlatt{#1}{when-iso}',9,10)
>> context.date{d = tday, m = tmonth, y = tyear}
>> }}
>> \docdate[day,month,year] = Document Date \par
>> } {
>> \def\docdate{\ctxlua{
>> local tyear = string.sub('\xmlatt{#1}{when-iso}',1,4)
>> local tmonth = string.sub('\xmlatt{#1}{when-iso}',6,7)
>> local tday = string.sub('\xmlatt{#1}{when-iso}',9,10)
>> context.date{d = tday, m = tmonth, y = tyear}
>> }}
>> \docdate[day,month,year] = Event Date\par
>> }
>> \stopxmlsetups
>> \starttext
>> \xmlprocessbuffer{main}{demo}{}
>> \stoptext
> Can be wikified ...
> 
> \startluacode
>function xml.finalizers.tex.MyDate(e,what,how)
>local t = string.split(e[1].at[what],"-")
>context.date(
>{ y = t[1], m = t[2], d = t[3] },
>{ how }
>)
>end
> \stopluacode
> 
> \startxmlsetups xml:date
> 
>   \xmldoifelse {#1}{.[@type='divDate']} {
>\xmlfilter{#1}{./MyDate("when-iso","day,month,year")}\
>   Document Date \par
>} {
>\xmlfilter{#1}{./MyDate("when-iso","day,month,year")}\
>Event Date\par
> 
>   }
> \stopxmlsetups

I couldn’t get this to work.
Had to change it to:

\startluacode
   function xml.finalizers.tex.MyDate(e,what,how)
   local ee = e[1].at[what]
   local t = (string.split(ee,"-"))
   context.date(
   { y = t[1], m = t[2], d = t[3] },
   { how }
   ) 
   end
\stopluacode

mtx-context | ConTeXt Process Management 1.03
mtx-context |
mtx-context | main context file: /Volumes/Macintosh 
HD/usr/local/texlive/context-109/tex/texmf-context/tex/context/base/mkiv/context.mkiv
mtx-context | current version: 2020.01.30 14:13
mtx-context | main context file: /Volumes/Macintosh 
HD/usr/local/texlive/context-109/tex/texmf-context/tex/context/base/mkiv/context.mkxl
mtx-context | current version: 2020.01.30 14:13

Greetings Axel

___
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
___


Re: [NTG-context] xml differences between old context and lmtx

2019-12-27 Thread Jan U. Hasecke
Am 27.12.19 um 14:03 schrieb Hans Hagen:
> On 12/26/2019 1:19 PM, Jan U. Hasecke wrote:
>> Hi all,
>>
>> are there any documented differences between the xml features of normal
>> context and lmtx?
>>
>> In a fun project I compile xml sources from www.deutschestextarchiv.de
>> to pdf via context using xmlsetups which kinda works with normal context
>> current version: 2019.08.09 18:29
>>
>> With lmtx current version: 2019.12.12 01:08 I don't get a usable result.
>>
>> And there is a change in file naming I discovered.
>>
>> Files from the deutschestextarchiv have names like
>> marx_kapital01_1867.TEI-P5.xml
>>
>> lmtx skips the TEI-P5 part
>>
>> Any hints how I can adjust my xmlsetups?
> how do you load the file

With the --environment switch:

context --environment=tei-style.tex marx_kapital01_1867.TEI-P5.xml

juh
___
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
___


Re: [NTG-context] xml differences between old context and lmtx

2019-12-27 Thread Hans Hagen

On 12/26/2019 1:19 PM, Jan U. Hasecke wrote:

Hi all,

are there any documented differences between the xml features of normal
context and lmtx?

In a fun project I compile xml sources from www.deutschestextarchiv.de
to pdf via context using xmlsetups which kinda works with normal context
current version: 2019.08.09 18:29

With lmtx current version: 2019.12.12 01:08 I don't get a usable result.

And there is a change in file naming I discovered.

Files from the deutschestextarchiv have names like
marx_kapital01_1867.TEI-P5.xml

lmtx skips the TEI-P5 part

Any hints how I can adjust my xmlsetups?

how do you load the file

-
  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
___


Re: [NTG-context] XML/HTML output of Math

2019-08-09 Thread Atsuhito Kohda
Hi all,

I will attach a screenshot of firefox on Ubuntu 10.04 but I'm not familiar
with Gmail so I'm uncertain if it goes well or not.

Thanks for your help.
Best regards,
Atsuhito Kohda

___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] XML/HTML output of Math

2019-08-09 Thread Hans Hagen

On 8/8/2019 9:41 AM, Taco Hoekwater wrote:


In case display math mode, we get very weird output of "\int_a^b”.


ConTeXt outputs b_a^\int in display mode; the order of the objects
inside the generated  is wrong, which is clearly a bug.
And it seems to do this for all large operators.

i'll look into it

Hans


-
  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
___


Re: [NTG-context] XML/HTML output of Math

2019-08-09 Thread Taco Hoekwater
Hi,

> On 9 Aug 2019, at 07:35, Atsuhito Kohda  wrote:
> 
> Dear Taco, thanks for your reply.
> 
> > I opened the xhtml with firefox and the only problem I see
> > is the ignored \displaystyle (which is why the integral looks small).
> > Inline looks fine otherwise, no interchanging of limits.
> 
> Hmm, I use firefox 68.0.1 of Ubuntu 19.04 and firefox 60.8.0
> of Debian/unstable.  I see the interchanging of limits with
> both firefoxes.  BTW, it seems Chromium doesn't support MathML.
> If any Linux users could test the xhtml with firefox (or any browsers)
> I believe it would help us much.

My firefox is 68.0.1 on MacOS. Small (ugly) screenshot attached.

___
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
___


Re: [NTG-context] XML/HTML output of Math

2019-08-08 Thread Atsuhito Kohda
Dear Taco, thanks for your reply.

> I opened the xhtml with firefox and the only problem I see
> is the ignored \displaystyle (which is why the integral looks small).
> Inline looks fine otherwise, no interchanging of limits.

Hmm, I use firefox 68.0.1 of Ubuntu 19.04 and firefox 60.8.0
of Debian/unstable.  I see the interchanging of limits with
both firefoxes.  BTW, it seems Chromium doesn't support MathML.
If any Linux users could test the xhtml with firefox (or any browsers)
I believe it would help us much.

> Well, as fine as it can be in firefox, which is pretty bad.

I'm not sure if I understand you correctly but I think MathJax
might be much better than MathML.

> ConTeXt outputs b_a^\int in display mode; the order of the objects
> inside the generated  is wrong, which is clearly a bug.
> And it seems to do this for all large operators.

I see.

> I think this somehow triggered by the nested mode switch (\text{\math{}})
in the \vsym.
> If I change that definition to the more simple:

>   \define[1]\vsym{{\textstyle\bi #1}}

> it works ok. Whether that helps you ...

It helps me to some extent but with the original definition, we can
use \vI in both math mode (\math{\vI}) and text mode like "vector \vI".
So if ConTeXt could convert the nested mode switch correctly
it would be very nice.

Thanks for your info.
Best regards,
Atsuhito Kohda



>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] XML/HTML output of Math

2019-08-08 Thread Taco Hoekwater
Hi,

> On 8 Aug 2019, at 01:06, Atsuhito Kohda  wrote:
> 
> Hi all,
> I used to compile a beamer file with LuaLaTeX to generate a PDF
> for presentation then convert the beamer file to XHTML with LaTeXML
> for Web page.
> Recently I begin to use ConTeXt so I try to get a PDF for presentation
> and also XML/HTML output from a single ConTeXt file.
> I have a few questions about XML/HTML output of Math.
> 
> 1. In case inline math mode with \displaystyle, we get wrong output
> of "\int_a^b"; lower limit and upper limit are interchanged 
> and further "b" is a bit larger and an integral symbol is rather small.
> (It looks "\displaystyle" is not effective, e.g see "\frac”.)

I opened the xhtml with firefox and the only problem I see
is the ignored \displaystyle (which is why the integral looks small). 
Inline looks fine otherwise, no interchanging of limits.

Well, as fine as it can be in firefox, which is pretty bad.

> In case display math mode, we get very weird output of "\int_a^b”.

ConTeXt outputs b_a^\int in display mode; the order of the objects
inside the generated  is wrong, which is clearly a bug.
And it seems to do this for all large operators.

> 
> 2. \math{\Vmatrix{\vI, \vj, \vk; a_{1}, a_{2}, a_{3}; b_{1}, b_{2}, b_{3}}}
> \vI, \vj, \vk are disappeared in xml/html output.  What happend?

I think this somehow triggered by the nested mode switch (\text{\math{}}) in 
the \vsym. 
If I change that definition to the more simple:

  \define[1]\vsym{{\textstyle\bi #1}}

it works ok. Whether that helps you ...

Best wishes,
Taco

___
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
___


Re: [NTG-context] XML in latest betas (MkIV & LMTX)

2019-06-02 Thread Hans Hagen

On 6/2/2019 3:07 PM, Pablo Rodriguez wrote:


Font expansion (as reported in
https://mailman.ntg.nl/pipermail/ntg-context/2019/095175.html).


font expansion is always slower (but i admit that i never use it)

Hans

-
  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
___


Re: [NTG-context] XML in latest betas (MkIV & LMTX)

2019-06-02 Thread Pablo Rodriguez
On 6/2/19 2:12 PM, Hans Hagen wrote:
> On 6/2/2019 1:17 PM, Pablo Rodriguez wrote:
>> [...]
>> Compiling exactly the same XML sources (a book on ConTeXt in Spanish),
>> MkIV needs 40s and LMTX more than 52s.
>
> Hm. Is that the first time you compare a MKIV runs with an LMTX run for
> that document? I assume that you time multiple runs.

No, it isn’t the first time I compare and I time multiple runs.

>> This is the first time I get such a difference in compilation times.
>
> On the average LMTX should be faster than MKIV (and definitely not 20%
> slower). I assume it's regular luatex?

Sorry, this was my fault. I thought I was running luatex and it was
luajittex.

MkIV times with luatex are 51.x seconds, which is a tiny bit faster than
LMTX (52.x seconds). But this is perfectly normal.

>> I’m afraid I can’t be sure that output is the same, since different
>> spacing gives different page numbers.
>
> Not sure where that comes from. There are no fundamental changes wrr
> spacing.

Font expansion (as reported in
https://mailman.ntg.nl/pipermail/ntg-context/2019/095175.html).

>> I wonder whether this might be an issue.
> Hard to say without a MWE that exposes the same

Sorry for the noise,

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
___


Re: [NTG-context] XML in latest betas (MkIV & LMTX)

2019-06-02 Thread Hans Hagen

On 6/2/2019 1:17 PM, Pablo Rodriguez wrote:

Dear list,

I have just installed latest betas for both MkIV and LMTX.

Compiling exactly the same XML sources (a book on ConTeXt in Spanish),
MkIV needs 40s and LMTX more than 52s.


Hm. Is that the first time you compare a MKIV runs with an LMTX run for 
that document? I assume that you time multiple runs.



This is the first time I get such a difference in compilation times.


On the average LMTX should be faster than MKIV (and definitely not 20% 
slower). I assume it's regular luatex?



I’m afraid I can’t be sure that output is the same, since different
spacing gives different page numbers.


Not sure where that comes from. There are no fundamental changes wrr 
spacing.



I wonder whether this might be an issue.

Hard to say without a MWE that exposes the same

-
  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
___


Re: [NTG-context] XML export: basic questions

2019-05-22 Thread Hans Hagen

On 5/22/2019 10:30 PM, Procházka Lukáš Ing. wrote:

Hello,

suppose having "Main.mkiv":


\setupbackend[export=yes]

\starttext
   \startsection[title={Sec},MyPar=MyVal]
     \input knuth
   \stopsection
\stoptext


Some questions concerning XML export:

1. Normally, with \setupbackend[export=yes], Ctx creates "Main-export" 
directory containing (among others) Main-raw.xml, and Main-tag.xhtml and 
some subdirs.


no, because then we also need to check for files with that name already 
present etc etc


Is there a way to tell Ctx to produce just one XML file with a 
prescribed name which wouldn't be placed in any subdir?
In my case - to produce "Main.xml" (instead of 
"Main-export/Main-raw.xml"), other files to be omitted?


no, because they also server as check


2. Is there a way to export user parameters used in \section?

In my case: \startsection[title={Sec},MyPar=MyVal] uses user parameter 
"MyPar" with value "MyVal", but "MyPar" is not transmitted into XML;

the goal is to have
 
which would allow some filtering when reprocessing that XML.


there are soem options to pass properties (probably also demonstrated in 
examples)



- Or is there another way, like enclosing into a user tag:

   \starttag[MyTag]
     \startsection[title={Sec},MyPar=MyVal]
   \input knuth
     \stopsection
   \stoptag


indeed you can define your own tags


which would export into:

 
   MyPar="MyVal">

   ...
   
     
as it is impossible to fulfil every possible scneario the export is just 
that ... an export ... one can always postprocess the xml


Hans

-
  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
___


Re: [NTG-context] XML roundtripping

2019-05-16 Thread Denis Maier
Ok. Have tried it. It seems to work on line 2.

Where can I find documentation about these ctx files?

Denis Maier  schrieb am Do., 16. Mai 2019, 12:27:

> 
>>
>
> Just after the xml declaration? Like on line 2?
>
>
>>
>> with "somefile.ctx" being:
>>
>> 
>>
>> 
>>  My very special style
>>  
>>  
>>  
>>  
>>  
>>  whatever.tex
>>  
>>  
>> 
>>
>
___
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
___


Re: [NTG-context] XML roundtripping

2019-05-16 Thread Hans Hagen

On 5/15/2019 10:31 PM, Denis Maier wrote:



Hans Hagen mailto:j.ha...@xs4all.nl>> schrieb am 
Mi., 15. Mai 2019, 18:32:


On 5/15/2019 4:35 PM, Denis Maier wrote:
 > Our workflow is not settled yet; we're still discussing options. All
 > depends upon what is possible ...
 >
 > That being said, for the purpose of displaying the articles
online we'll
 > need every article in a separate XML file. The question is if and
how we
 > will produce a PDF version containing a whole volume (we'll probably
 > need one PDF for the whole volume and also PDFs for each article).
 >
 > One option would be:
 > - merge the articles into a single XML,
 > - typeset from there
 > - split the PDF
 > (Hence my question here,
 > https://mailman.ntg.nl/pipermail/ntg-context/2019/095011.html).

you can create a master xml file with includes and process the lots in
one go ... this is quite convenient when you assemble for instance
books
from chapters that are split into sections ... you can make a xml file
per chapter that includes the sections and then a book file that loads
them all ... files can have a processing instruction telling what styel
to load and you can run individual files or assemblies ... all the
stuff
needed to do that is there (and probably also documented someplace)


Ok. Sounds good. How can I call the style in the xml files? I know that 
I can process a file with \xmlprocessfile or call it from the command 
line with --env=, and in a normal tex-file I could obviously use 
\environment for this,  but how does this work with xml?





with "somefile.ctx" being:




My very special style





whatever.tex








anyway, you can always save '\lastpage' during a run ... or you can
have
some shared lua file with chapters/pagenumbers that gets updated by the
current run

all this is workflow dependent but all can be done without too much
hassle

(fwiw: we have some cases where for one projects hundreds of xml files
get merged runtime and then processed ... the overhead is
neglectable to
the run)

 > Another option could be:
 > - Typeset each article individually.
 > - Get the last page number => in the next article, set the first
page
 > number to this + 1
 > (So, we do not necessarily need to write the page numbers back to
the
 > XML, but we'll somehow need to pass the page number to the next
article
 > in the chain.)
 >
 >
 > Am Mi., 15. Mai 2019 um 14:46 Uhr schrieb Hans Hagen
mailto:j.ha...@xs4all.nl>
 > >>:
 >
 >     On 5/15/2019 12:57 PM, Denis Maier wrote:
 >      > Hmm, getting the page number back from the tuc file sound
 >     feasible. I'll
 >      > have to look into this.
 >      >
 >      > But how would I write the information back to the XML? Is this
 >     explained
 >      > somewhere?
 >     all depends on the workflow ... why does it need to be
written back?
 >
 >
 >     -
 >                                                 Hans Hagen |
PRAGMA ADE
 >                     Ridderstraat 27 | 8061 GH Hasselt | The
Netherlands
 >              tel: 038 477 53 69 | www.pragma-ade.nl

 >      | www.pragma-pod.nl

 >     
 >     -
 >


-- 


-
                                            Hans Hagen | PRAGMA ADE
                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
         tel: 038 477 53 69 | www.pragma-ade.nl
 | www.pragma-pod.nl

-




--

-
  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

Re: [NTG-context] XML roundtripping

2019-05-15 Thread Denis Maier
Hans Hagen  schrieb am Mi., 15. Mai 2019, 18:32:

> On 5/15/2019 4:35 PM, Denis Maier wrote:
> > Our workflow is not settled yet; we're still discussing options. All
> > depends upon what is possible ...
> >
> > That being said, for the purpose of displaying the articles online we'll
> > need every article in a separate XML file. The question is if and how we
> > will produce a PDF version containing a whole volume (we'll probably
> > need one PDF for the whole volume and also PDFs for each article).
> >
> > One option would be:
> > - merge the articles into a single XML,
> > - typeset from there
> > - split the PDF
> > (Hence my question here,
> > https://mailman.ntg.nl/pipermail/ntg-context/2019/095011.html).
>
> you can create a master xml file with includes and process the lots in
> one go ... this is quite convenient when you assemble for instance books
> from chapters that are split into sections ... you can make a xml file
> per chapter that includes the sections and then a book file that loads
> them all ... files can have a processing instruction telling what styel
> to load and you can run individual files or assemblies ... all the stuff
> needed to do that is there (and probably also documented someplace)
>

Ok. Sounds good. How can I call the style in the xml files? I know that I
can process a file with \xmlprocessfile or call it from the command line
with --env=, and in a normal tex-file I could obviously use \environment
for this,  but how does this work with xml?



> anyway, you can always save '\lastpage' during a run ... or you can have
> some shared lua file with chapters/pagenumbers that gets updated by the
> current run
>
> all this is workflow dependent but all can be done without too much hassle
>
> (fwiw: we have some cases where for one projects hundreds of xml files
> get merged runtime and then processed ... the overhead is neglectable to
> the run)
>
> > Another option could be:
> > - Typeset each article individually.
> > - Get the last page number => in the next article, set the first page
> > number to this + 1
> > (So, we do not necessarily need to write the page numbers back to the
> > XML, but we'll somehow need to pass the page number to the next article
> > in the chain.)
> >
> >
> > Am Mi., 15. Mai 2019 um 14:46 Uhr schrieb Hans Hagen  > >:
> >
> > On 5/15/2019 12:57 PM, Denis Maier wrote:
> >  > Hmm, getting the page number back from the tuc file sound
> > feasible. I'll
> >  > have to look into this.
> >  >
> >  > But how would I write the information back to the XML? Is this
> > explained
> >  > somewhere?
> > all depends on the workflow ... why does it need to be written back?
> >
> >
> > -
> > Hans Hagen | PRAGMA ADE
> > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> >  tel: 038 477 53 69 | www.pragma-ade.nl
> >  | www.pragma-pod.nl
> > 
> > -
> >
>
>
> --
>
> -
>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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread nyssus

On 15/05/2019 15:35, Denis Maier wrote:
> Another option could be:
> - Typeset each article individually.
> - Get the last page number => in the next article, set the first page
> number to this + 1
> (So, we do not necessarily need to write the page numbers back to the XML,
> but we'll somehow need to pass the page number to the next article in the
> chain.)
Shouldn't products, components, and environments provide a way of doing
that from the ConTeXt side?
___
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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread Mica Semrick
If your web requirement is single XML files per article, you should be able to 
feed ConTeXt multiple XML files and typeset them as one PDF.

On May 15, 2019 7:35:47 AM PDT, Denis Maier  wrote:
>Our workflow is not settled yet; we're still discussing options. All
>depends upon what is possible ...
>
>That being said, for the purpose of displaying the articles online
>we'll
>need every article in a separate XML file. The question is if and how
>we
>will produce a PDF version containing a whole volume (we'll probably
>need
>one PDF for the whole volume and also PDFs for each article).
>
>One option would be:
>- merge the articles into a single XML,
>- typeset from there
>- split the PDF
>(Hence my question here,
>https://mailman.ntg.nl/pipermail/ntg-context/2019/095011.html).
>
>Another option could be:
>- Typeset each article individually.
>- Get the last page number => in the next article, set the first page
>number to this + 1
>(So, we do not necessarily need to write the page numbers back to the
>XML,
>but we'll somehow need to pass the page number to the next article in
>the
>chain.)
>
>
>Am Mi., 15. Mai 2019 um 14:46 Uhr schrieb Hans Hagen
>:
>
>> On 5/15/2019 12:57 PM, Denis Maier wrote:
>> > Hmm, getting the page number back from the tuc file sound feasible.
>I'll
>> > have to look into this.
>> >
>> > But how would I write the information back to the XML? Is this
>explained
>> > somewhere?
>> all depends on the workflow ... why does it need to be written back?
>>
>>
>> -
>>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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread Hans Hagen

On 5/15/2019 4:35 PM, Denis Maier wrote:
Our workflow is not settled yet; we're still discussing options. All 
depends upon what is possible ...


That being said, for the purpose of displaying the articles online we'll 
need every article in a separate XML file. The question is if and how we 
will produce a PDF version containing a whole volume (we'll probably 
need one PDF for the whole volume and also PDFs for each article).


One option would be:
- merge the articles into a single XML,
- typeset from there
- split the PDF
(Hence my question here, 
https://mailman.ntg.nl/pipermail/ntg-context/2019/095011.html).


you can create a master xml file with includes and process the lots in 
one go ... this is quite convenient when you assemble for instance books 
from chapters that are split into sections ... you can make a xml file 
per chapter that includes the sections and then a book file that loads 
them all ... files can have a processing instruction telling what styel 
to load and you can run individual files or assemblies ... all the stuff 
needed to do that is there (and probably also documented someplace)


anyway, you can always save '\lastpage' during a run ... or you can have 
some shared lua file with chapters/pagenumbers that gets updated by the 
current run


all this is workflow dependent but all can be done without too much hassle

(fwiw: we have some cases where for one projects hundreds of xml files 
get merged runtime and then processed ... the overhead is neglectable to 
the run)



Another option could be:
- Typeset each article individually.
- Get the last page number => in the next article, set the first page 
number to this + 1
(So, we do not necessarily need to write the page numbers back to the 
XML, but we'll somehow need to pass the page number to the next article 
in the chain.)



Am Mi., 15. Mai 2019 um 14:46 Uhr schrieb Hans Hagen >:


On 5/15/2019 12:57 PM, Denis Maier wrote:
 > Hmm, getting the page number back from the tuc file sound
feasible. I'll
 > have to look into this.
 >
 > But how would I write the information back to the XML? Is this
explained
 > somewhere?
all depends on the workflow ... why does it need to be written back?


-
                                            Hans Hagen | PRAGMA ADE
                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
         tel: 038 477 53 69 | www.pragma-ade.nl
 | www.pragma-pod.nl

-




--

-
  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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread Denis Maier
Our workflow is not settled yet; we're still discussing options. All
depends upon what is possible ...

That being said, for the purpose of displaying the articles online we'll
need every article in a separate XML file. The question is if and how we
will produce a PDF version containing a whole volume (we'll probably need
one PDF for the whole volume and also PDFs for each article).

One option would be:
- merge the articles into a single XML,
- typeset from there
- split the PDF
(Hence my question here,
https://mailman.ntg.nl/pipermail/ntg-context/2019/095011.html).

Another option could be:
- Typeset each article individually.
- Get the last page number => in the next article, set the first page
number to this + 1
(So, we do not necessarily need to write the page numbers back to the XML,
but we'll somehow need to pass the page number to the next article in the
chain.)


Am Mi., 15. Mai 2019 um 14:46 Uhr schrieb Hans Hagen :

> On 5/15/2019 12:57 PM, Denis Maier wrote:
> > Hmm, getting the page number back from the tuc file sound feasible. I'll
> > have to look into this.
> >
> > But how would I write the information back to the XML? Is this explained
> > somewhere?
> all depends on the workflow ... why does it need to be written back?
>
>
> -
>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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread Hans Hagen

On 5/15/2019 12:57 PM, Denis Maier wrote:
Hmm, getting the page number back from the tuc file sound feasible. I'll 
have to look into this.


But how would I write the information back to the XML? Is this explained 
somewhere?

all depends on the workflow ... why does it need to be written back?


-
  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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread Denis Maier
Hmm, getting the page number back from the tuc file sound feasible. I'll
have to look into this.

But how would I write the information back to the XML? Is this explained
somewhere?

Am Mi., 15. Mai 2019 um 09:19 Uhr schrieb Hans Hagen :

> On 5/14/2019 9:38 AM, Denis Maier wrote:
> > Hi everyone
> >
> > I am setting up a workflow for a journal where we will be using JATS XML
> > as an input format. PDFs should be typeset via ConTeXt. Is roundtripping
> > possible with ConTeXt? I will perhaps need to write page numbers back to
> > a XML file (either to the input file or to a new file.).
> it all depends on where the number comes from; saving a number is a file
> that later gets loaded by something else is no big deal
>
> also, there is always the tuc file one can analyze
>
> Hans
>
>
> -
>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
___


Re: [NTG-context] XML roundtripping

2019-05-15 Thread Hans Hagen

On 5/14/2019 9:38 AM, Denis Maier wrote:

Hi everyone

I am setting up a workflow for a journal where we will be using JATS XML 
as an input format. PDFs should be typeset via ConTeXt. Is roundtripping 
possible with ConTeXt? I will perhaps need to write page numbers back to 
a XML file (either to the input file or to a new file.).
it all depends on where the number comes from; saving a number is a file 
that later gets loaded by something else is no big deal


also, there is always the tuc file one can analyze

Hans


-
  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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-03 Thread Geert Verhaag

Hi Aditya,

The ConTeXt team did a great job in writing the manual xml-mkiv.pdf, but 
I think it is not meant for a beginner.


Its contents is rather overwhelming when trying it for the first time.

For me, I don't use luatex a lot, so that adds to the difficulty of 
trying it out.


Regards,
Gerard

On 03-05-19 00:51, Aditya Mahajan wrote:

On Thu, 2 May 2019, Geert Verhaag wrote:


Yes, I got it working!

It is somewhat tricky.

Trying to understanding the concepts behind all this isn't easy for 
me, but I'm bashing on.


I also find understanding XML processing rules to be complicated. I 
simply convert the XML to a lua table, and then use all the processing 
in lua using CLD (context lua documents).


Aditya
___ 

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
___ 




___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-02 Thread Aditya Mahajan

On Thu, 2 May 2019, Geert Verhaag wrote:


Yes, I got it working!

It is somewhat tricky.

Trying to understanding the concepts behind all this isn't easy for me, 
but I'm bashing on.


I also find understanding XML processing rules to be complicated. I simply 
convert the XML to a lua table, and then use all the processing in lua 
using CLD (context lua documents).


Aditya
___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-02 Thread Geert Verhaag

Hi Pablo,

Yes, I got it working!

It is somewhat tricky.

Trying to understanding the concepts behind all this isn't easy for me, 
but I'm bashing on.


Thanks!

Regards,
Gerard

On 02-05-19 14:47, Pablo Rodriguez wrote:

On 5/1/19 9:28 PM, Geert Verhaag wrote:

Hoi Pablo,

Thanks for your prompt reply!

The output Euro set! is printed always, it doesn't matter whether I put
EURO or DOLLAR first?!

Hi Geert,

my fault, the conditional should read:

 \xmldoif{#1}{currency[position()==1 and contains(text(),'EURO')]}
 {Euro set!}

I hope it works fine now.

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
___

___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-02 Thread Pablo Rodriguez
On 5/1/19 9:28 PM, Geert Verhaag wrote:
> Hoi Pablo,
>
> Thanks for your prompt reply!
>
> The output Euro set! is printed always, it doesn't matter whether I put
> EURO or DOLLAR first?!

Hi Geert,

my fault, the conditional should read:

\xmldoif{#1}{currency[position()==1 and contains(text(),'EURO')]}
{Euro set!}

I hope it works fine now.

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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-01 Thread Geert Verhaag

Hoi Pablo,

Thanks for your prompt reply!

The output Euro set! is printed always, it doesn't matter whether I put 
EURO or DOLLAR first?!


Also I can't find any clue on the suggested page 49 of xml-mkiv.pdf 
manual, sorry!


By the way, in my document it still doesn't seem to work!

I'm afraid all this is far too complex for me! The documentation simply 
isn't meant for beginners like me, sorry!


Regards,
Gerard


On 01-05-19 13:20, Pablo Rodriguez wrote:

On 4/30/19 9:58 PM, Geert Verhaag wrote:

[...]
\startxmlsetups xml:invoice:invoice
    \xmlfirst{#1}{currency} \par
    \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} {
   Euro set! \par
    }
[...]
But the xmldoif command doesn't cause the Euro set be printed?!

What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on
how to make this work!

Hi Geert,

the syntax reads \xmldoif{#1}{lpath}{action}. So your conditional may read:

 \xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
 {Euro set!}

In a complete sample (with dollar set first [it won’t show the result
unless you set EURO first]):

   \startbuffer[demo]
   
 
   DOLLAR
   EURO
 
   
   \stopbuffer

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

   \xmlregistersetup{xml:initialize}

   \startxmlsetups xml:doc
 \xmlfirst{#1}{currency} \par
 \xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
 {Euro set!}
   \stopxmlsetups

   \setuppapersize[A8]

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

It is all in xml-mkiv.pdf
(http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#page=49). I have
just discovered it .

Just in case it helps,

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
___

___
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
___


Re: [NTG-context] XML xmldoif struggle!

2019-05-01 Thread Pablo Rodriguez
On 4/30/19 9:58 PM, Geert Verhaag wrote:
> [...]
> \startxmlsetups xml:invoice:invoice
>    \xmlfirst{#1}{currency} \par
>    \xmldoif{\xmlfirst{#1}{currency}}{contains(text(),'EURO')} {
>   Euro set! \par
>    }
> [...]
> But the xmldoif command doesn't cause the Euro set be printed?!
>
> What's wrong here? The manual xml-mkiv.pdf doesn't give me any hint on
> how to make this work!

Hi Geert,

the syntax reads \xmldoif{#1}{lpath}{action}. So your conditional may read:

\xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
{Euro set!}

In a complete sample (with dollar set first [it won’t show the result
unless you set EURO first]):

  \startbuffer[demo]
  

  DOLLAR
  EURO

  
  \stopbuffer

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

  \xmlregistersetup{xml:initialize}

  \startxmlsetups xml:doc
\xmlfirst{#1}{currency} \par
\xmldoif{#1}{currency[first() and contains(text(),'EURO')]}
{Euro set!}
  \stopxmlsetups

  \setuppapersize[A8]

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

It is all in xml-mkiv.pdf
(http://www.pragma-ade.com/general/manuals/xml-mkiv.pdf#page=49). I have
just discovered it .

Just in case it helps,

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
___


Re: [NTG-context] XML and math

2019-01-10 Thread Aditya Mahajan

On Thu, 10 Jan 2019, Aditya Mahajan wrote:


On Thu, 10 Jan 2019, Hans Hagen wrote:


On 1/10/2019 10:26 PM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no 
control over), which contains elements as follows:


  
     
    height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>

     
  

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
   % Bunch of missing definitions
   \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
   \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).

Time for an "aha, I knew it" moment ...


This contains `` which I want to convert to either newline or blank.


Some debugging showed that the entity was being translated correctly. I 
was typesetting the output under texcatcodes, which was causing the 
problem. Setting formfeedasciicode and endoflineasciicode to ignorecatcode 
made everything work correctly.


Aditya___
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
___

Re: [NTG-context] XML and math

2019-01-10 Thread Aditya Mahajan

On Thu, 10 Jan 2019, Hans Hagen wrote:


On 1/10/2019 10:26 PM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no control 
over), which contains elements as follows:


  
     
    height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>

     
  

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
   % Bunch of missing definitions
   \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
   \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).

Time for an "aha, I knew it" moment ...


:-) Thanks.

Follow-up question: How do I escape entities inside the attributes. One 
snippet is:


 
$$x_2(t) = 
\begin{cases}  t,  0 \leq t  5 \\ -t+10,   t \geq

5\end{cases}$$
 

This contains `` which I want to convert to either newline or blank.

(I have to use the text attribute. The content has the right information 
in this particular instance due to a bug in the conversion)


Aditya___
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
___

Re: [NTG-context] XML and math

2019-01-10 Thread Aditya Mahajan

On Fri, 11 Jan 2019, Henri Menke wrote:


On 11/01/19 10:26 AM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no
control over), which contains elements as follows:

 
    
   
    
 

I want to typeset the `text` attribute of equation (and ignore the 
tag). So, I tried:

\startxmlsetups matlab
  % Bunch of missing definitions
  \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
  \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for
content and not attributes).


You could write your own attribute fetcher in Lua.  Probably there is a
more elegant method.

\startbuffer[test]

   
  
   

\stopbuffer

\startxmlsetups matlab
 % Bunch of missing definitions
 \xmlsetsetup{#1}{p}{matlab:*}
 \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:p
 \xmlflush{#1}
\stopxmlsetups

\startxmlsetups matlab:equation
 \xmlfunction{#1}{equation}
\stopxmlsetups
\startluacode
local a = "text"
local ctxcatcodes = catcodes.numbers.ctxcatcodes

function xml.functions.equation(id)
   local e = lxml.getid(id)
   if e then
   local at = e.at
   if at then
   local att = at[a]
   if att ~= "" then
   context.sprint(ctxcatcodes,att)
   end
   end
   end
end
\stopluacode

\xmlregistersetup{matlab}

\starttext
\xmlprocessbuffer{test}{test}{}
\stoptext


Thanks!

Aditya___
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
___

Re: [NTG-context] XML and math

2019-01-10 Thread Hans Hagen

On 1/10/2019 10:26 PM, Aditya Mahajan wrote:

Hi,

I have an XML file (which is generated via a program that I have no 
control over), which contains elements as follows:


  
     
    height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>

     
  

I want to typeset the `text` attribute of equation (and ignore the  
tag). So, I tried:


\startxmlsetups matlab
   % Bunch of missing definitions
   \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:equation
   \xmlatt{#1}{text}
\stopxmlsetups

This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the 
attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for 
content and not attributes).

Time for an "aha, I knew it" moment ...

\starttext

\startbuffer[test]


   height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>



\stopbuffer

\startxmlsetups whatever
\xmlsetsetup{#1}{p|equation}{xml:*}
\stopxmlsetups

\xmlregistersetup{whatever}

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

\startxmlsetups xml:equation
\cldcontext{lxml.getid("#1").at.text}
\stopxmlsetups

\startxmlsetups xml:equation
\startformula
\cldcontext{(string.gsub(lxml.getid("#1").at.text,"[$][$]",""))}
\stopformula
\stopxmlsetups

\xmlprocessbuffer{main}{test}{}

\stoptext


-
  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
___

Re: [NTG-context] XML and math

2019-01-10 Thread Henri Menke
On 11/01/19 10:26 AM, Aditya Mahajan wrote:
> Hi,
> 
> I have an XML file (which is generated via a program that I have no
> control over), which contains elements as follows:
> 
>  
>     
>     height="15px" src="Lab01_eq10401623798909303081.png" width="95px"/>
>     
>  
> 
> I want to typeset the `text` attribute of equation (and ignore the 
> tag). So, I tried:
> 
> \startxmlsetups matlab
>   % Bunch of missing definitions
>   \xmlsetsetup{#1}{equation}{matlab:*}
> \stopxmlsetups
> 
> \startxmlsetups matlab:equation
>   \xmlatt{#1}{text}
> \stopxmlsetups
> 
> This literally typesets `$$y_1(t) = 1, t \geq 0$$`. How can I flush the
> attribute using ctxcatcodes? (There is \xmlflushcontent, but that is for
> content and not attributes).

You could write your own attribute fetcher in Lua.  Probably there is a
more elegant method.

\startbuffer[test]
 

   

 
\stopbuffer

\startxmlsetups matlab
  % Bunch of missing definitions
  \xmlsetsetup{#1}{p}{matlab:*}
  \xmlsetsetup{#1}{equation}{matlab:*}
\stopxmlsetups

\startxmlsetups matlab:p
  \xmlflush{#1}
\stopxmlsetups

\startxmlsetups matlab:equation
  \xmlfunction{#1}{equation}
\stopxmlsetups
\startluacode
local a = "text"
local ctxcatcodes = catcodes.numbers.ctxcatcodes

function xml.functions.equation(id)
local e = lxml.getid(id)
if e then
local at = e.at
if at then
local att = at[a]
if att ~= "" then
context.sprint(ctxcatcodes,att)
end
end
end
end
\stopluacode

\xmlregistersetup{matlab}

\starttext
\xmlprocessbuffer{test}{test}{}
\stoptext


> 
> Thanks,
> Aditya
> ___
> 
> 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
> ___

___
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
___

Re: [NTG-context] xml in lua advice ?

2018-09-19 Thread Taco Hoekwater
Hi,

> it actually depends on what you do ... anyway here is some insight (as 
> xml-tex old-timer you'll probably recognize the madness)

What I am mostly trying to do is to have as much of the xml processing in lua 
as possible.

> 
> % \enabletrackers[context*]
> 
> \starttext
> 
> % here is your missing mwe

Yes, sorry about that. My question was intended to be more of an
documentation-related one. 

Using your MWE as guideline, my minimal file looks like this:

% BEGIN ENVIRONMENT
\startluacode
function xml.functions.document(t) 
   lxml.flush(t) 
end
function xml.functions.b(t)
   context.start()
   context.bf()
   lxml.flush(t)
   context.stop()
   context("{}")
end
function xml.functions.section(t)
  context.section("{")
  lxml.flush(t)
  context("}")
end
\stopluacode

\startxmlsetups mysetups % to be converted to lua later
  \xmlsetfunction {main}{document}{xml.functions.document}
  \xmlsetfunction {main}{section} {xml.functions.section}  
  \xmlsetfunction {main}{b}   {xml.functions.b}
\stopxmlsetups

\xmlregistersetup{mysetups} % to be converted to lua later
 
% XML normally in separate file
\starttext
\startbuffer[test]

   some bold title

\stopbuffer

\xmlprocessbuffer{main}{test}{}

\stoptext
% END EXAMPLE


I know it would be simple to write e.g.

  \startsetups xml:section
\section{\xmlflush{#1}}
  \stopsetups

but I was aiming for a simple, clean-looking CLD as style setup of the XML 
document. I doubt I could explain your MWE to one of my coworkers, as I 
hardly understand it myself :)

What I was really hoping for was something like the fictional:

  function xml.functions.section(t)
context.section(lxml.process_into_context_string(t))
  end

or some CLD extension so that it would actually understand

  function xml.functions.section(t)
context.section(lxml.flush(t))
  end

I hope this makes more sense now. Unless something magical is possible,
it seems my best bet is to stick with \startsetups instead of lua for
these cases, just to make sure I can explain to the rest of the office
what is going on.

Thanks,
Taco





___
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
___

Re: [NTG-context] xml in lua advice ?

2018-09-19 Thread mf
My 2 cents:

local xmlflush = lxml.flush

local function text_or_xml(...)
  for i,v in ipairs(arg) do
if "table" == type(v) then
  xmlflush(v)
else
  context(v)
end
  end
end

function xml.functions.heading(t)
  text_or_xml( "\\section{" , t , "}" )
end

Massimiliano

Il giorno mer, 19/09/2018 alle 15.56 +0200, Hans Hagen ha scritto:
> On 9/19/2018 2:50 PM, Taco Hoekwater wrote:
> > Hi,
> > 
> > Is there a more elegant way to feed an xml tree into a context()
> > command
> > that what I have below?
> > 
> > 
> > \startluacode
> > function xml.functions.heading(t)
> > context.section("{")
> > lxml.flush(t)
> > context("}")
> > end
> > \stopluacode
> > 
> > The subtree in ’t’ could have embedded xml tags that should be
> > processed,
> > so just stripping it clean will not do.
> > 
> > (this is not about \section as such, I just needed an example.
> > \startsection
> > would be more modern, but it would not help fix the issue )
> 
> it actually depends on what you do ... anyway here is some insight
> (as 
> xml-tex old-timer you'll probably recognize the madness)
> 
> % \enabletrackers[context*]
> 
> \starttext
> 
> % here is your missing mwe
> 
> \startbuffer[test]
> 
>  some bold title
> 
> \stopbuffer
> 
> % this will assume xml and relate some handlers
> 
> \setuphead[section]
>[coding=xml,
> xmlsetup=xml:flush]
> 
> \startxmlsetups xml:flush
>  \xmlflush{#1}
> \stopxmlsetups
> 
> % comment this one for your amusement
> 
> \startxmlsetups xml:b
>  {\bf \xmlflush{#1}}
> \stopxmlsetups
> 
> % here is the magic: you pass a reference
> 
> \startluacode
> function xml.finalizers.heading(t)
>  context.formatted.section("main::%i",t[1].ix)
> end
> \stopluacode
> 
> % this loads only (can happen at the lua end ... you can sort that
> out)
> 
> \xmlloadbuffer{main}{test}{}
> 
> % this indexes the nodes (the ix keys, basically all these #1
> argumehnts 
> in setups use that trickery)
> 
> \xmladdindex{main}
> 
> % to be sure
> 
> \xmlsetsetup{main}{b}{xml:b}
> 
> % now we filter / apply your finalizer
> 
> \xmlfilter{main}{section/heading()}
> 
> % done
> 
> \stoptext
> 
> 
> 
> 
> -
>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
> _
> __

___
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
___

  1   2   3   4   5   >