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

Markdown writer incorrect output of a figure with attributes #5121

Closed
cprecioso opened this issue Dec 3, 2018 · 5 comments
Closed

Markdown writer incorrect output of a figure with attributes #5121

cprecioso opened this issue Dec 3, 2018 · 5 comments

Comments

@cprecioso
Copy link

When putting an image on its own paragraph in order to make it a figure and appending an attribute to it, the outputted markdown contains an HTML block with the figure, but the following block is appended in the same line, instead of being separated by newlines. (It works if the image doesn't have additional attributes)

Repro on pandoc 2.5

I tried all the markdown variants, and only happens with markdown_mmd and markdown_strict (although the rest of markdowns just lose the figure and output a regular image). I checked the JSON format output and it seems the AST is correct, so I think it's an issue of the writer.

Because of this issue, the next block will not be parsed correctly in most markdown variants.

In what I think is related, if the figure caption contains a footnote, it will be rendered just under the figure, not joined with the rest of the footnotes in the document. (Repro case). If it's not part of the same issue, tell me so and I will open a separate issue.

@jgm jgm closed this as completed in 4060df6 Dec 3, 2018
@jgm
Copy link
Owner

jgm commented Dec 3, 2018

The footnote issue is separate and deserves a separate issue. Since markdown_strict doesn't have the "implicit figures" extension, we render figures in it using raw HTML. (If you don't want figures, turn off the implicit_figures extension in your source format.)

If the figure contains a footnote, it gets rendered with the figure by the HTML writer. I'm honestly not sure how to fix this. One could remove the note from the figure caption before rendering, but then where do you add it back again?

@cprecioso
Copy link
Author

Yes, I understand that it writes HTML into the markdown, and that's to be expected, that's not the issue. I'm trying to report a bug about how this HTML is mixing with the markdown. Maybe I haven't been clear or I'm not understanding you 😅. I think this issue deserves to be reopened, I'll try to rephrase in case I've not been straightforward when reporting.

What I mean is when feeding this markdown (-f markdown):

# Header 1

![My caption](./my-figure.jpg){width=500px}

## Header 2

-t markdown_strict and -t markdown_mmd both output:

Header 1
========

<figure>
<img src="./my-figure.jpg" alt="My caption" width="500" /><figcaption>My caption</figcaption>
</figure>Header 2
--------

The problem is the </figure>Header 2 in the same line. It should be on different lines, as most markdown renderers will not understand that. The output should then be:

Header 1
========

<figure>
<img src="./my-figure.jpg" alt="My caption" width="500" /><figcaption>My caption</figcaption>
</figure>

Header 2
--------

Is this clearer? Or have I not understood you? Thanks 🙂

@jgm
Copy link
Owner

jgm commented Dec 4, 2018

Oh no! You were perfectly clear. Maybe you missed the fact that I already fixed the bug with the blank line; that's what closed the issue.

@jgm
Copy link
Owner

jgm commented Dec 4, 2018

See commit 4060df6.

@cprecioso
Copy link
Author

cprecioso commented Dec 4, 2018

Oh, I absolutely did, sorry! Thanks for fixing the bug and for Pandoc, it's saving me plenty of time with my thesis! ☺️

I'll open another bug with the footnote issue.

daamien pushed a commit to daamien/pandoc that referenced this issue Dec 27, 2018
We use HTML for a figure in markdown dialects that can't
represent it natively.

Closes jgm#5121.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants