Yes, it doesn’t support HTML for the security reason.
So currently your approach doesn’t work.
It’d be great if you made a plugin for this feature.
I guess this library would be helpful to make it: https://github.com/remarkjs/remark-toc
Thanks for the reply. I fear i have not the programing skills neither the time to make a plugin. Although i have to admit, that the Plugin: Word Count documentation is so well made. On the other hand it would be easy to (manually) implement TOC, if Inkdrop would allow Html.
Could you explain how far Html support is a security matter for Inkdrop?
Inkdrop is obviously for personal use, so I guess you know that it’s safe to use HTML in notes. That’s right.
However it already supports publishing notes on the web. So it’d be possible dangerous for visitors. In addition, if the app supports additional sharing features in the future, HTML support will be a security matter.
Adding features is one way. I’d like to consider new features carefully that would affect others.
Your reasoning sounds conservative. In my understanding it’s like one would say it is potentially dangerous to visit a website.
Don’t take me wrong. I appreciate your attitude to take well pondered, carefully decisions. Users (like me ;)) often tend to desire more and more functionality. At the end Inkdrop is a Markdown notes app. I would propose to implement functionality which is generally considered as reasonable for Markdown.
Inkdrop uses remark-react for rendering Markdown and it prohibits from using HTML because of a potentially hazardous safety concern. Unfortunately it’s difficult to allow it in terms of implementation (I looked into it and tried before).
So it’d be good to be a plugin.
Yeah, I’m focusing on keeping the app simple and clean.
If it appeared that other people also want it, I’ll consider making it in the future.
Hi here, made a plugin (locally) using remark-toc; it works well to generate table of contents but link doesn’t work.
Explanation:
TOC for:
# A
Generates TOC (source code in preview):
<a href="#a">...</a>
But A header has id user-content-a
I cannot configure remark-toc to prefix href neither remove user-content prefix.
How would you do @craftzdog?
Here my gist
I guess link hashes don’t work because the browser window will try to have the target named link at the top of the view. I mean, it will cause not only the preview but also the entire app view scrolled down.
So you need to handle clicking toc links to scroll to the right position in your plugin without using A links.
Can you store a reference to the default behavior for MDEPreview.remarkReactOptions.remarkReactComponents.a in a variable and set it back on deactivation?
Thanks @anon29127703,
I removed jquery import but still using it (as jquery is part of electron inkdrop app) to keep animated scroll.
I rename package to toc
Not sure how to set back MDEPreview.remarkReactOptions.remarkReactComponents.a what would you do based on my code https://github.com/blacroix/inkdrop-toc/blob/master/src/inkdrop-toc.js? I tried something by I do not know if it will work.