Re: [NTG-context] numbering questions

2022-12-31 Thread Duncan Hothersall via ntg-context
I can't test right now but would something like

\setuphead[Day][sectionsegments=Day:Month:Year]

help?

Duncan


On Sat, 31 Dec 2022 at 17:24, Henning Hraban Ramm via ntg-context <
ntg-context@ntg.nl> wrote:

> A happy new year to everyone!
>
> I’m playing with some examples of section numbering.
>
> * Is there a setup to influence the order of number segments? I.e. can I
> have “section.chapter.part“ instead of “part.chapter.section”?
>
> * How can I format the segments, e.g. to get two or three digits each
> (leading zeros)?
>
> * I can force a section number with “ownnumber”, but the next one is
> back in the previous scheme. Itemize has “start”. How can I start
> section chapter numbering at 3 (or -1 or whatever; I know I can start at
> 0 with “zero”) and let ConTeXt continue from there?
>
>
> My example tries to (ab)use the section numbering for a date (e.g. for a
> diary):
>
> -
> \definestructureconversionset[default][n,n,month,n][n]
> \definestructureseparatorset [default][-,-,-,-]
>
> \definehead[Year][chapter]
> \definehead[Month][section]
> \definehead[Day][subsection]
>
> \define[2]\TitleCmd{#1} % number only
>
> \setuphead[Year,Month,Day][number=yes,page=no,command=\TitleCmd]
> \setuphead[Year][page=yes]
> %\setuphead[Month][]
> \setuphead[Day][style={\ss\bf}]
>
> \def\Dummycontent{
>  \dorecurse{12}{
>  \startMonth
>  New Month.
>
>  \dorecurse{5}{
>  \startDay
>  Another day.
>
>  \stopDay
>  }
>
>  \stopMonth
> }}
>
> \starttext
>
> \startYear[ownnumber=2023,title=This]
> A new year begins.
>
> \Dummycontent
>
> \stopYear
>
> \startYear
> Next year.
>
> \Dummycontent
>
> \stopYear
>
> \stoptext
> -
>
> Hraban
>
>
> ___
> 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 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] overprinting black

2022-11-09 Thread Duncan Hothersall via ntg-context
Have you tried overprint=yes? I have that in old files which used to work
under mkii. I must admit I haven't had the need to use overprinting since
then, but I do recall that come colour handling wasn't ported across to
mkiv or later.

Duncan

On Wed, 9 Nov 2022 at 16:12, Henning Hraban Ramm via ntg-context <
ntg-context@ntg.nl> wrote:

> I’m not sure if this ever worked, but at least in latest LMTX it doesn’t:
>
> """
> \setupcolors[state=start,cmyk=yes,rgb=no,intent=overprint]
>
> \starttext
>
> \framed[
>background=color,
>backgroundcolor=yellow,
> ]{\ss\bfd
>Black should always overprint.
> }
>
> \stoptext
> """
>
> The black text and frame border don’t overprint the yellow background
> but knockout. The only way to check this (that I know of) is Acrobat
> Pro’s separation simulation; the screenshot shows a snippet of the
> yellow separation.
>
> Actually, setting “overprint” for all colors doesn’t make sense, it
> should be a setting for single color (but default for black):
>
> % desired interface:
> \definecolor[overBlack][k=1,intent=overprint]
>
> Hraban
>
> ___
> 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] MathML when processing XML

2022-05-30 Thread Duncan Hothersall via ntg-context
Answering my own question - the rules in x-mathml.mkxl/.lmt assume *only*
an mml: namespace on MathML elements. Having built my current project on
the basis of the examples in the XML in mkiv manual, I had two layers of
namespaces in addition to that. Redoing the mappings for the MathML
elements resulted in glorious formulas coming out.

Duncan

On Sun, 29 May 2022 at 22:23, Duncan Hothersall  wrote:

> This feels like a really stupid question but I can't find an answer to it
> anywhere.
>
> When processing an XML file directly with ConTeXt, i.e.
> using \startxmlsetups rules, how can I make use of the MathML module for
> the MathML content in my XML source? Should I include a specific piece of
> code with a \registerctxluafile command as well as / instead of
> \usemodule[mathml]? Do I need to use something other than \xmlflush to pass
> the XML to the module?
>
> Sorry, it's probably obvious but I can't work it out!
>
> Thanks.
>
> Duncan
>


