
Hello list, I remember having read something about this, but I can't remember where: I need to prevent the next \par. The context (lowercase) is XML typesetting, where sometimes I want to concatenate two paragraphs in a particular typesetting, while keeping the original structure of the document (two distinct paragraphs). To give you an idea, in XHTML it could be something like this: ----------- <p>This is a paragraph.<?injecttex \preventpar ?></p> <p>This is the next paragraph.</p> ----------- Massi

Am 18.06.25 um 11:41 schrieb mf:
Hello list, I remember having read something about this, but I can't remember where: I need to prevent the next \par.
The context (lowercase) is XML typesetting, where sometimes I want to concatenate two paragraphs in a particular typesetting, while keeping the original structure of the document (two distinct paragraphs).
To give you an idea, in XHTML it could be something like this: ----------- <p>This is a paragraph.<?injecttex \preventpar ?></p> <p>This is the next paragraph.</p> -----------
Does \blank[nowhite,disable,back] help? Or \removeunwantedspaces ? Hraban

Am 18.06.2025 um 11:41 schrieb mf:
Hello list, I remember having read something about this, but I can't remember where: I need to prevent the next \par.
The context (lowercase) is XML typesetting, where sometimes I want to concatenate two paragraphs in a particular typesetting, while keeping the original structure of the document (two distinct paragraphs).
To give you an idea, in XHTML it could be something like this: ----------- <p>This is a paragraph.<?injecttex \preventpar ?></p> <p>This is the next paragraph.</p> -----------
\starttext First paragraph. \ignorepars Second paragraph. Third paragraph. \stoptext Wolfgang

