\par and \startlines
Hi, I'm trying to typeset a poem from XML, but I can't figure out how to make the inbetween key working here. As the source is XML, I cannot just add an empty line to start a new group of lines inside \startlines...\stoplines. I guess, there must be a command to do that, but \par seems to have no effect here. How can this be done? Best, Denis %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \setuplines[before={\blank},after={\blank},inbetween={ARE WE INBETWEEN?\blank}] % XML Nodes auswählen \startxmlsetups xml:test \xmlsetsetup{#1}{*}{-} \xmlsetsetup{#1}{doc|poem|stanza|line}{xml:*} \stopxmlsetups \xmlregistersetup{xml:test} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:poem \startlines \xmlflush{#1} \stoplines \stopxmlsetups \startxmlsetups xml:stanza \xmlflushlinewise{#1}\par %this has no effect \stopxmlsetups \startxmlsetups xml:line \xmlflush{#1} \stopxmlsetups \startbuffer[test] <?xml version='1.0' standalone='yes?> <doc> <poem> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> </poem> </doc> \stopbuffer \starttext This works: \startlines The lines are there! The lines are there! \stoplines Apparently, \type{\par} has no effect here: \startlines The lines are there!\par% \par has no effect here The lines are there! \stoplines For background, this is what I'm actually trying to do: \xmlprocessbuffer{test}{test}{} \stoptext %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
On 4/26/24 15:33, denis.maier@unibe.ch wrote:
Hi,
I’m trying to typeset a poem from XML, but I can’t figure out how to make the inbetween key working here.
As the source is XML, I cannot just add an empty line to start a new group of lines inside \startlines…\stoplines. I guess, there must be a command to do that, but \par seems to have no effect here.
How can this be done?
Hi Denis, I must confess I don’t get which is your actual question. \blank works here and you know that (since you included it in your code). MkIV with \par works in your sample and LMTX with \par doesn’t. I wonder whether this might be a bug in LMTX. Just in case it might help, Pablo
Denis Maier via ntg-context schrieb am 26.04.2024 um 18:10:
Pablo Rodriguez via ntg-context
mailto:ntg-context@ntg.nl> hat am 26.04.2024 17:25 CEST geschrieben: On 4/26/24 15:33, denis.maier@unibe.ch mailto:denis.maier@unibe.ch wrote: Hi, I’m trying to typeset a poem from XML, but I can’t figure out how to make the inbetween key working here. As the source is XML, I cannot just add an empty line to start a new group of lines inside \startlines…\stoplines. I guess, there must be a command to do that, but \par seems to have no effect here. How can this be done? Hi Denis, I must confess I don’t get which is your actual question. \blank works here and you know that (since you included it in your code). MkIV with \par works in your sample and LMTX with \par doesn’t. I wonder whether this might be a bug in LMTX. Just in case it might help, Thanks for your answer and sorry for not being clearer. I was just wondering why the \par seems to have no effect. (I first guessed that it might be related to XML, to but then realized it happens with context markup as well. Usually, you won't run into this because an empty line works, but with XML that's not am option.) As you've said, it looks like a bug then.
The lines environment treats each line of the input as paragraph by adding \par at the end of it and adding another \par makes no difference here. BTW: ConTeXt has a module for poems which can be loaded with \usemodule[format]. Wolfgang
Denis Maier schrieb am 26.04.2024 um 19:18:
Wolfgang Schuster
hat am 26.04.2024 18:24 CEST geschrieben: Denis Maier via ntg-context schrieb am 26.04.2024 um 18:10: Hi, I’m trying to typeset a poem from XML, but I can’t figure out how to make the inbetween key working here. As the source is XML, I cannot just add an empty line to start a new group of lines inside \startlines…\stoplines. I guess, there must be a command to do that, but \par seems to have no effect here. How can this be done? Hi Denis, I must confess I don’t get which is your actual question. \blank works here and you know that (since you included it in your code). MkIV with \par works in your sample and LMTX with \par doesn’t. I wonder whether this might be a bug in LMTX. Just in case it might help, Thanks for your answer and sorry for not being clearer. I was just wondering why the \par seems to have no effect. (I first guessed
Pablo Rodriguez via ntg-context
mailto:ntg-context@ntg.nl> hat am 26.04.2024 17:25 CEST geschrieben: On 4/26/24 15:33, denis.maier@unibe.ch mailto:denis.maier@unibe.ch wrote: that it might be related to XML, to but then realized it happens with context markup as well. Usually, you won't run into this because an empty line works, but with XML that's not am option.) As you've said, it looks like a bug then. The lines environment treats each line of the input as paragraph by adding \par at the end of it and adding another \par makes no difference here.
BTW: ConTeXt has a module for poems which can be loaded with \usemodule[format].
Wolfgang
Ok. I'll have a look at this module. Just two questions: 1. so did this behavior change? 2. What is inbetween referring to then? If each line is a paragraph, what's this group of paragraphs then? Can you manually switch to the next one?
The inbetween setting works because ConTeXt checks at the start of each line whether it's empty (in this case the value is used) or not. When you add a \par you just end the current line/paragraph and it doesn't matter how many \par's you use because TeX just ignores them. Wolfgang
On 4/26/24 19:52, Denis Maier via ntg-context wrote:
Wolfgang Schuster hat am 26.04.2024 19:29 CEST geschrieben: The inbetween setting works because ConTeXt checks at the start of each line whether it's empty (in this case the value is used) or not.
When you add a \par you just end the current line/paragraph and it doesn't matter how many \par's you use because TeX just ignores them. I see. But there's no command that could be used to simulate an empty line?
Crappy code: \starttext a\dorecurse{25}{\par}b a\dorecurse{25}{\null\par}b \stoptext Just to show it could be achieved, Pablo
Denis Maier schrieb am 26.04.2024 um 19:52:
I see. But there's no command that could be used to simulate an empty line? If not, me should I perhaps try to replicate the wrapper structure from the XML source in context? (I'll also look into the format module of course.) What do you think?
Below is a different solution to your problem with works without \startlines because you already mark up each individual line in the poem which make it possible to add a linebreak in the output. With \blank options (samepage) you can avoid pagebreaks between stanzas. \startxmlsetups xml:test \xmlsetsetup{#1}{*}{-} \xmlsetsetup{#1}{doc|poem|stanza|line}{xml:*} \stopxmlsetups \xmlregistersetup{xml:test} \startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:poem \blank[line] \xmlflush{#1} \blank[back,line] \stopxmlsetups \startxmlsetups xml:stanza \xmlflush{#1}\blank[preference,line] \stopxmlsetups \startxmlsetups xml:line \xmlflush{#1}\blank[samepage,none] \stopxmlsetups \startbuffer[test] <?xml version='1.0' standalone='yes?> <doc> <poem> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> </poem> </doc> \stopbuffer \starttext \samplefile{lorem} \xmlprocessbuffer{test}{test}{} \samplefile{lorem} \stoptext Wolfgang
-----Ursprüngliche Nachricht----- Von: Wolfgang Schuster
Gesendet: Samstag, 27. April 2024 07:40 An: Denis Maier Cc: mailing list for ConTeXt users Betreff: Re: [NTG-context] Re: \par and \startlines Denis Maier schrieb am 26.04.2024 um 19:52:
I see. But there's no command that could be used to simulate an empty line? If not, me should I perhaps try to replicate the wrapper structure from the XML source in context? (I'll also look into the format module of course.) What do you think?
Below is a different solution to your problem with works without \startlines because you already mark up each individual line in the poem which make it possible to add a linebreak in the output.
With \blank options (samepage) you can avoid pagebreaks between stanzas.
\startxmlsetups xml:test \xmlsetsetup{#1}{*}{-} \xmlsetsetup{#1}{doc|poem|stanza|line}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:test}
\startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:poem \blank[line] \xmlflush{#1} \blank[back,line] \stopxmlsetups
\startxmlsetups xml:stanza \xmlflush{#1}\blank[preference,line] \stopxmlsetups
\startxmlsetups xml:line \xmlflush{#1}\blank[samepage,none] \stopxmlsetups
\startbuffer[test] <?xml version='1.0' standalone='yes?> <doc> <poem> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> </poem> </doc> \stopbuffer
\starttext
\samplefile{lorem}
\xmlprocessbuffer{test}{test}{}
\samplefile{lorem}
\stoptext
Thanks for this solution. I've had a quick look, and it seems to do exactly what I need. My requirements are rather simple at the moment, but that should be sufficient, but to repeat Hraban's question: What would be the advantage of using the format module? Thanks again for your help, Denis
denismaier@mailbox.org schrieb am 30.04.2024 um 14:28:
-----Ursprüngliche Nachricht----- Von: Wolfgang Schuster
Gesendet: Samstag, 27. April 2024 07:40 An: Denis Maier Cc: mailing list for ConTeXt users Betreff: Re: [NTG-context] Re: \par and \startlines Denis Maier schrieb am 26.04.2024 um 19:52:
I see. But there's no command that could be used to simulate an empty line? If not, me should I perhaps try to replicate the wrapper structure from the XML source in context? (I'll also look into the format module of course.) What do you think? Below is a different solution to your problem with works without \startlines because you already mark up each individual line in the poem which make it possible to add a linebreak in the output.
With \blank options (samepage) you can avoid pagebreaks between stanzas.
\startxmlsetups xml:test \xmlsetsetup{#1}{*}{-} \xmlsetsetup{#1}{doc|poem|stanza|line}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:test}
\startxmlsetups xml:doc \xmlflush{#1} \stopxmlsetups
\startxmlsetups xml:poem \blank[line] \xmlflush{#1} \blank[back,line] \stopxmlsetups
\startxmlsetups xml:stanza \xmlflush{#1}\blank[preference,line] \stopxmlsetups
\startxmlsetups xml:line \xmlflush{#1}\blank[samepage,none] \stopxmlsetups
\startbuffer[test] <?xml version='1.0' standalone='yes?> <doc> <poem> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> <stanza> <line>The</line> <line>lines</line> <line>are</line> <line>there!</line> </stanza> </poem> </doc> \stopbuffer
\starttext
\samplefile{lorem}
\xmlprocessbuffer{test}{test}{}
\samplefile{lorem}
\stoptext Thanks for this solution. I've had a quick look, and it seems to do exactly what I need. My requirements are rather simple at the moment, but that should be sufficient, but to repeat Hraban's question: What would be the advantage of using the format module?
The module provides features like - alignment of the verse lines - numbering of the lines (which isn't supported by \startlines unless you add the normal linenumbering mechanism) - support for lines which don't fit on a single page where the consecutive lines are indented but the module is outdated and relies on an old mkii style code base. A big difference between the \startlines environment and the format module is that the first treats each line in the input file as a separate line in the output while the format module requires begin/end tags for each line which works better for xml input. Wolfgang
Am 01.05.24 um 09:44 schrieb Wolfgang Schuster:
but that should be sufficient, but to repeat Hraban's question: What would be the advantage of using the format module?
The module provides features like
- alignment of the verse lines - numbering of the lines (which isn't supported by \startlines unless you add the normal linenumbering mechanism) - support for lines which don't fit on a single page where the consecutive lines are indented
but the module is outdated and relies on an old mkii style code base.
A big difference between the \startlines environment and the format module is that the first treats each line in the input file as a separate line in the output while the format module requires begin/end tags for each line which works better for xml input.
Thank you! Doesn’t sound like I should use it… Hraban
Am 26.04.24 um 18:24 schrieb Wolfgang Schuster:
BTW: ConTeXt has a module for poems which can be loaded with \usemodule[format].
Never heard of it. Version says “ancient” ;) https://source.contextgarden.net/tex/context/modules/mkiv/m-format.mkiv What’s the advantage of all this markup over simple "lines" (or even \par after each line)? I’ll need to typeset a book of poetry soon, that will probably need a lot of different indentation/aligments… Hraban
participants (6)
-
Denis Maier
-
denis.maier@unibe.ch
-
denismaier@mailbox.org
-
Henning Hraban Ramm
-
Pablo Rodriguez
-
Wolfgang Schuster