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

Footnotes don't get reset after Postprocess #401

Closed
TintypeMolly opened this issue Apr 5, 2015 · 3 comments
Closed

Footnotes don't get reset after Postprocess #401

TintypeMolly opened this issue Apr 5, 2015 · 3 comments

Comments

@TintypeMolly
Copy link

Problem

Once markdown instance converted text containing footnotes, those footnotes' contents keep appearing at every single result converted by the markdown instance.

How to reproduce

import markdown

md = markdown.Markdown(extensions=["markdown.extensions.footnotes"])
md.convert("Foo[^1] Bar\n[^1]: Baz")
print md.convert("Foo")
print md.convert("Bar")

Desired Output

<p>Foo</p>
<p>Bar</p>

Current Output

<p>Foo</p>
<div class="footnote">
<hr />
<ol>
<li id="fn:1">
<p>Baz&#160;<a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
</li>
</ol>
</div>
<p>Bar</p>
<div class="footnote">
<hr />
<ol>
<li id="fn:1">
<p>Baz&#160;<a class="footnote-backref" href="#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text">&#8617;</a></p>
</li>
</ol>
</div>
@waylan
Copy link
Member

waylan commented Apr 5, 2015

As documented, this is a feature, not a bug. You need to call the reset method on the Markdown class between each call to convert. There may be valid reasons why a user may not want to reset between documents. For example, on the front/home page one could collect all the footnotes for multiple posts and display them al together at the bottom. As an added bonus, all of the links to the footnotes would then be unique with no duplicates.

@TintypeMolly
Copy link
Author

I can't grasp your explanation. Can you give me a concrete example? I know some kind of things(e.g. Meta-Data) have some advantages on keep their state but not with footnotes.

@waylan
Copy link
Member

waylan commented Apr 6, 2015

The one and only way to reset state should be to call Markdown.reset(). No other extension gets reset called without it explicitly being requested by the user, therefore we should not expect anything different for footnotes.

Regarding my stated use case, I had forgotten that when the UNIQUE_IDS config option is set to True it works across calls to reset. That said, the expectation is that there would be calls to reset - which is clearly documented.

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