Thanks Hraban and Wolfgang. \ignorepars is what I was looking for, though I realized it must be the last thing in the paragraph. Currently it does not work with my xml setup for paragraphs: \startxmlsetups xml:Para \dontleavehmode\xmlflush{#1}\resetcharacterkerning\strut\par \stopxmlsetups \resetcharacterkerning can be put after the \par. \strut prevents the last line from having no depth in case there are no letter with descendants. I think that could be set globally... but how? Massi Il 18/06/25 16:04, Wolfgang Schuster ha scritto:
Am 18.06.2025 um 11:41 schrieb mf:
Hello list, I remember having read something about this, but I can't remember where: I need to prevent the next \par.
The context (lowercase) is XML typesetting, where sometimes I want to concatenate two paragraphs in a particular typesetting, while keeping the original structure of the document (two distinct paragraphs).
To give you an idea, in XHTML it could be something like this: ----------- <p>This is a paragraph.<?injecttex \preventpar ?></p> <p>This is the next paragraph.</p> -----------
\starttext
First paragraph. \ignorepars
Second paragraph.
Third paragraph.
\stoptext
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________

Am 18.06.25 um 23:28 schrieb mf:
Thanks Hraban and Wolfgang.
\ignorepars is what I was looking for, though I realized it must be the last thing in the paragraph.
Currently it does not work with my xml setup for paragraphs:
\startxmlsetups xml:Para \dontleavehmode\xmlflush{#1}\resetcharacterkerning\strut\par \stopxmlsetups
\resetcharacterkerning can be put after the \par.
\strut prevents the last line from having no depth in case there are no letter with descendants. I think that could be set globally... but how?
Sounds like a case for \appendtoks … \to\everypar, but I’m not sure… Hraban

On Wed, 18 Jun 2025, mf wrote:
Thanks Hraban and Wolfgang.
\ignorepars is what I was looking for, though I realized it must be the last thing in the paragraph.
Currently it does not work with my xml setup for paragraphs:
\startxmlsetups xml:Para \dontleavehmode\xmlflush{#1}\resetcharacterkerning\strut\par \stopxmlsetups
\resetcharacterkerning can be put after the \par.
\strut prevents the last line from having no depth in case there are no letter with descendants. I think that could be set globally... but how?
Wouldn't something like this be simpler and more in spirit of separating intent from presentation? (I don't remember the XML syntax, so just conveying the high-level idea) <Para> ... </Para> is normal paragraph while <Para par="false"> is the paragraph where you don't want to insert a para. Then you can do something like: \startxmlsetups xml:Para ... \xmlflush{#1}% check if attribute par is not false ... insert \par \stopxmlsetups Aditya

Am 18.06.2025 um 23:28 schrieb mf:
Thanks Hraban and Wolfgang.
\ignorepars is what I was looking for, though I realized it must be the last thing in the paragraph.
Currently it does not work with my xml setup for paragraphs:
\startxmlsetups xml:Para \dontleavehmode\xmlflush{#1}\resetcharacterkerning\strut\par \stopxmlsetups
\resetcharacterkerning can be put after the \par.
There is also \begstrut ... \endstrut but this should only be necessary when you put text in a box.
\strut prevents the last line from having no depth in case there are no letter with descendants. I think that could be set globally... but how?
You can use a flag to call \ignorepars at the end of the paragraph. %%%% begin example \newconditional\IgnoreParagraph \IgnoreParagraph\conditionaltrue \starttext First paragraph. \ifconditional\IgnoreParagraph \IgnoreParagraph\conditionalfalse \ignorepars \fi Second paragraph. Third paragraph. \stoptext %%%% end example Wolfgang

Thanks Hraban, Aditya and Wolfgang. Wolfgang's solution lets me keep the \ignorepars just before the end of the paragraph, and it also auto-resets. Adding the following definition: \def\IgnoreNextPar{\IgnoreParagraph\conditionaltrue} I can switch on the "ignore next \par" everywhere in the paragraph. In my particular case, the \IgnoreNextPar would be the content of a RawInline in a Pandoc document, that would be automatically discarded for any output but ConTeXt. Massi Il 19/06/25 11:18, Wolfgang Schuster ha scritto:
Am 18.06.2025 um 23:28 schrieb mf:
Thanks Hraban and Wolfgang.
\ignorepars is what I was looking for, though I realized it must be the last thing in the paragraph.
Currently it does not work with my xml setup for paragraphs:
\startxmlsetups xml:Para \dontleavehmode\xmlflush{#1}\resetcharacterkerning\strut\par \stopxmlsetups
\resetcharacterkerning can be put after the \par.
There is also
\begstrut ... \endstrut
but this should only be necessary when you put text in a box.
\strut prevents the last line from having no depth in case there are no letter with descendants. I think that could be set globally... but how?
You can use a flag to call \ignorepars at the end of the paragraph.
%%%% begin example \newconditional\IgnoreParagraph \IgnoreParagraph\conditionaltrue
\starttext
First paragraph. \ifconditional\IgnoreParagraph \IgnoreParagraph\conditionalfalse \ignorepars \fi
Second paragraph.
Third paragraph.
\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 / https://mailman.ntg.nl/mailman3/lists/ ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________

On 6/18/2025 11:41 AM, mf wrote:
Hello list, I remember having read something about this, but I can't remember where: I need to prevent the next \par.
The context (lowercase) is XML typesetting, where sometimes I want to concatenate two paragraphs in a particular typesetting, while keeping the original structure of the document (two distinct paragraphs).
To give you an idea, in XHTML it could be something like this: ----------- <p>This is a paragraph.<?injecttex \preventpar ?></p> <p>This is the next paragraph.</p> -----------
Here is a weekend solution ... % Let's borrow some mwe as that was not provided: \startbuffer[test] <something> <what samepar="true"> one </what> <what> two </what> <what> three </what> <what> four </what> </something> \stopbuffer % some trivial mapping \startxmlsetups xml:mysetups \xmlsetsetup{#1}{something|what}{xml:*} \stopxmlsetups \xmlregistersetup{xml:mysetups} \startxmlsetups xml:something \xmlflush{#1} \stopxmlsetups % variant 1: \startxmlsetups xml:what \doifelse {\xmlattribute{#1}{./preceding-sibling::[-1]}{samepar}} {true} { \removeunwantedspaces \space \xmlflush{#1} } { \bpar \xmlflush{#1} \epar } \stopxmlsetups % variant 2: \startxmlsetups xml:what \xmldoifelse {#1} {./preceding-sibling::[-1][@samepar='true']} { \removeunwantedspaces \space \xmlflush{#1} } { \bpar \xmlflush{#1} \epar } \stopxmlsetups % variant 3: \startxmlsetups xml:what \ifxml {#1} {./preceding-sibling::[-1][@samepar='true']} \removeunwantedspaces \space \xmlflush{#1} \else \bpar \xmlflush{#1} \epar \fi \stopxmlsetups % let's test \starttext \xmlprocessbuffer{main}{test}{} \stoptext so, you can go verbose (variant 1), more efficient (variant 2), and even more effcicient in natural (emulated) tex speak. 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 -----------------------------------------------------------------

Thank you Hans, I'll keep these examples, because I always have problems writing lpaths, especially selecting along the siblings and ancestors axis. I usually switch to the lua side and work on the xml table, but this adds code and unnecessary complexity. In this particular case, though, I'm using paragraph concatenation to tweak typesetting problems that have no better alternative solution, like changing the lines count of a paragraph (+1/-1 working with penalties or space between glyphs), or vertical space around small titles (sacrificing the grid alignment locally). Since it slightly changes the contents of an original text, I don't want the tweak to become part of the text. To that respect, a Pandoc RawInline is a better solution than setting an attribute in a XML element, because it's clearly an alien element. And it's also format-specific (ConTeXt in this case), so when I convert the document to another format (e.g. HTML, DOCX, ICML) with Pandoc, the RawInline is simply discarded, and the paragraphs stick to the original text. Massi Il 20/06/25 15:38, Hans Hagen via ntg-context ha scritto:
On 6/18/2025 11:41 AM, mf wrote:
Hello list, I remember having read something about this, but I can't remember where: I need to prevent the next \par.
The context (lowercase) is XML typesetting, where sometimes I want to concatenate two paragraphs in a particular typesetting, while keeping the original structure of the document (two distinct paragraphs).
To give you an idea, in XHTML it could be something like this: ----------- <p>This is a paragraph.<?injecttex \preventpar ?></p> <p>This is the next paragraph.</p> -----------
Here is a weekend solution ...
% Let's borrow some mwe as that was not provided:
\startbuffer[test] <something> <what samepar="true"> one </what> <what> two </what> <what> three </what> <what> four </what> </something> \stopbuffer
% some trivial mapping
\startxmlsetups xml:mysetups \xmlsetsetup{#1}{something|what}{xml:*} \stopxmlsetups
\xmlregistersetup{xml:mysetups}
\startxmlsetups xml:something \xmlflush{#1} \stopxmlsetups
% variant 1:
\startxmlsetups xml:what \doifelse {\xmlattribute{#1}{./preceding-sibling::[-1]}{samepar}} {true} { \removeunwantedspaces \space \xmlflush{#1} } { \bpar \xmlflush{#1} \epar } \stopxmlsetups
% variant 2:
\startxmlsetups xml:what \xmldoifelse {#1} {./preceding-sibling::[-1][@samepar='true']} { \removeunwantedspaces \space \xmlflush{#1} } { \bpar \xmlflush{#1} \epar } \stopxmlsetups
% variant 3:
\startxmlsetups xml:what \ifxml {#1} {./preceding-sibling::[-1][@samepar='true']} \removeunwantedspaces \space \xmlflush{#1} \else \bpar \xmlflush{#1} \epar \fi \stopxmlsetups
% let's test
\starttext \xmlprocessbuffer{main}{test}{} \stoptext
so, you can go verbose (variant 1), more efficient (variant 2), and even more effcicient in natural (emulated) tex speak.
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://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Henning Hraban Ramm
-
mf
-
Wolfgang Schuster