[NTG-context] fatal error again in LMTX

2022-05-02 Thread Pablo Rodriguez via ntg-context
Hi Hans,

as already reported
(https://mailman.ntg.nl/pipermail/ntg-context/2022/105443.html), LMTX
(from 2022.05.02 16:19) quits messaging only fatal error with such a sample:

  \starttext
  \startitemize
  \item one
  \stoptext

I know that \stopitemize is missing above.

But in real--world documents, this mistake may need hours to be fixed.

Would it be possible that LMTX could provide more verbose information
about unfinished \start-commands?

Many thanks for your help,

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
___


[NTG-context] Cron /var/www/aanhet.net/context/bin/cron/context-mirror

2022-05-02 Thread Cron Daemon via ntg-context
receiving incremental file list
 ./
 ctan.lsr
 document-2.htm
 download-1.htm
 download-2.htm
 install.htm
 logo-ade.png
 logo-cts.png
 logo-pod.png
 rss.xml
 show-fil.pdf
 context/latest/
 context/latest/cont-mpd.zip
 context/latest/cont-ppc.zip
 context/latest/cont-sci.zip
 context/latest/cont-tmf.zip
 
 sent 90,352 bytes  received 18,536,958 bytes  3,386,783.64 bytes/sec
 total size is 456,819,434  speedup is 24.52


Running archiver:

New dir: /var/www/aanhet.net/context//htdocs/archives/context-2022-05-02.17
137316935   
/var/www/aanhet.net/context//htdocs/archives/context-2022-05-02.17/latest
126745317   
/var/www/aanhet.net/context//htdocs/archives/context-2022-05-02.17/current
18956262
/var/www/aanhet.net/context//htdocs/archives/context-2022-05-02.17/alpha
126707516   
/var/www/aanhet.net/context//htdocs/archives/context-2022-05-02.17/beta
409730126   
/var/www/aanhet.net/context//htdocs/archives/context-2022-05-02.17
409730126   total
___
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] process list items differently depending on position in list

2022-05-02 Thread Denis Maier via ntg-context
> -Ursprüngliche Nachricht-
> Von: ntg-context  Im Auftrag von Hans Hagen
> via ntg-context
> Gesendet: Montag, 2. Mai 2022 12:34
> An: Denis Maier via ntg-context 
> Cc: Hans Hagen 
> Betreff: Re: [NTG-context] process list items differently depending on
> position in list
> 
> On 5/2/2022 12:09 PM, Denis Maier via ntg-context wrote:
> 
> > But, it’d still love to hear whether there is a solution on the tex side.
> \processtokens {[before]} {[between]} {[after]} {[space]} {{one}{two}{three}}
> 
> \def\whatever{a,b,c,d}
> 
> \getcommacommandsize[\whatever]
> \scratchcounterone \zerocount
> \scratchcountertwo \commalistsize
> 
> \processcommacommand[\whatever]
>{\advance\scratchcounterone\plusone
> \ifnum\scratchcounterone=\scratchcountertwo
>   \space and\space
> \orelse\ifnum\scratchcounterone>\plusone
>   ,\space
> \fi
> \commalistelement}

Thanks.

