A study how the HTML id values of ATX headings are generated by GitHub Flavored Markdown processor
Here is the simplest case
Ampersand character (&) matters.
Under bar character (_) matters.
Parentheses ( and ) matters
Dot character (.) matters.
Hyphen character (-) matters.
Slash character (/) matters.
Colon character (:) matters.
$ cd MarkdownUtils
$ gradle publishdocs
This single line is equivalent to the following operation in the command line:
---
$ cd MarkdownUtils
$ cd docs
$ ./indexconv.sh -t
$ cd ..
$ git add .
$ git commit -m "update docs"
$ git push
---
TO BE AUTHORED
The index_.adoc
is originally authored in AsciiDoc.
I will execute the following command.
$ cd docs
$ ./indexconv.sh -t
The readmeconv.sh
will generate README.md
file. It will have
the following “Table of Contents” section.
- [MarkdownUtils](#_markdownutils)
- [com.kazurayam.markdownutils.PandocMarkdownTranslator](#_com_kazurayam_markdownutils_pandocmarkdowntranslator)
- [Problem to solve](#_problem_to_solve)
# MarkdownUtils
...
When I push this README.md up to GitHub, the link from TOC to the body sections does not work. The links are broken.
What do I mean “the links are broken”? If you open https://github.com/kazurayam/MarkdownUtils/ using any web browser and view the HTML source, you will find a section:
<a href="#_problem_to_solve">Problem to solve</a>
and also you will find a sction:
I will execute the follwoing command:
$ cd $MarkdownUtils
$ java -jar ./libs/MarkdownUtils-0.1.0-SNAPSHOT ./README.md ./temp.md
The jar contains the com.kazurayam.markdownutils.PandocMarkdownTranslator
class.
The above command will call translateFile("./README.md", "temp.md")
emthod, and
generate a new file temp.md
, which will have the following section:
- [MarkdownUtils](#markdownutils)
- [com.kazurayam.markdownutils.PandocMarkdownTranslator](#com-kazurayam-markdownutils-pandocmarkdowntranslator)
- [Problem to solve](#problem-to-solve)
# MarkdownUtils
...
Please find the link symbols are slightly amended.
The amended link symbols conforms to GitHub Flavoured Mardown spec.
When temp.md
is pushed to GitHub, the links in TOC to text body will work.
The PandocMarkdownTranslator
does this small patching over Markdown texts
generated by pandoc
.