-
Notifications
You must be signed in to change notification settings - Fork 128
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
Handle notes, etc. with MD admonitions #410
Handle notes, etc. with MD admonitions #410
Conversation
Taken from https://github.com/Python-Markdown/markdown/tree/master/markdown, commit 383de86c64101b8d14768d9a247c9efc97d703bd.
Rationale: more markdown extensions will be added to this module later.
Preprocessor converts FORD syntax to markdown admonition syntax.
Mistake prevented locating the sibling element unless the admonition type was "note".
E.g: some text @Endnote some more text
E.g: Some text @note Some more text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @mbraakhekke!
I think I'd prefer to name the new file md_admonition.py
, as we have a couple of other extensions in their own files already, and I'd prefer to keep them separate
self.lines.insert(idx + 1, m.group("posttxt")) | ||
del self.lines[idx] | ||
if m.group("pretxt"): | ||
self.lines.insert(idx, " " * self.INDENT_SIZE + m.group("pretxt")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe store INDENT = " " * self.INDENT_SIZE
to avoid this duplicated expression?
It might also be worth considering using textwrap.indent
to make this a bit more explicit?
We should probably try to preserve the existing indentation, as with this current implementation notes in lists etc are not indented, and numbered lists are restarted after the note:
rather than:
if self.lines[idx] != "": | ||
self.lines[idx] = " " * self.INDENT_SIZE + self.lines[idx] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the changes above, this could be
if self.lines[idx] != "": | |
self.lines[idx] = " " * self.INDENT_SIZE + self.lines[idx] | |
self.lines[idx] = textwrap.indent(self.lines[idx], self.INDENT) |
Thanks very much for this @mbraakhekke! Sorry it's taken me so long to get it sorted. I've finished it off and added tests etc in #540 |
…nsion Handle notes, etc. with MD admonitions (replaces #410)
First attempt. This is not a real PR yet but more of an update report.
Fixes #223. See accompanying comment in this issue.
Todo:
utils.sub_notes()