
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 ___________________________________________________________________________________