pandoc
pandoc copied to clipboard
Endnotes
This is for issue #4041 and depends on https://github.com/jgm/pandoc-types/pull/34
So far I did some straightforward changes, trying to relpace Note with Note FootNote where possible. For some reason Lua tests fail.
Reproduce with: stack test -j 1 --test-arguments '-p Lua' 2>&1 | less
Can someone familiar with lua (@tarleb ?) help with fixing this? Looks like something should be done about function Note, for example replacing it with function FootNote and function EndNote like it is done with Math.
Don't have time to look at it right now, but the most likely explanation is that you'll have to edit the M.Note function in data/pandoc.lua.
@tarleb Thanks, trying to fix it.
Fixed, all tests pass. Now going to add endnotes to Docx and ODT.
Reporting progress: Still need to fix Docx writer. Also maybe add some tests for OpenDocument writer or add EndNote to generic writer test at least. Maybe the best option is to check for round-trip, like Docx does now.
All done, need review.
Especially for Docx writer. Documents it produces can be loaded by LibreOffice, that is all I have tested. Code is mostly a copy of footnotes, I think it can be hlinted and pruned after merge. I don't understand the reason for defaultFootnotes, so I left default endnotes list empty. Judging from comments, looks like a kludge for some MS Office glitch? OOXML standard part 1 is 5000+ pages, TLDR.
Also, I will have to switch from my repo back to official one, for that we need a new version of pandoc-types, right? So first https://github.com/jgm/pandoc-types/pull/34 is to be merged and a new version assigned, then I can fix first commit in this PR.
Added support for Muse ({1} for endnotes). Now ODT, Docx and Muse support endnotes both for reading and writing. CI failures are due to the fact that I use custom version of pandoc-types.
@jgm How do I proceed to get this PR merged? I think it is ready.
@jgm ping, just updated PR
Linking #4213 as related
Rebased it once again on top of refactored Muse reader.
@jkr How do I update binary Docx files with the new test framework? All binary tests are failing mostly due to added endnote style. Manual testing shows produced files with endnotes are ok.
Alexander [email protected] writes:
@jkr How do I update binary Docx files with the new test framework? All binary tests are failing mostly due to added endnote style. Manual testing shows produced files with endnotes are ok.
Just run the tests with --accept. If you're using stack, that would be
stack test --test-arguments="--accept". That will produce new docx
files. When you commit, just make sure that you say that you confirmed
they work, and mention which version of Word you checked them in.
Oh, and if you test against a non-existent word file, it will create it.
More info here: https://ro-che.info/articles/2017-12-04-golden-tests
Updated once again, stack test passes, Muse round-trip test too.
@jkr I checked golden tests with LibreOffice, don't have any MS Office around.
@tarleb Lua doesn't work as expected. I am trying to run the following Lua filter, but it doesn't turn footnotes into endnotes:
return {
{
Note = function (elem)
if elem.notetype == "FootNote" then
elem.notetype = "EndNote"
end
return elem
end,
}
}
Also, is there anything that should be done to JSON filters compatible?
@tarleb I fixed Lua support and added a test for a filter that converts footnotes to endnotes.
@jgm I think it is ready. Custom writers are not broken, tested manually with pandoc -t data/sample.lua.
@labdsf Thanks, LGTM. I'm only wondering why it is FootNote and EndNote instead of Footnote and Endnote.
@tarleb
I'm only wondering why it is
FootNoteandEndNoteinstead ofFootnoteandEndnote.
Not sure, most likely because I looked at SingleQuote/DoubleQuote and DisplayMath/InlineMath while implementing it. This way quote, math and note types have capitalized "quote", "math" and "note" in their names, it is more consistent.
On the other hand, "footnote", "endnote" and "sidenote" are single words in English, while "doublequote" and "inlinemath" are not.
I still prefer the CamelCase style, because it allows to add something like "PopupNote", "MarginNote" etc.
I still prefer Footnote and Endnote, because these are single words; the CamelCase looks wrong here, though I see your thinking.
I have replaced FootNote and EndNote with Footnote and Endnote.
Had to replace Run constructors Footnote and Endnote with RunFootnote and RunEndnote in Docx to avoid conflicts.
This is a massive PR, so it's difficult to examine thoroughly.
Can you clarify which readers and writers actually support the distinction between endnotes and footnotes? (I assume that the other readers and writers just treat all notes as footnotes?)
@jgm Endnotes are supported in both readers and writers for ODT, Docx and Muse (with Amusewiki syntax: "{1}", "{2}" instead of "[1]" and "[2]" for footnotes), besides Native. All the other readers and writers simply ignore the type and treat them as footnotes.
Later it would be nice to add support for LaTeX, at least for the writer, but that requires using additional packages, so I have left it out for now. HTML/EPUB can get support once #4213 is resolved.
@jgm Just rebased it again to merge with Muse changes. Any updates?
I'm wondering if this PR is still being worked on? It would be great to be able to specify whether notes are endnotes and footnotes, especially for .docx files