amaiorano / md-to-toc Goto Github PK
View Code? Open in Web Editor NEWA python script that outputs a table of contents from a markdown file
License: MIT License
A python script that outputs a table of contents from a markdown file
License: MIT License
Markdown allows underlining or # titles, this seems to ignore the underlined ones:
# Header 1
Header 1
--------
## Header 2
Header 2
=======
If any headers have code tags
in them, the automatically generated hyperlinks don't work. To fix this, simply remove any backticks (`) from the links.
An example with broken links due to backticks in links:
https://github.com/rbotts/Occupancy/blob/446c2205c8c78eddc87ebd20a86e1bad850dfdea/UnmarkedGuide.md
(note that the two TOC items without any code tags have working links, but all the TOC items with code tags, such as "Creating colext
models" do not have working links.)
An example with those links fixed by removing the backticks:
https://github.com/rbotts/Occupancy/blob/f134cb8cb9626463e71df73c01681112eb004e9b/UnmarkedGuide.md
(note that now even the TOC items with code tags do have working links.
The diff between the two:
rbotts/Occupancy@f134cb8#diff-776f5c8d16bf7b01e8f44ec08d2ac678
When using pandoc to generate html output, md-to-toc
fails to match the generated id if the heading contains a full stop or more than one consecutive space:
Source markdown:
# Multiple spaces.
Pandoc output:
<h1 id="multiple-spaces.">Multiple spaces.</h1>
md-to-toc output:
- [Multiple spaces.](#multiple---spaces)
Pandoc keeps the full stop while md-to-toc
strips it out.
Pandoc collapses multiple spaces into a single dash while md-to-toc
converts every space to a dash.
md-to-toc
is designed to replicate GitHub's algorithm for determining anchor strings and GitHub may well handle these cases differently to pandoc. Thought I'd bring it to your attention anyway.
Aside from these two issues, which were trivial to work around, the script worked very well and saved me a lot of time. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.