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

change markdown parser to mistletoe #40

Closed
wants to merge 7 commits into from
Closed

change markdown parser to mistletoe #40

wants to merge 7 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 31, 2023

Switched Markdown parser to Mistletoe.

Related to this issue.

Copy link
Member

@sirodoht sirodoht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this! It's great, just a couple of preferences changes

requirements.in Outdated Show resolved Hide resolved
main/util.py Outdated Show resolved Hide resolved
@sirodoht
Copy link
Member

sirodoht commented Jun 2, 2023

As far as the test failing, it seems mistletoe adds a new line by default to any single line renderings. To fix the test failing, I think you can change the last line of the main/tests/test_feeds.py file from:

f"<description>{self.user.blog_byline}</description>"

to:

f"<description>{self.user.blog_byline}\n</description>"

The change is an addition of a \n character in the content of the tag.

@ghost
Copy link
Author

ghost commented Jun 2, 2023

No problem! I'll do that when I get home, in a few hours.

@ghost ghost requested a review from sirodoht June 2, 2023 19:31
main/tests/test_images.py Outdated Show resolved Hide resolved
@sirodoht
Copy link
Member

sirodoht commented Jun 3, 2023

I think I've made it so that you don't need my approval to run the CI anymore

@ghost ghost requested a review from sirodoht June 3, 2023 09:57
@ghost
Copy link
Author

ghost commented Jun 3, 2023

All checks have passed now!

@ghost ghost mentioned this pull request Jun 3, 2023
@sirodoht
Copy link
Member

sirodoht commented Jun 3, 2023

Great! I can’t recall if we talked about this but are the extensions we removed now supported natively? Namely tables, footnotes, toc.

@ghost
Copy link
Author

ghost commented Jun 3, 2023

Great! I can’t recall if we talked about this but are the extensions we removed now supported natively? Namely tables, footnotes, toc.

I don't know what toc is, but give me a few minutes and I'll test it!

Edit: It's "table of contents". Testing now...

@ghost
Copy link
Author

ghost commented Jun 3, 2023

Tables work, ToC doesn't, and neither do footnotes. Working on both now.

@ghost
Copy link
Author

ghost commented Jun 3, 2023

I want to get this working, but I don't know if I can figure it out. There isn't very detailed documentation for mistletoe, so it isn't the easiest thing to work with.

@sirodoht
Copy link
Member

sirodoht commented Jun 3, 2023

In terms of the TOC, I made an example here: https://nutcroft.com/blog/a-new-startup-lifecycle/

Essentially, the important part is that headings have ids. For example the first heading is an h2 and its id is i-the-philosophy-of-posthaven.

In other words it renders as <h2 id="i-the-philosophy-of-posthaven">I. The philosophy of Posthaven</h2>

For this reason, we can have a link such as https://nutcroft.com/blog/a-new-startup-lifecycle/#i-the-philosophy-of-posthaven which will scroll to that heading in the article.

The least important part, which we can do without, is the [TOC] marker, which generates these links in the beginning:
image

Let me know if these make sense!

@sirodoht
Copy link
Member

sirodoht commented Jun 3, 2023

In terms of footnotes, I see that mistletoe does not support them out of the box: miyuchina/mistletoe#47

One question is how easy we can re-implement them by overriding their HTMLRenderer, just like we did with the code highlighting part.

They don't have a footnotes example in their contrib folder as they do for code highlighting: https://github.com/miyuchina/mistletoe/tree/e853a0def73f4d4c2be5bf16ef4ef4135df0d556/mistletoe/contrib

But there is some kind of reference to footnotes in their docs building page here:
https://github.com/miyuchina/mistletoe/blob/e853a0def73f4d4c2be5bf16ef4ef4135df0d556/docs/__init__.py#L26-L34

as well as a Footnote BlockToken class, though I haven't figured out yet if that's the footnote we mean:
https://github.com/miyuchina/mistletoe/blob/e853a0def73f4d4c2be5bf16ef4ef4135df0d556/mistletoe/block_token.py#L745

@ghost ghost closed this by deleting the head repository Jun 22, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant