mwilliamson / mammoth.js

Convert Word documents (.docx files) to HTML
BSD 2-Clause "Simplified" License
4.85k stars 522 forks source link

Footnotes and custom style maps #156

Open urspx opened 6 years ago

urspx commented 6 years ago

Hello,

Thank you for the great document convertor – It's very helpful!

A question: Is it possible to use custom style maps to change how footnotes are converted? I would like to have them appear inline, wrapped in some form of tag (e.g. span.fn). In order to do that, I tried the following:

r[style-name='FootnoteReference'] => span.fn:fresh
p[style-name='FootnoteReference'] => span.fn:fresh

p[style-name='footnote text'] => span.fn:fresh
r[style-name='footnote reference'] =>

p[style-name='Footnote'] => span.fn:fresh
r[style-name='Footnote anchor'] =>

p[style-name='footnoteReference'] => span.fn:fresh
r[style-name='footnoteReference'] =>

but it didn't have any effect; the footnotes still show up in the usual way (i.e. superscript anchors that link to ordered lists).

I'm not sure if this is relevant, but whenever I run mammoth (with or without the style map), I get the following alert:

Run style with ID FootnoteReference was referenced but not defined in the document Unrecognised run style: 'null' (Style ID: FootnoteReference)

(This is where I got those style names from).

Is there a way to disable to footnote reader? Or would this have to be done with postprocessing the html?

Thank you!

mwilliamson commented 6 years ago

Hello! At the moment, footnotes are unconditionally inserted into the document as you've described.

maddesigns commented 6 years ago

would love to see that feature too

oninross commented 5 years ago

Would love to have control on how the footnotes are being generated. Right now we can only change the contents of the list.

julientaq commented 2 years ago

hi there! That would be quite useful for us too! THanks!

theskinnyghost commented 1 year ago

+1 on this feature request! 😄

pcraig3 commented 3 months ago

Has anyone figured out how to target these? I am building an application that throws exceptions on warning messages and I would like to add some rules to catch these but I am not sure if I can intercept them.

Here are the warnings I am getting (note that I am using Python but the issue is in essence the same):

Run style with ID FootnoteReference was referenced but not defined in the document Unrecognised run style: None (Style ID: FootnoteReference)

And here is what I am seeing in the XML for a footnote:

<w:r>
  <w:rPr>
    <w:vertAlign w:val="superscript"/>
  </w:rPr>
  <w:footnoteReference w:id="2"/>
</w:r>