Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug; footnotes produce wrong markdown syntax? #6348

Closed
tatums opened this issue May 7, 2020 · 4 comments · Fixed by #7914
Closed

Bug; footnotes produce wrong markdown syntax? #6348

tatums opened this issue May 7, 2020 · 4 comments · Fixed by #7914

Comments

@tatums
Copy link

tatums commented May 7, 2020

Problem

Hey there! I'm trying to convert JATS to markdown and I think Pandoc is producing incorrect markdown sytnax. Please let me know what you think!

Actual output

Results
=======

A University [1](#N0001){ref-type="fn"}

footnote

Expected output

Results
=======

A University [^1](#N0001){ref-type="fn"}

footnote

or possibly

Results
=======

A University [^N0001]

footnote

Additional info

Pandoc version

pandoc 2.5
Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.7.7

Command used

$ cat example.xml | pandoc -f jats -t markdown

2020-05-07_13-48

Input used (example.xml from cmd)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN" "http://jats.nlm.nih.gov/publishing/1.0/JATS-journalpublishing1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" dtd-version="1.0" article-type="research-article">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Opinion Research</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Example article</article-title>
      </title-group>
    </article-meta>
  </front>
  <body>
    <sec sec-type="results">
      <title>Results</title>
      <p>A University <xref ref-type="fn" rid="N0001">1</xref></p>
    </sec>
  </body>
  <back>
    <fn-group>
      <fn id="N0001">
        <p>footnote</p>
      </fn>
    </fn-group>
  </back>
</article>
@jgm
Copy link
Owner

jgm commented May 7, 2020

-t native shows how it's being parsed.

[Header 1 ("",[],[]) [Str "Results"]
,Para [Str "A",Space,Str "University",Space,Link ("",[],[("ref-type","fn")]) [Str "1"] ("#N0001","")]
,Para [Str "footnote"]]

You're right, this isn't being recognized as a footnote; that could be improved.

@gabestein
Copy link

gabestein commented Feb 1, 2022

As I was looking at some of the recent JATS writer improvements the other day, it occurred to me to check if anyone else had noticed footnote reading issues. It's something we're running into increasingly with PubPub, so I wondered if there's been any interest or progress here.

I may be getting way too ahead of myself here, but if I understand this correctly and it's a fairly simple parsing issue in the reader, it might be something I could try if someone wanted to point me in the right direction.

@jgm
Copy link
Owner

jgm commented Feb 1, 2022

Go for it! Look in the JATS reader code.

I think this is roughly what needs to be done: we need to add special parsing for fn-group.
The footnotes need to be parsed into block-level content and put in a table in the writer state with their ids as keys. Then, after parsing, we can use walk to traverse the AST and replace Link elements with ref-type="fn" with a Note element containing the content stored in the table under the link's rid attribute.

It looks like the treatment of rid is also weird; we're adding an id attribute to the Link, which wrongly contains a #. We should leave this as an rid attribute I think.

@tarleb any thoughts?

@tarleb
Copy link
Collaborator

tarleb commented Feb 2, 2022

I'll be a bit slow to respond over the next couple of days, but I can take a look after that.

tarleb added a commit to tarleb/pandoc that referenced this issue Feb 12, 2022
Footnotes in `<fn-group>` elements are collected and re-inserted into
the document as proper footnotes in the place where they are referenced.

Fixes: jgm#6348
@jgm jgm closed this as completed in #7914 Feb 13, 2022
jgm pushed a commit that referenced this issue Feb 13, 2022
Footnotes in `<fn-group>` elements are collected and re-inserted into
the document as proper footnotes in the place where they are referenced.

Fixes: #6348
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants