ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* dealing with footnotes and ol in XML
@ 2015-01-09 10:41 Pablo Rodriguez
  2015-01-09 11:18 ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2015-01-09 10:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Dear list,

I have the following sample:

\startbuffer[demo]
<doc>

    <p>This is the first paragraph.</p>

    <ol>
        <li><p>first item</p></li>
        <li><p>second item</p></li>
    </ol>

    <p>text with footnote<a href="#fn1" class="footnoteRef"
id="fnref1"><sup>1</sup></a></p>

    <p>text with another footnote<a href="#fn2" class="footnoteRef"
id="fnref2"><sup>2</sup></a></p>

    <div class="footnotes">
    <hr />
        <ol>
            <li id="fn1"><p>footnote text</p>
            <p>In two paragraphs<a href="#fnref1">↩</a></p></li>

            <li id="fn2"><p>footnote text</p>
            <p>In two paragraphs<a href="#fnref2">↩</a></p></li>
        </ol>
    </div>

</doc>
\stopbuffer

\starttext

\usemodule[html]

\startxmlsetups xml:initialize
    \xmlsetsetup{#1}{*}{xml:*}
    \xmlsetsetup{\xmldocument}{a[@class='footnoteRef']}{xml:footnote}

\stopxmlsetups

\xmlregistersetup{xml:initialize}

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

\startxmlsetups xml:footnote
    \startfootnote

\xmlfirst{main}{div[@class='footnotes']/ol/li[@id=string.sub('\xmlatt{#1}{href}',2)]}
    \stopfootnote
\stopxmlsetups

\setupitemize[margin=yes]

\xmlprocessbuffer{main}{demo}{}

\stoptext

The first issue I’m experiencing is that I don’t know how to avoid that
footnotes (implemented in XML as items in an ordered list) are also
typeset as list items. Footnotes may be inside lists or contain lists,
but footnotes themselves are only implemented as lists. The only way I
know is to disable lists, but this is not an option.

The second issue is that \setupitemize[margin=yes] doesn’t work. What am
I missing here?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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] 7+ messages in thread

* Re: dealing with footnotes and ol in XML
  2015-01-09 10:41 dealing with footnotes and ol in XML Pablo Rodriguez
@ 2015-01-09 11:18 ` Hans Hagen
  2015-01-09 11:29   ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2015-01-09 11:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 1/9/2015 11:41 AM, Pablo Rodriguez wrote:
> Dear list,
>
> I have the following sample:
>
> \startbuffer[demo]
> <doc>
>
>      <p>This is the first paragraph.</p>
>
>      <ol>
>          <li><p>first item</p></li>
>          <li><p>second item</p></li>
>      </ol>
>
>      <p>text with footnote<a href="#fn1" class="footnoteRef"
> id="fnref1"><sup>1</sup></a></p>
>
>      <p>text with another footnote<a href="#fn2" class="footnoteRef"
> id="fnref2"><sup>2</sup></a></p>
>
>      <div class="footnotes">
>      <hr />
>          <ol>
>              <li id="fn1"><p>footnote text</p>
>              <p>In two paragraphs<a href="#fnref1">↩</a></p></li>
>
>              <li id="fn2"><p>footnote text</p>
>              <p>In two paragraphs<a href="#fnref2">↩</a></p></li>
>          </ol>
>      </div>
>
> </doc>
> \stopbuffer
>
> \starttext
>
> \usemodule[html]
>
> \startxmlsetups xml:initialize
>      \xmlsetsetup{#1}{*}{xml:*}
>      \xmlsetsetup{\xmldocument}{a[@class='footnoteRef']}{xml:footnote}
>
> \stopxmlsetups
>
> \xmlregistersetup{xml:initialize}
>
> \startxmlsetups xml:doc
>       \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:footnote
>      \startfootnote
>
> \xmlfirst{main}{div[@class='footnotes']/ol/li[@id=string.sub('\xmlatt{#1}{href}',2)]}
>      \stopfootnote
> \stopxmlsetups
>
> \setupitemize[margin=yes]
>
> \xmlprocessbuffer{main}{demo}{}
>
> \stoptext
>
> The first issue I’m experiencing is that I don’t know how to avoid that
> footnotes (implemented in XML as items in an ordered list) are also
> typeset as list items. Footnotes may be inside lists or contain lists,
> but footnotes themselves are only implemented as lists. The only way I
> know is to disable lists, but this is not an option.

\startbuffer[demo]
<doc>
     <p>This is the first paragraph.</p>
     <ol>
         <li><p>first item</p></li>
         <li><p>second item</p></li>
     </ol>
     <p>text with footnote<a href="#fn1" class="footnoteRef" 
id="fnref1"><sup>1</sup></a></p>
     <p>text with another footnote<a href="#fn2" class="footnoteRef" 
id="fnref2"><sup>2</sup></a></p>
     <div class="footnotes">
         <hr/>
         <ol>
             <li id="fn1"><p>footnote text</p><p>In two paragraphs<a 
href="#fnref1">↩</a></p></li>
             <li id="fn2"><p>footnote text</p><p>In two paragraphs<a 
href="#fnref2">↩</a></p></li>
         </ol>
     </div>
</doc>
\stopbuffer

\starttext

\usemodule[html]

\xmlregistersetup{xml:html:basics}
\xmlregistersetup{xml:html:tables}

\startxmlsetups xml:initialize
     \xmlsetsetup{#1}{a[@class='footnoteRef']}{xml:footnote:ref}
     \xmlsetsetup{#1}{div[@class='footnotes']}{}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

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

\startxmlsetups xml:footnote:set
     \startfootnote
         \xmlflush{#1}
     \stopfootnote
\stopxmlsetups

\startxmlsetups xml:footnote:ref
 
\xmlfilter{main}{div[@class='footnotes']/ol/li[@id=string.sub('\xmlatt{#1}{href}',2)]/command(xml:footnote:set)}
\stopxmlsetups

\xmlprocessbuffer{main}{demo}{}

\stoptext



-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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 / 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] 7+ messages in thread

* Re: dealing with footnotes and ol in XML
  2015-01-09 11:18 ` Hans Hagen
@ 2015-01-09 11:29   ` Hans Hagen
  2015-01-09 12:24     ` Pablo Rodriguez
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2015-01-09 11:29 UTC (permalink / raw)
  To: ntg-context; +Cc: Thomas A. Schmitz

On 1/9/2015 12:18 PM, Hans Hagen wrote:

> \startxmlsetups xml:footnote:ref
> \xmlfilter{main}{div[@class='footnotes']/ol/li[@id=string.sub('\xmlatt{#1}{href}',2)]/command(xml:footnote:set)}
> \stopxmlsetups

I'll add this:

\startluacode
     local gsub = string.gsub
     function xml.expressions.idstring(str)
         return type(str) == "string" and gsub(str,"^#","") or ""
     end
\stopluacode

\startxmlsetups xml:footnote:ref
 
\xmlfilter{main}{div[@class='footnotes']/ol/li[@id=idstring('\xmlatt{#1}{href}')]/command(xml:footnote:set)}
\stopxmlsetups

As this id stuff happens more often.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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 / 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] 7+ messages in thread

* Re: dealing with footnotes and ol in XML
  2015-01-09 11:29   ` Hans Hagen
@ 2015-01-09 12:24     ` Pablo Rodriguez
  2015-01-10 13:01       ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2015-01-09 12:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 01/09/2015 12:29 PM, Hans Hagen wrote:
> [...]
> I'll add this:
> 
> \startluacode
>      local gsub = string.gsub
>      function xml.expressions.idstring(str)
>          return type(str) == "string" and gsub(str,"^#","") or ""
>      end
> \stopluacode
> 
> \startxmlsetups xml:footnote:ref
>  
> \xmlfilter{main}{div[@class='footnotes']/ol/li[@id=idstring('\xmlatt{#1}{href}')]/command(xml:footnote:set)}
> \stopxmlsetups
> 
> As this id stuff happens more often.

Many thanks for your reply and the code, Hans.

I have an issue with multiparagraph footnotes. Here is the sample in
ConTeXt code:

\setuppapersize[A7]
\setupbodyfont[15pt]
\starttext
\dorecurse{2}{A footnote\footnote
{\dorecurse{2}{Footnote paragraph.\par}}}
\dorecurse{3}{B footnote\footnote
{Footnote paragraph.\par Footnote paragraph.}}
\stoptext

Footnotes that end with \par have wrong space with next footnote.

I don’t know whether this is intended. How could I avoid that in XML?

Many thanks for your help again,


Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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] 7+ messages in thread

