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

table of contents [[_TOC_]] not available in HTML #27

Closed
fabbra opened this issue Apr 6, 2021 · 8 comments
Closed

table of contents [[_TOC_]] not available in HTML #27

fabbra opened this issue Apr 6, 2021 · 8 comments
Labels
bug - output The output isn't what it is supposed to be

Comments

@fabbra
Copy link

fabbra commented Apr 6, 2021

When I have a table of contents (via the [[_TOC_]] keyword) in my markdown, the HTML will not show a table of contents but simply these few characters [[TOC]].
Is this a bug or simply a too "complicated" feature which will not be available?

@phseiff
Copy link
Owner

phseiff commented Apr 6, 2021

Hi, and thanks for filing this issue!

Is the [[_TOC_]] feature available on GitHub/ part of the GitHub flavored markdown specification?
If not, then I'm afraid that this is out of scope (after all, the project aims to offer GitHub-flavored markdown conversion); if it is, on the other hand, then that's a bug and I will ofc do my best to fix it.

Did you use the core_converter option to use a different markdown parser than the one offered by GitHub? If yes, then that might be the reason.

I'm afraid I can't look any deeper into the issue at the moment, though, since I'll be occupied with private matters until the 9th of April; after that, I will further investigate into the issue.

@phseiff phseiff added the bug - output The output isn't what it is supposed to be label Apr 6, 2021
@phseiff
Copy link
Owner

phseiff commented Apr 6, 2021

I just googled it quickly, and according to this article, the [[_TOC_]]-syntax is only supported by RedCarpet markdown; neither GitHub flavored nor pandoc-flavored markdown, so there isn't really a reason why this would need to be part of this markdown converter.

I could imagine adding an option to support all three syntaxes the article lists ([[_TOC_]], [toc] and {:toc}) in the future, but I will have to think a little bit about this since I'm not sure if that's really a wide-spread enough feature to add it, considering every feature somewhat clutters the list of options.

@fabbra
Copy link
Author

fabbra commented Apr 6, 2021

Hi,
I am using this feature in GitLab and I must say that I was not fully aware that this is not a "general" feature.
Thus, yes, fully understandable if this will not be included as a feature to avoid cluttering the list of options.
Sorry for not having checked this beforehand.
Thanks for your prompt replies!

@phseiff
Copy link
Owner

phseiff commented Apr 6, 2021

Don't worry, you're welcome!

@phseiff phseiff added enhancement New feature or request and removed bug - output The output isn't what it is supposed to be labels Apr 6, 2021
@phseiff
Copy link
Owner

phseiff commented Apr 10, 2021

@fabbra You can update to v1.9.0 now (pip3 install --upgrade gh-md-to-html==1.9.0), and use --toc true to enable the use of [[_TOC__]] (and the other syntaxes listed above) for adding a table of contents.
Note that the [[_TOC__]]-token must be stand-alone (the only thing within its line) for this to work, though.

@phseiff phseiff added the fixed The issue was fixed. label Apr 10, 2021
@fabbra
Copy link
Author

fabbra commented Apr 19, 2021

thanks a lot!

it almost works...
i found an error of non-working links if the title contains a dash.

in the following example file the link (via TOC) to the first three headings (not containing a dash) works whereas the links do not work to the last three headings (all containing a dash)
test.md

@phseiff phseiff reopened this Apr 19, 2021
@phseiff phseiff added bug - output The output isn't what it is supposed to be and removed enhancement New feature or request fixed The issue was fixed. labels Apr 19, 2021
@phseiff
Copy link
Owner

phseiff commented Apr 19, 2021

Thanks for testing and filing this issue!

I fixed this in v1.10.2 now, and verified it works with this extended test file (both with GitHub's REST API as well as with the -o OFFLINE option):
test-headings.md

@fabbra
Copy link
Author

fabbra commented Apr 19, 2021

seems to have fixed the bug. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - output The output isn't what it is supposed to be
Projects
None yet
Development

No branches or pull requests

2 participants