[NTG-context] Re: more register questions!

2024-05-07 Thread Rik Kabel

Hello Wolfgang and all,

I have been trying to extend this to handle endnotes. So far, I have not 
succeeded; the number is always that of the last endnote.


I could possibly increment a counter for each endnote processed, but 
that seems a hack.


--
Rik

On 2024-05-03 06:18, Wolfgang Schuster wrote:

Thomas A. Schmitz schrieb am 02.05.2024 um 17:01:

Hi,

making wonderful progress on my registers and translating from xml. 
There is one thing I can't figure out (and I or some other good soul 
may have asked in the past...). Is it possible to mark occurrences in 
footnotes? Ideally, the entry in the register would look like


p. 100\high{20}

to show that the term occurs in note 20 on p. 100. But if that's 
asking too much, I would be content with applying a processor (say, 
italic) to these register entries. From the looks of the tuc file, 
Context doesn't appear to "know" that a register entry is within a 
footnote. But Hans never ceases to amaze me, so maybe there is a way 
(short of applying special markup to these notes in the source)?


You can play with the following example, the main point use to use the 
\setregisterentry command and pass the footnote counter with the third 
(optional) argument.


\def\IndexPageCommand#1%
  {#1\doifsomething
 {\currentregisterpageuserdata{footnote}}
 {\high{\currentregisterpageuserdata{footnote

\setupregister[index][pagecommand=\IndexPageCommand]

\starttext

\dorecurse{200}
{\samplefile{lorem}\expanded{\setregisterentry[index][entries=\recurselevel]}% 

\samplefile{lorem}\footnote{xxx\expanded{\setregisterentry[index][entries=\recurselevel][footnote={\rawcountervalue[footnote]}]}}% 


   \samplefile{lorem}}

\page \placeindex

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


[NTG-context] Re: more register questions!

2024-05-03 Thread Thomas A. Schmitz

Hi Wolfgang,

powerful and elegant, as always! I think I have a solution with xml; I 
will have to test it more extensively with my complex real file; but 
here comes, also for Hraban (if it works in real life, I'll add it to 
the wiki...).


Thanks a lot!

Thomas

\startbuffer[test]

  
Dummy text.Dummy footnote.
  
  
Dummy text.Dummy footnote.
  
  

\stopbuffer

\startxmlsetups xml:testsetups
  \xmlsetsetup{#1}{*}{-}
  \xmlsetsetup{#1}{document|chapter|p|footnote|indexentry|index}{xml:*}
\stopxmlsetups

\xmlregistersetup{xml:testsetups}

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

\startxmlsetups xml:chapter
  \xmlflush {#1} \page
\stopxmlsetups

\startxmlsetups xml:p
  \xmlflush {#1} \par
\stopxmlsetups

\startxmlsetups xml:footnote
  \footnote[\xmlatt{#1}{id}]{\xmlflush{#1}}
\stopxmlsetups

\startxmlsetups xml:indexentry
  \xmldoiftext {#1} {ancestor::footnote}
   {\setregisterentry 
[index][keys:1=\xmlatt{#1}{key},entries:1=\xmlatt{#1}{key}][footnote={\rawcountervalue[footnote]}]}


{\setregisterentry[index][keys:1=\xmlatt{#1}{key},entries:1=\xmlatt{#1}{key}]}
\stopxmlsetups

\startxmlsetups xml:index
  \page \placeregister [index]
\stopxmlsetups

\def\IndexPageCommand#1%
  {#1\doifsomething
 {\currentregisterpageuserdata{footnote}}
 {\high{\currentregisterpageuserdata{footnote

\setupregister[index][pagecommand=\IndexPageCommand]
\starttext
\xmlprocessbuffer{main}{test}{}
\stoptext




On 5/3/24 12:18, Wolfgang Schuster wrote:
You can play with the following example, the main point use to use the 
\setregisterentry command and pass the footnote counter with the third 
(optional) argument.


\def\IndexPageCommand#1%
   {#1\doifsomething
  {\currentregisterpageuserdata{footnote}}
  {\high{\currentregisterpageuserdata{footnote

\setupregister[index][pagecommand=\IndexPageCommand]

\starttext

\dorecurse{200}
{\samplefile{lorem}\expanded{\setregisterentry[index][entries=\recurselevel]}%
\samplefile{lorem}\footnote{xxx\expanded{\setregisterentry[index][entries=\recurselevel][footnote={\rawcountervalue[footnote]}]}}%
    \samplefile{lorem}}

\page \placeindex

\stoptext

Wolfgang


--
Prof. Dr. Thomas A. Schmitz
Institut für Klassische und Romanische Philologie
Universität Bonn
Rabinstr. 8
53111 Bonn
http://www.philologie.uni-bonn.de/de/personal/schmitz

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


[NTG-context] Re: more register questions!

2024-05-03 Thread Henning Hraban Ramm

Am 03.05.24 um 22:24 schrieb Thomas A. Schmitz:

Hi Massi,

yes, that was a very good idea! I can detect if the element  
occurs within a footnote by testing


\xmldoiftext {#1} {ancestor::footnote}

and then apply a processor to these entries. That would be a good 
solution for the time being.


Would you contribute the complete solution to the wiki?
I find the case quite interesting.

Hraban

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


[NTG-context] Re: more register questions!

2024-05-03 Thread Thomas A. Schmitz

Hi Massi,

yes, that was a very good idea! I can detect if the element  
occurs within a footnote by testing


\xmldoiftext {#1} {ancestor::footnote}

and then apply a processor to these entries. That would be a good 
solution for the time being.


Thanks and all best

Thomas

On 5/2/24 17:55, mf wrote:


I did something like that, with a processor that added a "n" after the 
occurrence page number.


Since you typeset XML, maybe you can detect that an index (register) 
reference happens inside a note from the DOM element you are typesetting.


Then you use a command like this:

\index[NoteProcessor->sortkey]{index term}

where NoteProcessor is defined like this:

\defineprocessor[NoteProcessor][right={\itx n}]

In this case I'm adding a smaller "n" to the right of the page number of 
the occurrence.


Adding the \high style is not difficult:

\defineprocessor[NoteProcessor][right=\high{n}]

but replacing a fixed "n" with the footnote number is quite challenging.

The second argument of \defineprocessor has a "command=\...##1" option 
that could be exploited, but I don't know exactly what gets passed to 
that custom command as ##1; maybe the page number of the occurrence.


In that case, I'd look for a way to store the association between that 
occurrence and the footnote number, and retrieve that in the custom 
command.


Massi


--
Prof. Dr. Thomas A. Schmitz
Institut für Klassische und Romanische Philologie
Universität Bonn
Rabinstr. 8
53111 Bonn
http://www.philologie.uni-bonn.de/de/personal/schmitz

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


[NTG-context] Re: more register questions!

2024-05-03 Thread Wolfgang Schuster

Thomas A. Schmitz schrieb am 02.05.2024 um 17:01:

Hi,

making wonderful progress on my registers and translating from xml. 
There is one thing I can't figure out (and I or some other good soul 
may have asked in the past...). Is it possible to mark occurrences in 
footnotes? Ideally, the entry in the register would look like


p. 100\high{20}

to show that the term occurs in note 20 on p. 100. But if that's 
asking too much, I would be content with applying a processor (say, 
italic) to these register entries. From the looks of the tuc file, 
Context doesn't appear to "know" that a register entry is within a 
footnote. But Hans never ceases to amaze me, so maybe there is a way 
(short of applying special markup to these notes in the source)?


You can play with the following example, the main point use to use the 
\setregisterentry command and pass the footnote counter with the third 
(optional) argument.


\def\IndexPageCommand#1%
  {#1\doifsomething
 {\currentregisterpageuserdata{footnote}}
 {\high{\currentregisterpageuserdata{footnote

\setupregister[index][pagecommand=\IndexPageCommand]

\starttext

\dorecurse{200}
{\samplefile{lorem}\expanded{\setregisterentry[index][entries=\recurselevel]}%
\samplefile{lorem}\footnote{xxx\expanded{\setregisterentry[index][entries=\recurselevel][footnote={\rawcountervalue[footnote]}]}}%
   \samplefile{lorem}}

\page \placeindex

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


[NTG-context] Re: more register questions!

2024-05-02 Thread mf



Il 02/05/24 17:01, Thomas A. Schmitz ha scritto:

Hi,

making wonderful progress on my registers and translating from xml. 
There is one thing I can't figure out (and I or some other good soul may 
have asked in the past...). Is it possible to mark occurrences in 
footnotes? Ideally, the entry in the register would look like


p. 100\high{20}

to show that the term occurs in note 20 on p. 100. But if that's asking 
too much, I would be content with applying a processor (say, italic) to 
these register entries. From the looks of the tuc file, Context doesn't 
appear to "know" that a register entry is within a footnote. But Hans 
never ceases to amaze me, so maybe there is a way (short of applying 
special markup to these notes in the source)?




I did something like that, with a processor that added a "n" after the 
occurrence page number.


Since you typeset XML, maybe you can detect that an index (register) 
reference happens inside a note from the DOM element you are typesetting.


Then you use a command like this:

\index[NoteProcessor->sortkey]{index term}

where NoteProcessor is defined like this:

\defineprocessor[NoteProcessor][right={\itx n}]

In this case I'm adding a smaller "n" to the right of the page number of 
the occurrence.


Adding the \high style is not difficult:

\defineprocessor[NoteProcessor][right=\high{n}]

but replacing a fixed "n" with the footnote number is quite challenging.

The second argument of \defineprocessor has a "command=\...##1" option 
that could be exploited, but I don't know exactly what gets passed to 
that custom command as ##1; maybe the page number of the occurrence.


In that case, I'd look for a way to store the association between that 
occurrence and the footnote number, and retrieve that in the custom command.


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