* Re: dealing with footnotes and ol in XML
  2015-01-09 12:24     ` Pablo Rodriguez
@ 2015-01-10 13:01       ` Hans Hagen
  2015-01-11 21:01         ` Pablo Rodriguez
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2015-01-10 13:01 UTC (permalink / raw)
  To: ntg-context

On 1/9/2015 1:24 PM, Pablo Rodriguez wrote:
> On 01/09/2015 12:29 PM, Hans Hagen wrote:
>> [...]
>> I'll add this:
>>
>> \startluacode
>>       local gsub = string.gsub
>>       function xml.expressions.idstring(str)
>>           return type(str) == "string" and gsub(str,"^#","") or ""
>>       end
>> \stopluacode
>>
>> \startxmlsetups xml:footnote:ref
>>
>> \xmlfilter{main}{div[@class='footnotes']/ol/li[@id=idstring('\xmlatt{#1}{href}')]/command(xml:footnote:set)}
>> \stopxmlsetups
>>
>> As this id stuff happens more often.
>
> Many thanks for your reply and the code, Hans.
>
> I have an issue with multiparagraph footnotes. Here is the sample in
> ConTeXt code:
>
> \setuppapersize[A7]
> \setupbodyfont[15pt]
> \starttext
> \dorecurse{2}{A footnote\footnote
> {\dorecurse{2}{Footnote paragraph.\par}}}
> \dorecurse{3}{B footnote\footnote
> {Footnote paragraph.\par Footnote paragraph.}}
> \stoptext
>
> Footnotes that end with \par have wrong space with next footnote.
>
> I don’t know whether this is intended. How could I avoid that in XML?

well, more unexpected .. messing with the depth is always tricky

\unexpanded\def\handlenoteitself#tag#id%
   {\edef\currentnotenumber{#id}%
    \edef\currentnote{#tag}%
    \strc_constructions_initialize{#tag}%
    \strc_notes_synchronize
 
\edef\currentconstructionlistentry{\ctxcommand{notelistindex("\currentnote",#id)}}% 

    \reinstateconstructionnumberentry\currentconstructionlistentry
    \dontcomplain
    \strc_notes_interaction_check_display
    \strc_notes_set_reference_attribute_text
    \strc_constructions_stored_start
    \begstrut
    \strc_references_flush_destination_nodes
    \strc_notes_set_destination_attribute_text
    \strc_notes_inject_text
    \ifvmode\obeydepth\else\endstrut\fi % \obeydepth is new per 2015-01-10
    \strc_constructions_stored_stop}



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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 / 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] 7+ messages in thread

* Re: dealing with footnotes and ol in XML
  2015-01-10 13:01       ` Hans Hagen
@ 2015-01-11 21:01         ` Pablo Rodriguez
  2015-01-11 21:58           ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2015-01-11 21:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 01/10/2015 02:01 PM, Hans Hagen wrote:
> On 1/9/2015 1:24 PM, Pablo Rodriguez wrote:
>> [...]
>> Footnotes that end with \par have wrong space with next footnote.
>>
>> I don’t know whether this is intended. How could I avoid that in XML?
> 
> well, more unexpected .. messing with the depth is always tricky

Many thanks for your code, Hans.

I’m afraid I cannot get it working:

\setupbodyfont[40pt]
\startbuffer[demo]
<doc>
     <p>text<a href="#fn1" class="footnoteRef"
id="fnref1"><sup>1</sup></a> with<a href="#fn2" class="footnoteRef"
id="fnref2"><sup>2</sup></a> footnotes<a href="#fn3" class="footnoteRef"
id="fnref3"><sup>3</sup></a></p>
     <div class="footnotes">
         <hr/>
         <ol>
             <li id="fn1"><p>footnote one</p><p>In two paragraphs<a
href="#fnref1">↩</a></p></li>
             <li id="fn2"><p>footnote two</p>In two paragraphs<a
href="#fnref2">↩</a></li>
             <li id="fn3"><p>footnote three</p><p>In two paragraphs<a
href="#fnref3">↩</a></p></li>
         </ol>
     </div>
</doc>
\stopbuffer

\starttext

\usemodule[html]

\xmlregistersetup{xml:html:basics}
\xmlregistersetup{xml:html:tables}

\startxmlsetups xml:initialize
     \xmlsetsetup{#1}{a[@class='footnoteRef']}{xml:footnote:ref}
     \xmlsetsetup{#1}{div[@class='footnotes']}{}
\stopxmlsetups

\xmlregistersetup{xml:initialize}

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

\startxmlsetups xml:footnote:set
     \startfootnote
         \xmlflush{#1}
     \stopfootnote
\stopxmlsetups

\startluacode
     local gsub = string.gsub
     function xml.expressions.idstring(str)
         return type(str) == "string" and gsub(str,"^#","") or ""
     end
\stopluacode

\startxmlsetups xml:footnote:ref
\xmlfilter{main}{div[@class='footnotes']/ol/li[@id=idstring('\xmlatt{#1}{href}')]/command(xml:footnote:set)}
\stopxmlsetups

\xmlprocessbuffer{main}{demo}{}

\unexpanded\def\handlenoteitself#tag#id%
   {\edef\currentnotenumber{#id}%
    \edef\currentnote{#tag}%
    \strc_constructions_initialize{#tag}%
    \strc_notes_synchronize


\edef\currentconstructionlistentry{\ctxcommand{notelistindex("\currentnote",#id)}}%

    \reinstateconstructionnumberentry\currentconstructionlistentry
    \dontcomplain
    \strc_notes_interaction_check_display
    \strc_notes_set_reference_attribute_text
    \strc_constructions_stored_start
    \begstrut
    \strc_references_flush_destination_nodes
    \strc_notes_set_destination_attribute_text
    \strc_notes_inject_text
    \ifvmode\obeydepth\else\endstrut\fi % \obeydepth new 2015-01-10
    \strc_constructions_stored_stop}

\stoptext

Sorry, but this is all Greek to me. What am I doing wrong here?

Many thanks for your help,


Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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] 7+ messages in thread

* Re: dealing with footnotes and ol in XML
  2015-01-11 21:01         ` Pablo Rodriguez