-- 
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] MathML when processing XML

2022-05-29 Thread Duncan Hothersall via ntg-context
This feels like a really stupid question but I can't find an answer to it
anywhere.

When processing an XML file directly with ConTeXt, i.e.
using \startxmlsetups rules, how can I make use of the MathML module for
the MathML content in my XML source? Should I include a specific piece of
code with a \registerctxluafile command as well as / instead of
\usemodule[mathml]? Do I need to use something other than \xmlflush to pass
the XML to the module?

Sorry, it's probably obvious but I can't work it out!

Thanks.

Duncan
___
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 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
<https://maps.google.com/?q=22+Forth+Street,+Edinburgh,+EH1+3LH,+UK=gmail=g>

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


*Sign up to the CAPDM newsletter here <http://eepurl.com/bqzBQn>*
___
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: calculations on attribute values before output

2022-05-04 Thread Duncan Hothersall via ntg-context
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!)

MWE below, but obviously it just passes the morerows="1" value straight
through into \bTD[nr=1] so it doesn't give me a row span at all.

Thanks in advance.

Duncan

--

\startbuffer[demo]

 
  
   
1
2
   
   
3
   
  
 

\stopbuffer

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

\xmlregisterdocumentsetup{demo}{xml:demo:base}

\startxmlsetups xml:demo:informaltable
 \bTABLE
  \xmlflush{#1}
 \eTABLE
\stopxmlsetups

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

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

\startxmlsetups xml:demo:row
 \bTR
  \xmlflush{#1}
 \eTR
\stopxmlsetups

\startxmlsetups xml:demo:entry
 \bTD[nr=\xmlattdef{#1}{morerows}{1}]
  \xmlflush{#1}
 \eTD
\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-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}
>

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 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] Space around figure

2022-04-28 Thread Duncan Hothersall via ntg-context
You should be able to change the space above and below a float with the
spacebefore and spaceafter keys to \setupfloat. I think the default value
is big for each, but you can override that with null. Something like

\setupfloat[figure][spacebefore=,spaceafter=]

Hope that helps.

Duncan

On Thu, 28 Apr 2022 at 11:41, Alain Delmotte via ntg-context <
ntg-context@ntg.nl> wrote:

> Hi,
>
> When one insert a figure in a text, I think that the default behaviour is
> to add space around the figure.
>
> Is tit possible to manage that space or suppress it?
>
> Thanks in advance,
>
> --
>
> Alain
>
> ___
> 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] How to group list of figures and list of tables by chapter?

2022-03-30 Thread Duncan Hothersall via ntg-context
You could try using \writebetweenlist hooked into \setuphead[chapter]?
Something like (untested):

\setuphead[chapter][before={\writebetweenlist[figure][location=here]{\blank}}]

(Sorry, can't currently test this.)

Duncan

On Thu, 31 Mar 2022 at 06:31, Werner Schmidt via ntg-context <
ntg-context@ntg.nl> wrote:

> Hi,
>
> How can I set up \placelistoffigures and \placelistoftables that figures
> and tables are grouped by chapter, i.e. separated by a blank line between
> chapters (see example below)?
>
> Thanks in advance for your help!
>
> Best Werner
>
>
> (Default:)
> Figures
>
> 1.1 Caption Chapter01-Section01-01 . . . . . . . . . . . . . . . . . 2
> 2.1 Caption Chapter02-Section01-01 . . . . . . . . . . . . . . . . . 3
> 2.2 Caption Chapter02-Section01-02 . . . . . . . . . . . . . . . . . 3
> 3.1 Caption Chapter03-Section01-01 . . . . . . . . . . . . . . . . . 4
> 3.2 Caption Chapter03-Section01-02 . . . . . . . . . . . . . . . . . 4
> 3.3 Caption Chapter03-Section02-03 . . . . . . . . . . . . . . . . . 4
>
> (Wanted:)
> Figures
>
> 1.1 Caption Chapter01-Section01-01 . . . . . . . . . . . . . . . . . 2
>
> 2.1 Caption Chapter02-Section01-01 . . . . . . . . . . . . . . . . . 3
> 2.2 Caption Chapter02-Section01-02 . . . . . . . . . . . . . . . . . 3
>
> 3.1 Caption Chapter03-Section01-01 . . . . . . . . . . . . . . . . . 4
> 3.2 Caption Chapter03-Section01-02 . . . . . . . . . . . . . . . . . 4
> 3.3 Caption Chapter03-Section02-03 . . . . . . . . . . . . . . . . . 4
>
> ___
> 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] Bloody PDF boxes and cr*p marks!

2021-10-31 Thread Duncan Hothersall via ntg-context
Thank you for this, that's the first time this stuff has made any sense to
me.

On Sat, 30 Oct 2021 at 20:22, Henning Hraban Ramm via ntg-context <
ntg-context@ntg.nl> wrote:

> I finally reworked the wiki page https://wiki.contextgarden.net/PDF_Boxes
> and also extended https://wiki.contextgarden.net/PDFX a bit.
>
> Hraban
>
> ___
> 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] A book with sections

2021-10-24 Thread Duncan Hothersall via ntg-context
Worth just quickly noting that the default for \part is placehead=no. You
need to explicitly set placehead=yes for it to actually output the heading.
See https://wiki.contextgarden.net/Command/_section#Parts

On Sun, 24 Oct 2021 at 00:02, Bruce Horrocks via ntg-context <
ntg-context@ntg.nl> wrote:

>
>
> > On 23 Oct 2021, at 14:51, Gerben Wierda via ntg-context <
> ntg-context@ntg.nl> wrote:
> >
> >
> >> On 23 Oct 2021, at 15:34, Wolfgang Schuster <
> wolfgang.schuster.li...@gmail.com> wrote:
> >>
> >>  Gerben Wierda via ntg-context schrieb am 23.10.2021 um 15:20:
> >>> I’d like a book with chapters to have sections/parts, e.g. something
> that groups a few \chapter elements together. Is there support for this in
> LMTX? I.e. in such a way that it also shows up in the table of contents?
> >>
> >> You can use \part.
> >
> > Yes. Thanks. But that leads to additional questions:
> > - how do I get the parts to show up in the table of contents? Because I
> tried \part but it did not show up
> > - how do I let chapters number on (not restart in each part, and not a
> x.y number but simply ‘2. Chapter’
> > - what is a good way to create actual RHS ‘title’ pages for each chapter?
> > - how do I get parts to number with Roman numerals?
>
> I define my own versions of \part and \chapter (called \Part and \Chapter)
> and specify a different display style using setups. The definition for
> \Part is below, \Chapter is very similar so I haven't included it.
>
> %% Double rule above part title
> \startsetups PartSetup
>  \setupheader[state=empty]
>  \par
>  \startMPcode
>draw (0,2mm)--(TextWidth,2mm) withpen pensquare scaled 1.5mm ;
>draw (0,0)--(TextWidth,0) withpen pensquare scaled 1.0mm ;
>clip currentpicture to unitsquare yscaled 1cm xscaled TextWidth
>  \stopMPcode
> \stopsetups
>
> \define[2]\placePartTitle{\midaligned{#2}}
> %% The above line is what I use. You want Roman numerals so maybe adapt it
> to:
> %% \define[2]\placePartTitle{\midaligned{\convertnumber[Romannumerals][#1]
> #2}}
>
> \definehead [Part] [part]
> \setuphead[Part]
>  [ page=right,
>placehead=yes,
>style={\stylePartTitle}, %% this is just from a \definefont
>before={\setups{PartSetup}},
>command=\placePartTitle,
>  ]
>
> With \setuplayout[location=doublesided] this then comes out on the RHS.
>
> For the ToC, I use:
>
> \setuplist [alternative=b]
> \setuplist [Part]
>  [ headnumber=no,
>margin=0cm,
>width=0cm,
>distance=0cm,
>style=\tocStylePartTitle,
>  ]
> \setuplist [Chapter]
>  [ headnumber=no,
>margin=1em,
>width=0cm,
>distance=0cm,
>  ]
> \setupcombinedlist [content] [list={Part,Chapter}]
>
> then \placecontent prints the chapter titles indented under each part.
>
> HTH
> —
> Bruce Horrocks
> Hampshire, UK
>
>
>
> —
> 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
>
> ___
>


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