ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \footnote and \note with \setupnotation[way=bypage], but it does not work with XML processing
@ 2015-07-02 21:51 mf
  0 siblings, 0 replies; only message in thread
From: mf @ 2015-07-02 21:51 UTC (permalink / raw)
  To: ntg-context

Hello list,
I have a text with footnotes that get referenced more than once.
No problem for ConTeXt, since it has \footnote and \note for that.

Resetting the footnote counter every page with
\setupnotation[way=bypage] complicates the problem, because when you
call \note on the next page, it prints the value of the counter that
the footnote had in the previous page, when it should produce a new
\footnote instead for the new page.

Running this example should show the problem more clearly:


\setupnotation[way=bypage]

\def\showcountersinmargin#1{%
  \inmargin{\rawcountervalue[contapag#1].\rawcountervalue[#1]}%
}
  
\def\showidinmargin#1{%
  \inrightmargin{ #1}%
}

\def\mynotelabel#1{#1pag\rawcountervalue[contapag#1]}
  
\def\myfootnote#1#2{%
  \definenumber[contapag#1][prefix=no]%
  \incrementcounter[contapag#1]%
  \definenumber[#1][way=bypage,prefix=no]%
  \incrementcounter[#1]%
  \footnote[\mynotelabel{#1}]{#2}%
  \showcountersinmargin{#1}%
  \showidinmargin{\mynotelabel{#1}}%
}
  
\def\mynote#1#2{%
  \incrementcounter[#1]%
  \doifelse{\rawcountervalue[#1]}{1}{%
    \incrementcounter[contapag#1]%
    \footnote[\mynotelabel{#1}]{#2}%
    \showcountersinmargin{#1}%
    \showidinmargin{\mynotelabel{#1}}%
  }{%
    \note[\mynotelabel{#1}]%
    \showcountersinmargin{#1}%
    \showidinmargin{\mynotelabel{#1}}%
  }%
}

\starttext
 
\def\fnid{id1}
\def\fntext{Text of the recurring footnote}

  Using just \verbatim{\footnote}\footnote[\fnid]{\fntext}
  and than \verbatim{\note}\note[\fnid] even in...
  \page
  ... the new page\footnote[otherid]{another footnote} does not 
  work\note[\fnid](here different footnotes are referred
  with the same number because I used \verbatim{\note} to
  reference a footnote of the previous page).

  
  {\bf The text above should have been like this:}\par
  ... the new page\note[otherid] does not 
  work\footnote{\fntext}.

  \page
  Using \verbatim{\myfootnote} and \verbatim{\mynote} it
  works as expected:

  Some text before the first occurrence of my recurring 
  footnote\myfootnote{\fnid}{\fntext}.
  
  Some other text, with a new occurrence of my recurring
  footnote\mynote{\fnid}{\fntext}.

\dorecurse{5}{
  \page[yes] % new page
  
  \getrandomnumber \n {1} {7}
  \dorecurse{\n}{
  Other text\footnote{other disturbing footnote}.\par
  }
  
  A new occurrence of the previous 
  footnote\mynote{\fnid}{\fntext}.

  \getrandomnumber \n {1} {7}
  \dorecurse{\n}{
  Other text\footnote{other disturbing footnote}.\par
  }
  
  Another occurrence of the previous 
  footnote\mynote{\fnid}{\fntext},
  to see if it gets referenced right.%
}

\stoptext

My functions (\myfootnote and \mynote) solve the problem, at least with
version 2014.05.21 of ConTeXt (recent versions seem to have this bug: 
http://www.ntg.nl/pipermail/ntg-context/2015/082498.html).

Now my problem is that I can't get the same code working in XML(XHTML)
processing. Here's a recurring footnote in XHTML:

<span class="footnote" id="id1">Text of the recurring footnote</span>

for the first occurrence, and

<span class="footnote" idref="id1">Text of the recurring
footnote</span>

for all the other occurrences of the same footnote.

These are my corresponding XML setups in ConTeXt:

\startxmlsetups xml:span:footnote:id
  \myfootnote{\xmlatt{#1}{id}}{\xmlflush{#1}}
\stopxmlsetups

\startxmlsetups xml:span:footnote:idref
  \mynote{\xmlatt{#1}{idref}}{\xmlflush{#1}}
\stopxmlsetups

Used in XML processing, the counters "go crazy" and I get "??" instead
of the right footnote numbers in the text.
Any hints?

Thanks in advance,
MF
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-02 21:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-02 21:51 \footnote and \note with \setupnotation[way=bypage], but it does not work with XML processing mf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).