> 
> but ... there's also:
> 
> \startlines
> \commalistsentence[aap,noot,mies]
> \commalistsentence[aap,noot]
> \commalistsentence[aap]
> \commalistsentence[a,b,c]
> \commalistsentence[a,b,c][{ \& },{ and }] \commalistsentence[a,b,c][+,-]
> \stoplines
> 
> which uses presets like
> 
> \setuplabeltext [nl] [and-1={{, }}, and-2={{ en }}]   % 1, 2 en 3
> \setuplabeltext [en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3
> \setuplabeltext [de] [and-1={{, }}, and-2={{ und }}]  % 1, 2 und 3
> \setuplabeltext [hr] [and-1={{, }}, and-2={{ i }}]% 1, 2 i 3
> 
> maybe wikify

I've just checked, \commalistsentence is already on the wiki, but you have to 
know it exists. (I'll check whether I can link to that page from somewhere.)

But there's no (high-level) way to apply certain commands to this list 
elements, right? 
Background: My real use case is a bit more complex. I use comma separated lists 
to store author lists, but the authors themselves are saved in structured 
variables. So, I'll need to reassemble the different name parts first.
So, nothing like 
\commalistprocessandmakesentence[a,b,c]\commandforfirst\commandforinbetween\commandforlast
Probably to specific, right?


\startbuffer[test]


This is the title

Doe
John


Smith
Jane

This is a first sentence

\stopbuffer

\startxmlsetups xml:setup
  \xmlsetsetup{\xmldocument}{*}{-}
  \xmlsetsetup{\xmldocument}{document|p}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:setup}

\startxmlsetups xml:document
  \xmlfilter{#1}{/title/command(xml:title)}
  \xmlfilter{#1}{/author/command(xml:author)}
  \startdocument
  \xmlflush{#1}
  \stopdocument
\stopxmlsetups

\startxmlsetups xml:title
  \setupdocument[title={\xmlflush{#1}},author={\AuthorList}]
\stopxmlsetups

\startxmlsetups xml:author:family-name
\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:author:given-name
\xmlflush{#1}
\stopxmlsetups

\startxmlsetups xml:author
  
\defineauthor[\xmlfilter{#1}{/family-name/command(xml:author:family-name)}\xmlfilter{#1}{/given-name/command(xml:author:given-name)}][family-name={\xmlfilter{#1}{/family-name/command(xml:author:family-name)}},given-name={\xmlfilter{#1}{/given-name/command(xml:author:given-name)}}]
  \addtocommalist 
{\xmlfilter{#1}{/family-name/command(xml:author:family-name)}\xmlfilter{#1}{/given-name/command(xml:author:given-name)}}
 \AuthorList
\stopxmlsetups

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

\definenamespace
   [documentauthor] % name of internal varialbles
   [type=module,
name=author, 
command=yes, % Create \defineauthor
style=yes, % Create \useauthorstyleandcolor 
setup=list, % Create \setupauthor
parent=documentauthor,
  ]
  
\def\AuthorList{}

\define[1]\useauthor
{\edef\currentauthor{#1}%
{\authorparameter{given-name}
 \space
  \authorparameter{family-name}}}

\startsetups document:start
\documentvariable{title}\endgraf
\blank[medium]
\processcommacommand[\documentvariable{author}]\useauthor
\endgraf
\stopsetups

\xmlprocessbuffer{main}{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] process list items differently depending on position in list

2022-05-02 Thread Hans Hagen via ntg-context

On 5/2/2022 12:09 PM, Denis Maier via ntg-context wrote:


But, it’d still love to hear whether there is a solution on the tex side.
\processtokens {[before]} {[between]} {[after]} {[space]} 
{{one}{two}{three}}


\def\whatever{a,b,c,d}

\getcommacommandsize[\whatever]
\scratchcounterone \zerocount
\scratchcountertwo \commalistsize

\processcommacommand[\whatever]
  {\advance\scratchcounterone\plusone
   \ifnum\scratchcounterone=\scratchcountertwo
 \space and\space
   \orelse\ifnum\scratchcounterone>\plusone
 ,\space
   \fi
   \commalistelement}

but ... there's also:

\startlines
\commalistsentence[aap,noot,mies]
\commalistsentence[aap,noot]
\commalistsentence[aap]
\commalistsentence[a,b,c]
\commalistsentence[a,b,c][{ \& },{ and }]
\commalistsentence[a,b,c][+,-]
\stoplines

which uses presets like

\setuplabeltext [nl] [and-1={{, }}, and-2={{ en }}]   % 1, 2 en 3
\setuplabeltext [en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3
\setuplabeltext [de] [and-1={{, }}, and-2={{ und }}]  % 1, 2 und 3
\setuplabeltext [hr] [and-1={{, }}, and-2={{ i }}]% 1, 2 i 3

maybe wikify


-
  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] process list items differently depending on position in list

2022-05-02 Thread Denis Maier via ntg-context
Ok, in lua it's indeed simple:

\startluacode
list = {"foo", "bar", "baz"}
\stopluacode

\starttext

\startluacode
for i, v in ipairs(list) do
if i == #list then
tex.print("last:")
tex.print(v)
elseif i == 1 then
tex.print("first:")
tex.print(v)
else
tex.print("in between:")
tex.print(v)
end
end
\stopluacode

\stoptext

But, it'd still love to hear whether there is a solution on the tex side.

Denis

Von: Maier, Denis Christian (UB)
Gesendet: Montag, 2. Mai 2022 09:15
An: 'mailing list for ConTeXt users' 
Betreff: process list items differently depending on position in list

Hi,

I need to process a comma separated list, and adapt the formatting according to 
the position of an item in the list (example below). Expected output would be:
{\bf foo
}, {\em bar} and baz.

Is that possible? Can I somehow get the position of an item in the list? (My 
understanding is that \processcommalist and \processcommacommand apply a 
command to each list item, but there is no such thing as ... I hope I'm wrong here.)

Or is that something where using Lua would be a better choice?

Best,
Denis


\define[1]\command
  {#1}

\define\somelist
  {foo, bar, baz}

\starttext

  \processcommacommand
[\somelist]
\command

\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] \getcommacommandsize not working in lmtx

2022-05-02 Thread Hans Hagen via ntg-context

On 5/2/2022 9:37 AM, Denis Maier via ntg-context wrote:

Hi,

I’ve just ran into a behaviour that runs against what is shown on the 
wiki, https://wiki.contextgarden.net/System_Macros/Comma_Separated_Lists 



Maybe a bug?


More a feature as \define defines a protected macro.

\starttext

\define\somelist{foo,bar,baz}

{\tt\meaningasis\somelist}

\getcommacommandsize[\somelist] \commalistsize

\defineexpandable\somelist{foo,bar,baz}

{\tt\meaningasis\somelist}

\getcommacommandsize[\somelist] \commalistsize

\starttexdefinition protected somelist
foo,
bar,
baz
\stoptexdefinition

{\tt\meaningasis\somelist}

\getcommacommandsize[\somelist] \commalistsize

\starttexdefinition somelist
foo,
bar,
baz
\stoptexdefinition

{\tt\meaningasis\somelist}

\getcommacommandsize[\somelist] \commalistsize

\semiprotected\def\somelist{foo,bar,baz}

\getcommacommandsize[\somelist] \commalistsize
\getcommacommandsize[\semiexpanded{\somelist}] \commalistsize

% also in next version:
%
% \starttexdefinition semiprotected somelist
% foo,
% bar,
% baz
% \stoptexdefinition
%
% {\tt\meaningasis\somelist}
%
% \getcommacommandsize[\somelist] \commalistsize
% \getcommacommandsize[\semiexpanded{\somelist}] \commalistsize

\stoptext

The semiprotected is something lmtx and only expands when explicitly 
asked for (like in an \edef or so). Something that we might apply in the 
core some day.


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


[NTG-context] \getcommacommandsize not working in lmtx

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

I've just ran into a behaviour that runs against what is shown on the wiki, 
https://wiki.contextgarden.net/System_Macros/Comma_Separated_Lists
Maybe a bug?

The wiki says you can use \getcommacommandsize to get the length of a comma 
separated list, but it does not seem to work. MWE below.

Best,
Denis


\define\somelist
  {foo, bar, baz}

\starttext

\getcommacommandsize[\somelist]
\commalistsize
% Expected : 3
% Actual : 1

\expandafter\getcommalistsize\expandafter[\somelist]
\commalistsize
% Expected : 3
% Actual : 3

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


[NTG-context] XML processing instructions

2022-05-02 Thread Duncan Hothersall via ntg-context
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] recursion in a table

2022-05-02 Thread Hans Hagen via ntg-context

On 5/2/2022 2:30 AM, Aditya Mahajan via ntg-context wrote:


\expanded{\NC \recurselevel \noexpand\NC ... }


There is no need for \noexpand before \NC. Even \NR is protected. In 
MKIV there are some more sensitive ones like \FR but in LMTX these are 
defined as \noaligned which permits them being protected too (the 
engine's alignments scanners have some lookahead properties that cna 
otherwise interfere).


\starttabulate[||]
\NC \infofont\meaningasis \NC \NC \NR
\NC \infofont\meaningasis \NR \NC \NR
\NC \infofont\meaningasis \HL \NC \NR
\NC \infofont\meaningasis \FL \NC \NR
\stoptabulate


Remind me of a more-than-a-decade-old discussion on the mailing list, 
summarized here:

https://adityam.github.io/context-blog/post/tex-programming/


Also, \HL doesn’t work at the end, and the second line of the error
message makes no sense:


As you're not afraid of low level code:

\starttext

\starttabulate[|r|c|]
\NC $T$ \NC what \NC \NR
\HL
\expandedloop 0 359 45 {
\NC \number\currentloopiterator ˚ \NC \NC \NR
}
\stoptabulate

\stoptext

So, you can play with:

\expandedloop
\unexpandedloop
\localcontrolledloop
\quitloop
\currentloopiterator
\currentloopnesting
\lastloopiterator

if you want a challenge for a new blog post.

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
___


[NTG-context] process list items differently depending on position in list

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

I need to process a comma separated list, and adapt the formatting according to 
the position of an item in the list (example below). Expected output would be:
{\bf foo
}, {\em bar} and baz.

Is that possible? Can I somehow get the position of an item in the list? (My 
understanding is that \processcommalist and \processcommacommand apply a 
command to each list item, but there is no such thing as ... I hope I'm wrong here.)

Or is that something where using Lua would be a better choice?

Best,
Denis


\define[1]\command
  {#1}

\define\somelist
  {foo, bar, baz}

\starttext

  \processcommacommand
[\somelist]
\command

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