ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Denis Maier via ntg-context <ntg-context@ntg.nl>
To: <mckaymeister@gmail.com>, <ntg-context@ntg.nl>
Cc: denis.maier@unibe.ch
Subject: Re: [NTG-context] Help with typesetting footnotes in an HTML document
Date: Wed, 12 Apr 2023 10:33:07 +0000	[thread overview]
Message-ID: <fbcf0a08f3794edb82e5e576268b4168@unibe.ch> (raw)
In-Reply-To: <b382e0c9-065c-a08b-077a-d6f768515d50@gmail.com>

Depending on how complex your files are, you might want to have a look at pandoc. It does a decent job when converting docx to other formats (HTML, Markdown or even ConTeXt).

Best & good luck
Denis

> -----Ursprüngliche Nachricht-----
> Von: Keith McKay <mckaymeister@gmail.com>
> Gesendet: Mittwoch, 12. April 2023 12:22
> An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>; ntg-
> context@ntg.nl
> Betreff: Re: AW: AW: [NTG-context] Help with typesetting footnotes in an
> HTML document
> 
> Hi Denis,
> 
> Thanks for the code, I shall give this a try.
> 
> To get the html file I convert a docx file using a wordpress multisite app called
> Pressbooks, a book content management system for book publishing in
> various formats such as the web, pdf, epub and various xml flavours (see
> pressbooks.com). My interest was that docx files could be imported into
> pressbooks, edited and then exported as html which I then used in ConTeXt
> to produce pdf. Pressbooks has an open source option and they give
> instructions on how to self-host on a local web server, which is what I have
> done (see pressbooks.org). It is, I suppose, like using a sledgehammer to
> crack a nut, and the html files produced are quite complicated. I'm still in the
> experimental stage with it.
> 
> Before trying out Pressbooks, I had previously produced two
> books(novels) by converting docx files to epub using an epub extension to
> Libre Office, then edit/clean-up the epub using Sigil epub editor.
> Finally I extract the individual xhtml files and input into ConTeXt.
> That was much easier and the files much less complicated, however those
> books did not have footnotes so I shall have to check that out in Sigil.
> I'm still experimenting to get a simple workflow for the conversion of docx
> files to simple (x)html files.
> 
> Thanks again for the code.
> 
> Best Wishes
> 
> Keith
> 
> On 12/04/2023 09:05, denis.maier@unibe.ch wrote:
> > Hey Keith,
> >
> > the code below should get you started. Obviously, the links in the
> footnotes don't appear as there are no setups for the <a> elements yet.
> >
> > By the way, where is the HTML coming from? The dual structure for
> footnotes looks a bit odd and a bit too complicated for me.
> >
> > ==========================================
> > \startxmlsetups xml:initialize
> > \xmlsetsetup{\xmldocument}{*}{-}
> > \xmlsetsetup{\xmldocument}{html|body|p|}{xml:*}
> >
> > %\xmlsetsetup{#1}{span[@class="data-fnref"]}{xml:footnote} % data-
> fnref is not a class; also -> the element won't be seen if the parent span is
> not treated in some way.
> > \xmlsetsetup{#1}{span[@class="footnote"]}{xml:footnote-wrapper}
> > \xmlsetsetup{#1}{span[@class="footnote-indirect"]}{xml:footnote}
> > \xmlsetsetup{#1}{div[@class="footnotes"]}{xml:nothing}
> >
> > \stopxmlsetups
> > \xmlregistersetup{xml:initialize}
> >
> > \startxmlsetups xml:html
> > \xmlflush{#1}
> > \stopxmlsetups
> >
> > \startxmlsetups xml:body
> > \xmlflush{#1}
> > \stopxmlsetups
> >
> > \startxmlsetups xml:p
> > \xmlflush{#1}\par
> > \stopxmlsetups
> >
> > \startxmlsetups xml:footnote-wrapper
> > \xmlflush{#1}
> > \stopxmlsetups
> >
> > \startxmlsetups xml:footnote
> > \footnote
> > %
> > {\xmlfirst{test}{div[@class="footnotes"]/div/div[@id="\xmlatt{#1}{id}"
> > ]}} -> test is not the document name nor the name of the node to be
> > processed>; div/div nesting was wrong; for some reason I can't get it
> > to work with xmlfirst. But \xmlfilter works
> > {\xmlfilter{\xmldocument}{div[@id='\xmlrefatt{#1}{data-fnref}']/comman
> > d(xml:test)}}
> > \stopxmlsetups
> >
> > \startxmlsetups xml:test
> > \xmlflush{#1}
> > \stopxmlsetups
> >
> >
> > \starttext
> >
> > \xmlprocessfile{initialise}{footnoteTest.html}{}
> >
> > \stoptext
> >
> ==========================================================
> ===
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Keith McKay <mckaymeister@gmail.com>
> >> Gesendet: Dienstag, 11. April 2023 17:53
> >> An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>; ntg-
> >> context@ntg.nl
> >> Betreff: Re: AW: [NTG-context] Help with typesetting footnotes in an
> >> HTML document
> >>
> >> Fair comment Denis.
> >>
> >> I decided to try the lookup based approach on pages 85 - 86 of the
> >> xml manual and my setups are based on those pages. I have to admit
> >> that I find the xml manual a wee bit difficult in places since xml is outside
> my expertise.
> >> I attach my tex and html files which should save some copy and pasting.
> >>
> >> Thanks
> >>
> >> Keith McKay
> >>
> >> On 11/04/2023 14:51, denis.maier@unibe.ch wrote:
> >>> Hard to tell, if you don't show us what you've tried so far.
> >>> In one of my setups I use the lua based approach described on page
> 86/87.
> >> But again, we'll probably need more information to figure it out.
> >>>> -----Ursprüngliche Nachricht-----
> >>>> Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Keith
> >>>> McKay via ntg-context
> >>>> Gesendet: Montag, 10. April 2023 17:30
> >>>> An: mailing list for ConTeXt users <ntg-context@ntg.nl>
> >>>> Cc: Keith McKay <mckaymeister@gmail.com>
> >>>> Betreff: [NTG-context] Help with typesetting footnotes in an HTML
> >>>> document
> >>>>
> >>>> Hi,
> >>>>
> >>>> I have been puzzling over how to typeset footnotes in a HTML
> >>>> document, most elements have been relatively easy to typeset but
> >>>> I'm stumped with footnotes.  I have been studying the the xml
> >>>> manual in particular Chapter  7.4 Cross Referencing, but I'm still
> >>>> struggling to get xmlsetups which come anywhere near working. Any
> >>>> hints  to a solution would be greatly appreciated.
> >>>>
> >>>> Best Wishes
> >>>>
> >>>> Keith McKay
> >>>>
> >>>> %%%%%%%%%%%%%%%%%%%
> >>>>
> >>>> Here is a snippet of the HTML document with footnotes
> >>>>
> >>>> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC
> >>>> "-//W3C//DTD XHTML 1.1//EN"
> >>>>      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> >>>> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
> <head>
> >>>>      <title></title>
> >>>> </head>
> >>>> <body>
> >>>>      <p class="import-Normal">‘What is a weed? A plant whose
> >>>> virtues have not been discovered,’ wrote Ralph Waldo Emerson<span
> >>>> class="footnote"><span class="footnote-indirect"
> >>>> data-fnref="53-1"></span></span>. Those delicate crucifers with
> >>>> their manifold faces of four pink or lilac petals striated with
> >>>> veins of deeper lavender are the perfect introduction to flowers for
> children.
> >>>> So delicate and yet hardy.</p>
> >>>>      <p class="import-Normal">I spend some of April abroad,
> >>>> travelling by road from an unseasonably snowy Austria (‘dieses
> >>>> Wetter ist verrückt!’<span class="footnote"><span class="footnote-
> indirect"
> >>>> data-fnref="53-2"></span></span> as an elderly lady exclaimed to
> >>>> me) to northern France, and when I come home, it’s to a landscape
> >>>> responding to substantially increased light levels and
> temperatures.</p>
> >>>>      <p class="import-Normal">This was the early sixties. Like many
> >>>> thousands, we were rehoused from Maryhill in the heart of urban
> >>>> Glasgow to this peripheral housing scheme which completely changed
> >>>> the character of what had been a village. Within a decade those
> >>>> glasshouses were abandoned, glass broken in the frames, and a row
> >>>> of shops that included a chippy and a betting shop soon replaced
> >>>> them, betting ‘off’ licensed race-tracks having become legal in
> >>>> 1961.<span class="footnote"><span class="footnote- indirect"
> >>>> data-fnref="75-
> >> 1"></span></span></p>
> >>>>      <div class="footnotes">
> >>>>        <hr/>
> >>>>        <div id='53-1'>
> >>>>          Emerson, R.W. (1878) <em>Fortune of the Republic</em>, p.3
> >>>> quoted in <em>Oxford Dictionary of Quotations</em>, Rev Fourth
> >> Edition (1996).
> >>>>        </div>
> >>>>        <div id='53-2'>
> >>>>          ‘Crazy weather!’
> >>>>        </div>
> >>>>        <div id='75-1'>
> >>>>          <a class="rId10"
> >>>> href="http://www.independent.co.uk/sport/racing/our-national-love-
> a
> >>>> ff
> >>>> air- a-history-of-the-betting-shop-804966.html"
> >>>> data-url="http://www.independent.co.uk/sport/racing/our-national-lo
> >>>> ve
> >>>> - affair-a-history-of-the-betting-shop-804966.html"><span
> >>>> class="import-
> >> Hyperlink">http://www.independent.co.uk/sport/racing/ou
> >>>> r-
> >>>> national-love-affair-a-history-of-the-betting-shop-804966.html</spa
> >>>> n>
> >>>> </a>
> >>>> [accessed 11 Dec 2017]
> >>>>        </div>
> >>>>      </div>
> >>>> </body>
> >>>> </html>
> >>>>
> >>>> %%%%%%%%%%%%%%%%%%
> >>>>
> >>>>
> >>
> __________________________________________________________
> >>>> _________________________
> >>>> If your question is of interest to others as well, please add an
> >>>> entry to the Wiki!
> >>>>
> >>>> maillist : ntg-context@ntg.nl /
> >>>> https://www.ntg.nl/mailman/listinfo/ntg-
> >>>> context
> >>>> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> >>>> archive  : https://bitbucket.org/phg/context-mirror/commits/
> >>>> wiki     : https://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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2023-04-12 10:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10 15:30 Keith McKay via ntg-context
2023-04-11 13:51 ` Denis Maier via ntg-context
2023-04-11 15:52   ` Keith McKay via ntg-context
2023-04-12  8:05     ` Denis Maier via ntg-context
2023-04-12 10:21       ` [NTG-context] " Keith McKay via ntg-context
2023-04-12 10:33         ` Denis Maier via ntg-context [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fbcf0a08f3794edb82e5e576268b4168@unibe.ch \
    --to=ntg-context@ntg.nl \
    --cc=denis.maier@unibe.ch \
    --cc=mckaymeister@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).