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

Handle notes, etc. with MD admonitions #410

Conversation

mbraakhekke
Copy link
Contributor

@mbraakhekke mbraakhekke commented Apr 12, 2022

First attempt. This is not a real PR yet but more of an update report.

Fixes #223. See accompanying comment in this issue.

Todo:

  • Remove utils.sub_notes()
  • Update module docstring
  • Add tests

Copy link
Member

@ZedThree ZedThree left a 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"))
Copy link
Member

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:

image

rather than:

image

Comment on lines +294 to +295
if self.lines[idx] != "":
self.lines[idx] = " " * self.INDENT_SIZE + self.lines[idx]
Copy link
Member

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

Suggested change
if self.lines[idx] != "":
self.lines[idx] = " " * self.INDENT_SIZE + self.lines[idx]
self.lines[idx] = textwrap.indent(self.lines[idx], self.INDENT)

@ZedThree
Copy link
Member

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

@ZedThree ZedThree closed this Jul 11, 2023
ZedThree added a commit that referenced this pull request Aug 2, 2023
…nsion

Handle notes, etc. with MD admonitions (replaces #410)
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

Successfully merging this pull request may close these issues.

@todo in unordered list breaks html
2 participants