Automatically generate a compliant table of contents for a markdown file to improve document readability https://docs.franco.net.eu.org/md-toc/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

56 lines
9.8 KiB

{"version": 2, "width": 83, "height": 46, "timestamp": 1638223392, "env": {"SHELL": "/bin/bash", "TERM": "rxvt-unicode-256color"}}
[0.002946, "o", "Running a demo to show some of python -m md_toc's capabilities...\r\n\r\n"]
[1.004213, "o", "$ python -m md_toc -h\r\n"]
[1.216159, "o", "usage: __main__.py [-h] [-c | -i] [-l] [-m TOC_MARKER] [-n NEWLINE_STRING] [-p]\r\n [-s SKIP_LINES] [-v]\r\n {github,commonmarker,gitlab,cmark,goldmark,redcarpet} ...\r\n\r\nMarkdown Table Of Contents: Automatically generate a compliant table\r\nof contents for a markdown file to improve document readability.\r\n\r\noptional arguments:\r\n -h, --help show this help message and exit\r\n -c, --no-list-coherence\r\n avoids checking for TOC list coherence\r\n -i, --no-indentation avoids adding indentations to the TOC\r\n -l, --no-links avoids adding links to the TOC\r\n -m TOC_MARKER, --toc-marker TOC_MARKER\r\n set the string to be used as the marker for positioning\r\n the table of contents. Defaults to <!--TOC-->\r\n -n NEWLINE_STRING, --newline-string NEWLINE_STRING\r\n the string used to separate the lines of the TOC. Use\r\n quotes to delimit the string. If you output i"]
[1.21623, "o", "n place all\r\n the newlines of the input file will be replaced with this\r\n value. Defaults to '\\n'\r\n -p, --in-place overwrite the input file\r\n -s SKIP_LINES, --skip-lines SKIP_LINES\r\n skip parsing of the first selected number of lines.\r\n Defaults to 0, i.e. do not skip any lines\r\n -v, --version show program's version number and exit\r\n\r\nmarkdown parser:\r\n {github,commonmarker,gitlab,cmark,goldmark,redcarpet}\r\n <markdown parser> --help\r\n\r\nPlease read the documentation to understand how each parser works\r\n\r\nReturn values: 0 ok, 1 error, 2 invalid command\r\n\r\nCopyright (C) 2017-2021 Franco Masotti, frnmst\r\nLicense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\r\nThis is free software: you are free to change and redistribute it.\r\nThere is NO WARRANTY, to the extent permitted by law.\r\n"]
[1.231495, "o", "\r\n~~~~\r\n"]
[2.23527, "o", "1. inspecting the file...\r\n$ cat foo.md\r\n"]
[2.236755, "o", "# Hi\r\n\r\n<!--TOC-->\r\n\r\nhey\r\n\r\n## How are you? !!!\r\n\r\n## fine, thanks\r\n\r\n### Bye\r\n\r\n## <small>__Bye bye__ **bye***</small>\r\n\r\n```python\r\n# This is a code\r\n# fence with comments that might represent ATX-style headings\r\n# if not properly parsed\r\n```\r\n\r\nbye\r\n\r\n# boo\r\n\r\n# a string with lots of spaces.\r\n"]
[2.237414, "o", "\r\n~~~~\r\n"]
[3.2415, "o", "2. run with default options...\r\n$ python -m md_toc github foo.md\r\n"]
[3.479479, "o", "- [Hi](#hi)\r\n - [How are you? !!!](#how-are-you-----------)\r\n - [fine, thanks](#fine-thanks)\r\n - [Bye](#bye)\r\n - [<small>__Bye bye__ **bye***</small>](#bye-bye-bye)\r\n- [boo](#boo)\r\n- [a string with lots of spaces.](#a-string--------------with----------------lots-of-spaces)\r\n"]
[3.494502, "o", "\r\n~~~~\r\n"]
[4.496332, "o", "3. ordered list...\r\n$ python -m md_toc gitlab -o '.' foo.md\r\n"]
[4.695467, "o", "1. [Hi](#hi)\r\n 1. [How are you? !!!](#how-are-you-)\r\n 2. [fine, thanks](#fine-thanks)\r\n 1. [Bye](#bye)\r\n 3. [<small>__Bye bye__ **bye***</small>](#bye-bye-bye)\r\n2. [boo](#boo)\r\n3. [a string with lots of spaces.](#a-string-with-lots-of-spaces)\r\n"]
[4.709769, "o", "\r\n~~~~\r\n"]
[5.712839, "o", "4. constant ordered list...\r\n$ python -m md_toc github -c -o '.' foo.md\r\n"]
[5.929494, "o", "1. [Hi](#hi)\r\n 1. [How are you? !!!](#how-are-you-----------)\r\n 1. [fine, thanks](#fine-thanks)\r\n 1. [Bye](#bye)\r\n 1. [<small>__Bye bye__ **bye***</small>](#bye-bye-bye)\r\n1. [boo](#boo)\r\n1. [a string with lots of spaces.](#a-string--------------with----------------lots-of-spaces)\r\n"]
[5.943946, "o", "\r\n~~~~\r\n"]
[6.945834, "o", "5. no links...\r\n$ python -m md_toc -l github foo.md\r\n"]
[7.175309, "o", "- Hi\r\n - How are you? !!!\r\n - fine, thanks\r\n - Bye\r\n - <small>__Bye bye__ **bye***</small>\r\n- boo\r\n- a string with lots of spaces.\r\n"]
[7.19285, "o", "\r\n~~~~\r\n"]
[8.194795, "o", "6. no links and no indentation...\r\n$ python -m md_toc -l -i github foo.md\r\n"]
[8.392153, "o", "- Hi\r\n- How are you? !!!\r\n- fine, thanks\r\n- Bye\r\n- <small>__Bye bye__ **bye***</small>\r\n- boo\r\n- a string with lots of spaces.\r\n"]
[8.405631, "o", "\r\n~~~~\r\n"]
[9.408707, "o", "7. inspecting the non-coherent file...\r\n$ cat foo_noncoherent.md\r\n"]
[9.409761, "o", "# Hi\r\n### boo\r\n"]
[9.410067, "o", "\r\n~~~~\r\n"]
[10.412979, "o", "8. trying to parse a non coherent markdown file will raise an exception...\r\n$ python -m md_toc github foo_noncoherent.md\r\n"]
[10.647775, "o", "Traceback (most recent call last):\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/__main__.py\", line 35, in main\r\n result = args.func(args)\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/cli.py\", line 64, in write_toc\r\n toc_struct = build_multiple_tocs(\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 378, in build_multiple_tocs\r\n build_toc(filenames[file_id], ordered, no_links, no_indentation,\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 283, in build_toc\r\n raise TocDoesNotRenderAsCoherentList\r\nmd_toc.exceptions.TocDoesNotRenderAsCoherentList\r\n"]
[10.664687, "o", "\r\n~~~~\r\n"]
[11.667053, "o", "9. try to parse a non coherent markdown file without checking for coherence...\r\n$ python -m md_toc -c github foo_noncoherent.md\r\n"]
[11.877614, "o", "- [Hi](#hi)\r\n - [boo](#boo)\r\n"]
[11.891481, "o", "\r\n~~~~\r\n"]
[12.892696, "o", "10. use stdin, no links and no indentation...\r\n$ cat foo.md | python -m md_toc -l -i - cmark -u '*'\r\n"]
[13.105842, "o", "* Hi\r\n* How are you? !!!\r\n* fine, thanks\r\n* Bye\r\n* <small>__Bye bye__ **bye***</small>\r\n* boo\r\n* a string with lots of spaces.\r\n"]
[13.121329, "o", "\r\n~~~~\r\n"]
[14.123426, "o", "11. inspecting a file where the first 5 lines need to be skipped...\r\n$ cat foo_skiplines.md\r\n"]
[14.124117, "o", "# I want this line to be a comment\r\n#### And this as well\r\n## And this\r\n###### ByeBye\r\n\r\n# Hi\r\n## How\r\n### Are\r\n## You\r\n# Today ?\r\n"]
[14.124462, "o", "\r\n~~~~\r\n"]
[15.12656, "o", "12. using the skip lines option...\r\n$ python -m md_toc -s 5 github foo_skiplines.md\r\n"]
[15.335789, "o", "- [Hi](#hi)\r\n - [How](#how)\r\n - [Are](#are)\r\n - [You](#you)\r\n- [Today ?](#today-)\r\n"]
[15.350826, "o", "\r\n~~~~\r\n"]
[16.353282, "o", "13. showing GitLab's removal of consecutive dashes in the link destination...\r\n$ python -m md_toc gitlab -l 6 foo.md\r\n"]
[16.570979, "o", "- [Hi](#hi)\r\n - [How are you? !!!](#how-are-you-)\r\n - [fine, thanks](#fine-thanks)\r\n - [Bye](#bye)\r\n - [<small>__Bye bye__ **bye***</small>](#bye-bye-bye)\r\n- [boo](#boo)\r\n- [a string with lots of spaces.](#a-string-with-lots-of-spaces)\r\n"]
[16.585488, "o", "\r\n~~~~\r\n"]
[17.587717, "o", "14. editing file in place with a custom newline...\r\n$ python -m md_toc --newline '\\r\\n' -p gitlab -l 6 foo.md\r\n"]
[17.88186, "o", "\r\n$ cat --show-nonprinting --show-ends foo.md\r\n"]
[17.882617, "o", "# Hi^M$\r\n^M$\r\n<!--TOC-->^M$\r\n^M$\r\n- [Hi](#hi)^M^M$\r\n - [How are you? !!!](#how-are-you-)^M^M$\r\n - [fine, thanks](#fine-thanks)^M^M$\r\n - [Bye](#bye)^M^M$\r\n - [<small>__Bye bye__ **bye***</small>](#bye-bye-bye)^M^M$\r\n- [boo](#boo)^M^M$\r\n- [a string with lots of spaces.](#a-string-with-lots-of-spaces)^M$\r\n^M$\r\n<!--TOC-->^M$\r\n^M$\r\nhey^M$\r\n^M$\r\n## How are you? !!!^M$\r\n^M$\r\n## fine, thanks^M$\r\n^M$\r\n### Bye^M$\r\n^M$\r\n## <small>__Bye bye__ **bye***</small>^M$\r\n^M$\r\n```python^M$\r\n# This is a code^M$\r\n# fence with comments that might represent ATX-style headings^M$\r\n# if not properly parsed^M$\r\n```^M$\r\n^M$\r\nbye^M$\r\n^M$\r\n# boo^M$\r\n^M$\r\n# a string with lots of spaces.^M$\r\n"]
[17.882932, "o", "\r\n~~~~\r\n"]
[18.885713, "o", "15. editing the file in-place. As you can see, code fence detection still needs to be implemented for redcarpet..."]
[18.885907, "o", "\r\n"]
[18.886082, "o", "$ python -m md_toc -p redcarpet foo.md"]
[18.886268, "o", "\r\n"]
[19.176672, "o", "$ cat foo.md"]
[19.176844, "o", "\r\n"]
[19.177659, "o", "# Hi\r\n\r\n<!--TOC-->\r\n\r\n- [Hi](#hi)\r\n - [How are you? !!!](#how-are-you)\r\n - [fine, thanks](#fine-thanks)\r\n - [Bye](#bye)\r\n - [<small>__Bye bye__ **bye***</small>](#small>__bye-bye__-bye-small>)\r\n- [This is a code](#this-is-a-code)\r\n- [fence with comments that might represent ATX-style headings](#fence-with-comments-that-might-represent-atx-style-headings)\r\n- [if not properly parsed](#if-not-properly-parsed)\r\n- [boo](#boo)\r\n- [a string with lots of spaces.](#a-string-with-lots-of-spaces)\r\n\r\n<!--TOC-->\r\n\r\nhey\r\n\r\n## How are you? !!!\r\n\r\n## fine, thanks\r\n\r\n### Bye\r\n\r\n## <small>__Bye bye__ **bye***</small>\r\n\r\n```python\r\n# This is a code\r\n# fence with comments that might represent ATX-style headings\r\n# if not properly parsed\r\n```\r\n\r\nbye\r\n\r\n# boo\r\n\r\n# a string with lots of spaces.\r\n"]