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

Zombie <p></p> before and after the ToC #62

Closed
marconae opened this issue Sep 6, 2024 · 3 comments · May be fixed by AlphaBeta906/UUN#6
Closed

Zombie <p></p> before and after the ToC #62

marconae opened this issue Sep 6, 2024 · 3 comments · May be fixed by AlphaBeta906/UUN#6

Comments

@marconae
Copy link

marconae commented Sep 6, 2024

I am using version 0.6.0. The <div...><ul>... is always wrapped in a <p>.

Excerpt of the Markdown file:

Lorem Ipsum Dolor...

[[toc]]

## Headline 1

Lorem Ipsum Dolor...

## Headline 2

Lorem Ipsum Dolor...

Here is the generated HTML:

<p>
  <div class="table-of-contents"><ul>....</ul></div>
</p>

Checked other blogs out there that use the library and I see the wrapping <p> there as well.

How to get rid of the wrapping <p>?

@cmaas
Copy link
Owner

cmaas commented Sep 6, 2024

@marconae I'm afraid this is actually expected behavior, because of how Markdown works. This plugin doesn't really add the <p> container. The problem is that [[toc]] is on its own paragraph. If you add [[toc]] to the vanilla markdown-it renderer (try here), it turns it into <p>[[toc]]</p>. This plugin now turns [[toc]] into a full table of contents. I haven't looked into markdown-it to see if this behavior can be changed somehow.

If you do this:

Test
[[toc]]

it will be transformed into

<p>Test<div class="table-of-contents">...</div></p>

Not optimal either.

I suppose there is a way to modify the plugin to not add a default paragraph. Maybe I can look into it, but can't promise right now.

@marconae
Copy link
Author

marconae commented Sep 7, 2024

@cmaas Thanks for your feedback. I just discovered the issue, because I would like to have W3C valid HTML in my blog. It would be great if there is a way to modify the plugin to not add the <p>.

@cmaas cmaas closed this as completed in d866954 Sep 9, 2024
@cmaas
Copy link
Owner

cmaas commented Sep 9, 2024

@marconae New version 0.7.0 fixes this and removes the wrapping <p> tag.

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 a pull request may close this issue.

2 participants