pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

Endnotes

Open link2xt opened this issue 8 years ago • 20 comments

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.

link2xt avatar Nov 05 '17 20:11 link2xt

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 avatar Nov 05 '17 21:11 tarleb

@tarleb Thanks, trying to fix it.

link2xt avatar Nov 05 '17 21:11 link2xt

Fixed, all tests pass. Now going to add endnotes to Docx and ODT.

link2xt avatar Nov 05 '17 21:11 link2xt

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.

link2xt avatar Nov 06 '17 01:11 link2xt

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.

link2xt avatar Nov 06 '17 20:11 link2xt

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.

link2xt avatar Dec 15 '17 10:12 link2xt

@jgm ping, just updated PR

Linking #4213 as related

link2xt avatar Dec 30 '17 23:12 link2xt

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.

link2xt avatar Feb 13 '18 22:02 link2xt

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.

jkr avatar Feb 13 '18 22:02 jkr

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

jkr avatar Feb 13 '18 22:02 jkr

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?

link2xt avatar Apr 09 '18 05:04 link2xt

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

link2xt avatar Apr 29 '18 15:04 link2xt

@labdsf Thanks, LGTM. I'm only wondering why it is FootNote and EndNote instead of Footnote and Endnote.

tarleb avatar May 01 '18 12:05 tarleb

@tarleb

I'm only wondering why it is FootNote and EndNote instead of Footnote and Endnote.

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.

link2xt avatar May 01 '18 14:05 link2xt

I still prefer Footnote and Endnote, because these are single words; the CamelCase looks wrong here, though I see your thinking.

jgm avatar May 03 '18 16:05 jgm

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.

link2xt avatar May 03 '18 23:05 link2xt

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 avatar Jul 21 '18 18:07 jgm

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

link2xt avatar Jul 21 '18 19:07 link2xt

@jgm Just rebased it again to merge with Muse changes. Any updates?

link2xt avatar Sep 02 '18 16:09 link2xt

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

johannesburg avatar Sep 21 '22 19:09 johannesburg