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

Paragraph wraps TOC #25

Open
Avol-V opened this issue Aug 10, 2016 · 4 comments
Open

Paragraph wraps TOC #25

Avol-V opened this issue Aug 10, 2016 · 4 comments

Comments

@Avol-V
Copy link

Avol-V commented Aug 10, 2016

When I try to place TOC with placeholder @[toc], it produce paragraph tags around.

        md.use(
            markdownItTocAndAnchor,
            {
                toc: true,
                tocFirstLevel: 2,
                tocLastLevel: 3,
                anchorLink: false
            }
        );
# Header 1

@[toc]

## Subheader 1

Test text
<h1 id="header-1">Header 1</h1>
<p><ul class="markdownIt-TOC">
<li><a href="#subheader-1">Subheader 1</a></li>
</ul>
</p>
<h2 id="subheader-1">Subheader 1</h2>
<p>Test text</p>
@medfreeman
Copy link
Owner

Hi,

i'm not sure that's an issue, that's how this plugin has been designed right from the start.
If you need i could add a 'wrap' option or something like that, that defines in which element the toc is wrapped, with a default of 'p', to preserve compatibility.
Or feel free to provide a pr, haven't got much time for the rest of the month.

@Avol-V
Copy link
Author

Avol-V commented Aug 10, 2016

Thanks for the quick response!
It looks like issue, because <ul> can't be inside <p>. Browser transforms it into empty <p></p>, before and after <ul>…</ul>.
It would be great if you add an option for change this tag, or even to remove it (UL with class seems sufficient).

@Avol-V
Copy link
Author

Avol-V commented Aug 11, 2016

As I see, we must to change chain type from inline to block and the rule to place after. But it breaks code and I don't know how to work with markdown-it plugin system.

I still try to work with it, but I do't have much time.

@pmpinto
Copy link

pmpinto commented Jun 30, 2023

@medfreeman Not a lot happened around here since this was reported.
Allow me to emphasise what @Avol-V mentioned: The <ul> can't be placed inside a <p> — that's invalid markup.

I assume that at some point @[toc] is being replaced with the actual list markup.
Perhaps that's happening after markdown-it has converted @[toc] to <p>@[toc]</p>?

Could this be easily solved just by replacing <p>@[toc]</p> with the list markup? Or is that too farfetched?

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

3 participants