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

Page Toc changes HTML rendering of horizontal rule #30

Open
shankar2k opened this issue Oct 31, 2023 · 3 comments
Open

Page Toc changes HTML rendering of horizontal rule #30

shankar2k opened this issue Oct 31, 2023 · 3 comments

Comments

@shankar2k
Copy link

I installed this plugin and found that my implementation of multiple columns (based on this recipe) stopped working. After some digging, I discovered the reason for this is that this plugin changes the HTML rendering of the markdown --- from <hr /> to <hr>. Is there a reason for this change? Can it be documented somewhere?

@pamtbaau
Copy link

pamtbaau commented Nov 1, 2023

Did some digging...

The issue has been introduced in v3.0.0 when HTML5 library is being replaced by PHP DOMDocument class.

When saving a DOMDocument into HTML, the <hr /> is being replaced with <hr> conform the HTML specs.

In the following code line, $markup contains <hr /> before executing the code line and contains <hr> after.

$markup = $domDocument->saveHTML($domDocument->getElementsByTagName('page-toc')->item(0));

I'll add a note to the recipe in the docs.

@shankar2k
Copy link
Author

Thank you! Should the rendering of the markdown --- be changed to <hr> in general, to conform with HTML specs? Or is that happening in code provided elsewhere (e.g., Twig)?

@pamtbaau
Copy link

pamtbaau commented Nov 3, 2023

Should the rendering of the markdown --- be changed to <hr> in general, to conform with HTML specs?

The rendering of Markdown happens by Grav's external library Parsedown, which tries to be CommonMark Spec compliant. According to CommonMark, Thematic Breaks should be rendered as <hr />.

It is the PHP DOMDocument library, used by Page Toc, that converts <hr /> generated by Parsedown, into <hr>.

I don't think CommonMark is going to change its specs, neither the Markdown parser being used...

So, when using the recipe you are referring to, filter |split('<hr />') should be replaced by |split('<hr>') when using plugin Page Toc.

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