@ 2015-01-11 21:58           ` Hans Hagen
  0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2015-01-11 21:58 UTC (permalink / raw)
  To: ntg-context

On 1/11/2015 10:01 PM, Pablo Rodriguez wrote:
> On 01/10/2015 02:01 PM, Hans Hagen wrote:
>> On 1/9/2015 1:24 PM, Pablo Rodriguez wrote:
>>> [...]
>>> Footnotes that end with \par have wrong space with next footnote.
>>>
>>> I don’t know whether this is intended. How could I avoid that in XML?
>>
>> well, more unexpected .. messing with the depth is always tricky
>
> Many thanks for your code, Hans.
>
> I’m afraid I cannot get it working:
>
> \setupbodyfont[40pt]
> \startbuffer[demo]
> <doc>
>       <p>text<a href="#fn1" class="footnoteRef"
> id="fnref1"><sup>1</sup></a> with<a href="#fn2" class="footnoteRef"
> id="fnref2"><sup>2</sup></a> footnotes<a href="#fn3" class="footnoteRef"
> id="fnref3"><sup>3</sup></a></p>
>       <div class="footnotes">
>           <hr/>
>           <ol>
>               <li id="fn1"><p>footnote one</p><p>In two paragraphs<a
> href="#fnref1">↩</a></p></li>
>               <li id="fn2"><p>footnote two</p>In two paragraphs<a
> href="#fnref2">↩</a></li>
>               <li id="fn3"><p>footnote three</p><p>In two paragraphs<a
> href="#fnref3">↩</a></p></li>
>           </ol>
>       </div>
> </doc>
> \stopbuffer
>
> \starttext
>
> \usemodule[html]
>
> \xmlregistersetup{xml:html:basics}
> \xmlregistersetup{xml:html:tables}
>
> \startxmlsetups xml:initialize
>       \xmlsetsetup{#1}{a[@class='footnoteRef']}{xml:footnote:ref}
>       \xmlsetsetup{#1}{div[@class='footnotes']}{}
> \stopxmlsetups
>
> \xmlregistersetup{xml:initialize}
>
> \startxmlsetups xml:doc
>        \xmlflush{#1}
> \stopxmlsetups
>
> \startxmlsetups xml:footnote:set
>       \startfootnote
>           \xmlflush{#1}
>       \stopfootnote
> \stopxmlsetups
>
> \startluacode
>       local gsub = string.gsub
>       function xml.expressions.idstring(str)
>           return type(str) == "string" and gsub(str,"^#","") or ""
>       end
> \stopluacode
>
> \startxmlsetups xml:footnote:ref
> \xmlfilter{main}{div[@class='footnotes']/ol/li[@id=idstring('\xmlatt{#1}{href}')]/command(xml:footnote:set)}
> \stopxmlsetups
>
> \xmlprocessbuffer{main}{demo}{}
>
> \unexpanded\def\handlenoteitself#tag#id%
>     {\edef\currentnotenumber{#id}%
>      \edef\currentnote{#tag}%
>      \strc_constructions_initialize{#tag}%
>      \strc_notes_synchronize
>
>
> \edef\currentconstructionlistentry{\ctxcommand{notelistindex("\currentnote",#id)}}%
>
>      \reinstateconstructionnumberentry\currentconstructionlistentry
>      \dontcomplain
>      \strc_notes_interaction_check_display
>      \strc_notes_set_reference_attribute_text
>      \strc_constructions_stored_start
>      \begstrut
>      \strc_references_flush_destination_nodes
>      \strc_notes_set_destination_attribute_text
>      \strc_notes_inject_text
>      \ifvmode\obeydepth\else\endstrut\fi % \obeydepth new 2015-01-10
>      \strc_constructions_stored_stop}
>
> \stoptext
>
> Sorry, but this is all Greek to me. What am I doing wrong here?


put such code in cont-new.mkiv after \unprotect or wait for a beta

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | 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 / 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] 7+ messages in thread

end of thread, other threads:[~2015-01-11 21:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 10:41 dealing with footnotes and ol in XML Pablo Rodriguez
2015-01-09 11:18 ` Hans Hagen
2015-01-09 11:29   ` Hans Hagen
2015-01-09 12:24     ` Pablo Rodriguez
2015-01-10 13:01       ` Hans Hagen
2015-01-11 21:01         ` Pablo Rodriguez
2015-01-11 21:58           ` Hans Hagen

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).