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

Add space before footnote in stringify function #225

Open
lewer opened this issue Nov 16, 2022 · 4 comments
Open

Add space before footnote in stringify function #225

lewer opened this issue Nov 16, 2022 · 4 comments

Comments

@lewer
Copy link
Contributor

lewer commented Nov 16, 2022

Hello,

currently, if I have a markdown file like:

hello this[^1] is my footnote

[^1]: just a test

and if I represent it as a panflute Doc and call stringify, it will return:

hello thisjust a test is my footnote

I think that stringify should add a space before the Note element, and instead return:

hello this just a test is my footnote

If you agree with this change I can propose a PR.

@sergiocorreia
Copy link
Owner

Sorry for only reading this now. Completely agree with the change, feel free to submit a PR. Otherwise, I'll schedule this for the next major update (time permitting)

@lewer
Copy link
Contributor Author

lewer commented Jan 27, 2023

Actually pandoc's stringify function for Lua skips footnotes (see https://github.com/jgm/pandoc/blob/ad3d7c19144b2bac7084499b8fd3a62aa0972a6e/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Utils.hs#L182)

Maybe panflute's stringify should do the same for coherence?

@sergiocorreia
Copy link
Owner

I agree that coherence is valuable but OTOH dropping text might be problematic. Maybe we can just add it back in the same format as inline footnotes (see last part of this link). EG:

hello this[^1] is my footnote

[^1]: just a test

Becomse:

hello this[^is my footnote]

In that way footnotes can be clearly spotted from the main text.

@lewer
Copy link
Contributor Author

lewer commented Jan 30, 2023

But if the footnote contains multiple paragraphs?

I don't think that stringify's goal is to “pretty-print” the element. Do you have any filters in mind for which we would like stringify to return the footnote?

I have in mind filters for which we don't want that. For instance a spellchecking filter: it checks if the element e is a Paragraph, and if so, it computes stringify(e) and spellchecks. If stringify skips the footnote it's ok: as the footnote itself contains a Paragraph, it will be spellchecked separately from e. But if stringify(e) returns both the paragraph text and the footnote, the footnote will be spellchecked twice, and moreover we'll have to deal with these [^...] characters.

what do you think?

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