MarkdownConverter icon indicating copy to clipboard operation
MarkdownConverter copied to clipboard

Problem Including Table of Contents

Open karmeye opened this issue 3 years ago • 16 comments

Sorry for rather simple question but I cannot find details on this anywhere. I am unable to generate a toc in the pdf. I ran the following commands:

  1. npm install markdown-it --save
  2. npm i markdown-it-table-of-contents --save

The markdownConverter.Parser.Toc.Indicator is the default ^\[\[\s*toc\s*\]\]

When I convert the following

Table Of Contents

[[toc]]

# 12

# we
### sdf

It looks like this:

Screenshot 1

Also, I am new to npm. After running those commands above, a node_modules folder was created in my working directory as well as a package-lock.json and a package.json. Is this correct?

Thx

karmeye avatar Feb 15 '22 07:02 karmeye

Hello @karmeye First of all - thanks for your interest in this project and for using MarkdownConverter! Installing markdown-it and markdown-it-table-of-contents is unnecessary and doesn't change MarkdownConverter's behavior as MarkdownConverter is pre-packaged with all these modules and doesn't care what's inside VSCode's working directory, really.

Sadly I cannot reproduce the issue. Could you please change the output-type to HTML (using the markdownConverter.ConversionType setting) and post the generated HTML file here?

neurolag avatar Feb 15 '22 07:02 neurolag

Thank you for making this and your quick response!

Ah, good to hear that MarkdownConverter is pre-packaged with those. When I read the setting description

Enables the rendering of a table of contents using markdown-it-table-of-contents

I didn't know what it was and thought that was the problem.

Here's the html: html.txt

karmeye avatar Feb 16 '22 04:02 karmeye

I'm also getting this issue (VSCode/Win64/10), at first I thought proxy server, but that's been removed and I'm still getting double angle brackets where the TOC should be. I also noted a crash report from windows event view. See attached the .md, .html (requested), event exception. It produces the same result in multiple formats. I originally used default for chromium, but have also tried specifying the location of chrome.exe (makes it run much faster). User_Seed.md User_Seed_html.txt EVENT_LOG.txt

0xbac avatar Aug 26 '22 15:08 0xbac

Thank you for making this and your quick response!

Ah, good to hear that MarkdownConverter is pre-packaged with those. When I read the setting description

Enables the rendering of a table of contents using markdown-it-table-of-contents

I didn't know what it was and thought that was the problem.

Here's the html: html.txt

You're right - I might have to reverb this section of the README. This really does sound confusing now that you mention it 😅

neurolag avatar Sep 16 '22 01:09 neurolag

I could reproduce the issue. Looks like vscode's markdown-it instance doesn't get along with markdown-it-table-of-contents anymore.

To be honest, I have no idea on whether and how I can fix this. I'll investigate this at a later point. Stay tuned!

neurolag avatar Sep 16 '22 01:09 neurolag

@karmeye, @0xbac I could pinpoint it down to the problem's source.

It looks just like this problem is caused by the Markdown Preview Mermaid Support extension. No idea on how to fix it - neither do I know on how to fix it tbh 😅

neurolag avatar Sep 16 '22 16:09 neurolag

I got the same problem when I added the Mermaid Extension. Before, the TOC was ok and after there was no more toc, only an empty tag. Deactivating the Mermaid extension does not solve the TOC problem. Question: is the Mermaid extension destroying the toc after it is generated? Could it be possible that swapping the extension effect might solve the problem? In mean, applying Mermaid first and makdown-it-table-of-content afterwards? I hope this can help.

AJE-2015 avatar Dec 17 '22 18:12 AJE-2015

Hello;

I am also encountering this issue, where [[toc]] is replaced with <>; Windows 10 22H2, VSCode 1.77.2, MarkdownConverter 5.2.1.

I have also found that the markdownConverter.Parser.Toc.Indicator setting doesn't seem to work? If I change it, for example, to \\/\\/toc, there is no substitution.

SmithPlatts avatar Apr 12 '23 09:04 SmithPlatts

Hi @SmithPlatts Thanks for your feedback.

As mentioned before, this is most likely caused by the Markdown Preview Mermaid Support extension. Sadly, I don't know as to how this extension breaks markdown-it, so there is nothing much I can do.

You might want to disable this extension to make TOCs work.

neurolag avatar Apr 12 '23 10:04 neurolag

Hi @manuth;

Cheers for the response.

I have uninstalled Markdown Preview Mermaid Support, and have also disabled the following other extensions:

  • Instant Markdown
  • Markdown Checkboxes
  • Markdown Footnotes
  • Markdown yaml Preamble

I still have the following extensions installed:

  • Markdown Emoji
  • Markdown Preview Github Styling

I will try disabling these too, and then will try uninstalling them if there is still no improvement.

Would you like a dedicated issue raised for the markdownConverter.Parser.Toc.Indicator issue? This does not seem to be related.

SmithPlatts avatar Apr 12 '23 11:04 SmithPlatts

Yes, that would help me a lot to keep track of it Thank you very much!

neurolag avatar Apr 12 '23 12:04 neurolag

I gave up; disabled Markdown Converter TOC and I'm using Auto Markdown TOC now. It takes a little more management in your .md, but gives you much more control. I still use Markdown Converter for all the other features, file conversion, style support etc. and everything plays nicely with Markdown Preview Mermaid Support.

0xbac avatar Apr 12 '23 12:04 0xbac

Hi @manuth;

It was the Markdown Preview Github Styling extension that was causing the issue for me; with it disabled, and all of the others enabled, TOC would generate correctly (using [[toc]]).

I also reinstalled Markdown Preview Mermaid Support, disabled Markdown Preview Github Styling, and retested and confirmed the issue.

In summary, either of these two extensions being enabled will cause [[toc]] to be replaced with <>:

  • Markdown Preview Github Styling
  • Markdown Preview Mermaid Support

SmithPlatts avatar Apr 12 '23 12:04 SmithPlatts

Thank you so much for the recommendation! Another alternative for generating TOCs that I use quite often is the "Markdown All In One" extension. Definitely recommend this.

neurolag avatar Apr 12 '23 12:04 neurolag

Hi @manuth;

It was the Markdown Preview Github Styling extension that was causing the issue for me; with it disabled, and all of the others enabled, TOC would generate correctly (using [[toc]]).

I also reinstalled Markdown Preview Mermaid Support, disabled Markdown Preview Github Styling, and retested and confirmed the issue.

In summary, either of these two extensions being enabled will cause [[toc]] to be replaced with <>:

  • Markdown Preview Github Styling
  • Markdown Preview Mermaid Support

Thanks a lot for your research! I'll keep this in mind when working on this issue

neurolag avatar Apr 12 '23 12:04 neurolag

Yes, that would help me a lot to keep track of it Thank you very much!

Issue #218 has been created.

SmithPlatts avatar Apr 12 '23 14:04 SmithPlatts