-
Notifications
You must be signed in to change notification settings - Fork 34
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
Format markdown in TOC by default #41
Format markdown in TOC by default #41
Conversation
Sounds good @coryschires ! @GiridharanNarayanan do you think you could help out here as it seems @coryschires has run into some issues with some aspect of |
Hey, wanted to follow up with another possible solution. Not as good, imo. But worth mentioning. Rather than parse markdown by default, we could at least expose the This solution would probably un-block this PR because the default behavior would no longer conflict with Anyway, if you'd like to move forward with this idea, let me know and I will update the PR accordingly. |
@coryschires , Apologies for late response. I am a bit held up with deliverables at work. You could go ahead with your new solution if @martinlissmyr is fine with it. By next week I should have time to have a look at this and I can try to fix the issue and make the MD rendering a default. |
I think that the original intention here, to parse markdown per default, is better. If you @coryschires think it's fine to wait for @GiridharanNarayanan to fix any conflicting issues I would prefer that as I believe it makes things a bit less brittle. |
Sure. I don't mind waiting. No rush as I can always point to my branch in the meantime. |
Hi @martinlissmyr, As mentioned above, I decided to point to my branch locally, as that fixes the bug on my end. Unfortunately, along the way, I encountered another issue: My JS tests were failing, complaining about ES6 is, of course, a huge improvement. However, in my experience, libraries normally transpile ES6 and thus expose an ES5 version for use by clients applications. For example, To workaround this issue, I have updated by PR and removed all ES6 syntax (i.e. However, I think this library could be improved by doing either:
Are you open to either of these solutions? Changes could be in this pull request or in a separate PR. |
@coryschires My intention was for this to be used in Node, so for me ES6 was fine. Didn't think further than that :) However, as using ES6 doesn't really "do" anything I'm open to just revert that as you've done... Could you do it in a separate PR? If so I'm glad to merge it right away. |
Is this still being considered? I'm using ToC in a code-heavy repo, and don't want to lose code formatting in my headings. Would love to see this merged. |
Well, this PR became rather messy and confusing. Not sure where it stands right now. If you are willing to clean it up, make sure tests pass, rebase it from master and so on I can merge it. |
Hey. I can take a fresh look at this PR. It's been a while but the changes are still relevant / needed, imo. I'll follow up once I have things cleaned up. |
I have updated this PR and it is now synced with the latest master. Because there's been quite a bit of discussion on this thread, I will recap the significant changes in the hope of getting this merged quickly. 1. Update code to use ES5 syntaxAs you can see in the above discussion, I think this project would be improved by migrating to plain ol' ES5 syntax. This ensures interoperability between node and browser environments. While I'm sure everyone agrees modern ES syntax is a huge improvement, I don't think it's a good trade off for this project given its small size. Alternatively, you could transpile ES6 and expose an ES5 version for use by clients applications. This is the pattern used by other markdown-it extensions such as Unfortunately, these changes do make the PR a bit noisy – but not too bad imo. If someone wants to make a separate PR dedicated to this change, that may be a good idea. That said, I think the PR is still legible (again, just my opinion) and I'm not interested in dividing this work into two separate PRs. 2. Updates the existing
|
Great work @coryschires! Thanks!
I buy your arguments! I agree.
👍
I agree it's a weird one... I'm fine with dropping support for this option. I'm just going to up the version number to reflect it's a breaking change. If you have nothing more to add I'm going to merge and release this soon! |
That's great news! Thanks for accepting my changes! |
Fixes #19
Problem
Currently, markdown is not rendered within the TOC. Given the following markdown text:
The TOC should render as:
But instead is rendered showing the raw markdown syntax:
For more details and discussion around this change, see #19.
Solution
As suggested in #19, I have updated the default behavior to always format markdown within the TOC.
Additional notes
<span>1</span>
with<span>1</span>
. But this change is actually an improvement, imo. By default, markdown-it escapes raw HTML unless you passhtml: true
. With my changemarkdown-it-table-of-contents
now also follows this config option (i.e. if you sethtml: true
then HTML will reader, otherwise it will be escaped).Conflict with
forceFullToc
?Unfortunately, this change seems to conflict with the
forceFullToc
option. The test suite overflows in an endless loop (see inline code comment). This should be fixable? Honestly, I was having a little trouble understanding the code in this area.While I am not using
forceFullToc
, it definitely sucks to regress on this feature. I'd appreciate any advice / suggestion to keepforceFullToc
working as before.Thanks again for creating this library!