[NTG-context] CSS selector for elements strictly preceded by other elements

Hans Hagen j.hagen at xs4all.nl
Sat Aug 4 12:10:48 CEST 2018


On 8/3/2018 4:31 PM, MF wrote:
> 
>> make a (real) minimal example and we'll see what can be done
>>
> 
> Here it is:
> 
> \startbuffer[test]
> <body>
>    <p>In this paragraph<footnote>first footnote</footnote><endnote>endnote strictly
>    following a footnote (no other XML nodes between them)</endnote>
>    a footnote marker and an endnote marker are at the same point in the text;
>    in the XML source, their elements are contiguous, with nothing in between.
>    The CSS selector <code>footnote + endnote</code> works right, and the setup
>    associated to that selector puts a comma between their markers to
>    separate them in the typesetting.</p>
> 
>    <p>In this paragraph<footnote>second footnote</footnote> they don't occur at the
>    same point in the text<endnote>endnote comes after footnote: there's some
>    text between them, but no XML elements</endnote>;
>    for the CSS selector <code>footnote + endnote</code> it's the same case of the previous paragraph,
>    because there's no other XML element between the <code>footnote</code> and the
>    <code>endnote</code> elements: that's why you still see a comma before
>    the endnote's marker, but this time it's not what I want.</p>
> 
>    <p>In this paragraph<footnote>third footnote</footnote> they don't occur at the
>    same point in the text, and the CSS selector <code>footnote + endnote</code>
>    does not match<endnote>endnote comes after footnote, but there are 3 nodes
>    between them: a text, a <code>code</code> element, another text</endnote>,
>    because there's a <code>code</code> element between <code>footnote</code>
>    and <code>endnote</code> elements.</p>
> 
>    <p>CSS has no operator to discriminate between the first two cases.</p>
> </body>
> \stopbuffer
> 
> \setupnotation[footnote][numberconversion=a]
> \setupwhitespace[line]
> 
> \startxmlsetups xml:notesetups
>    \xmlsetsetup{#1}{body|p|footnote|code}{xml:*}
>    \xmlsetsetup{#1}{{endnote}}{xml:endnote}
>    \xmlsetsetup{#1}{{footnote + endnote}}{xml:endnote-after-footnote}
> \stopxmlsetups
> 
> \xmlregistersetup{xml:notesetups}
> 
> \startxmlsetups xml:body
>    \xmlflush{#1}
> \stopxmlsetups
> 
> \startxmlsetups xml:p
>    \xmlflush{#1}\par
> \stopxmlsetups
> 
> \startxmlsetups xml:footnote
>    \footnote{\xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:code
>    {\tt\xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:endnote
>    \endnote{\xmlflush{#1}}
> \stopxmlsetups
> 
> \startxmlsetups xml:endnote-after-footnote
>    \high{,}\endnote{\xmlflush{#1}}
> \stopxmlsetups
> 
> \starttext
>    \xmlprocessbuffer{main}{test}{}
>    \page
>    \placenotes[endnote]
> \stoptext

The obvious ...

\setupnotes[textseparator={, }]

\startxmlsetups xml:notesetups
     \xmlsetsetup{#1}{body|p|footnote|endnote|code}{xml:*}
\stopxmlsetups

\startxmlsetups xml:endnote
     \endnote{\xmlflush{#1}}
\stopxmlsetups

\startxmlsetups xml:footnote
     \footnote{\xmlflush{#1}}
\stopxmlsetups




-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list