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.
 
 
 

47 lines
8.3 KiB

{"version": 2, "width": 83, "height": 46, "timestamp": 1622221077, "env": {"SHELL": "/bin/bash", "TERM": "rxvt-unicode-256color"}}
[0.008049, "o", "Running a demo to show some of python -m md_toc's capabilities...\r\n\r\n"]
[1.015122, "o", "$ python -m md_toc -h\r\n"]
[1.356915, "o", "usage: __main__.py [-h] [-c | -i] [-l] [-m TOC_MARKER] [-n NEWLINE_STRING]\r\n [-p] [-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\r\n positioning the table of contents. Defaults to <!--\r\n 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 t"]
[1.357019, "o", "he string. 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.449011, "o", "\r\n"]
[2.457318, "o", "Inspecting the file...\r\n$ cat foo.md\r\n"]
[2.458509, "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.459323, "o", "\r\n"]
[3.467115, "o", "Run with default options...\r\n$ python -m md_toc github foo.md\r\n"]
[3.932094, "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"]
[4.018819, "o", "\r\n"]
[5.020617, "o", "Ordered list...\r\n$ python -m md_toc gitlab -o '.' foo.md\r\n"]
[5.43953, "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"]
[5.499317, "o", "\r\n"]
[6.501616, "o", "Constant ordered list...\r\n$ python -m md_toc github -c -o '.' foo.md\r\n"]
[6.897007, "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"]
[6.963218, "o", "\r\n"]
[7.965299, "o", "No links...\r\n$ python -m md_toc -l github foo.md\r\n"]
[8.342501, "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.419095, "o", "\r\n"]
[9.421119, "o", "No links and no indentation...\r\n$ python -m md_toc -l -i github foo.md\r\n"]
[9.951343, "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"]
[10.052129, "o", "\r\n"]
[11.053621, "o", "Inspecting the non-coherent file...\r\n$ cat foo_noncoherent.md\r\n"]
[11.055057, "o", "# Hi\r\n### boo\r\n"]
[11.055449, "o", "\r\n"]
[12.05725, "o", "Trying to parse a non coherent markdown file will raise an exception...\r\n$ python -m md_toc github foo_noncoherent.md\r\n"]
[12.513556, "o", "Traceback (most recent call last):\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/__main__.py\", line 34, in main\r\n result = args.func(args)\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/cli.py\", line 73, in write_toc\r\n newline_string=newline_string)\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 842, in build_multiple_tocs\r\n list_marker, skip_lines, constant_ordered_list, newline_string))\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 748, in build_toc\r\n raise TocDoesNotRenderAsCoherentList\r\nmd_toc.exceptions.TocDoesNotRenderAsCoherentList\r\n"]
[12.598876, "o", "\r\n"]
[13.601292, "o", "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"]
[13.957473, "o", "- [Hi](#hi)\r\n - [boo](#boo)\r\n"]
[14.008105, "o", "\r\n"]
[15.008974, "o", "Use stdin, no links and no indentation...\r\n$ cat foo.md | python -m md_toc -l -i - cmark -u '*'\r\n"]
[15.429645, "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"]
[15.514497, "o", "\r\n"]
[16.516463, "o", "Inspecting a file where the first 5 lines need to be skipped...\r\n$ cat foo_skiplines.md\r\n# 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"]
[16.519302, "o", "\r\n"]
[17.519869, "o", "Using the skip lines option...\r\n$ python -m md_toc -s 5 github foo_skiplines.md\r\n"]
[17.935135, "o", "- [Hi](#hi)\r\n - [How](#how)\r\n - [Are](#are)\r\n - [You](#you)\r\n- [Today ?](#today-)\r\n"]
[18.007388, "o", "\r\n"]
[19.009973, "o", "Showing Gitlab's removal of consecutive dashes in the link destination...\r\n$ python -m md_toc gitlab -l 6 foo.md\r\n"]
[19.41085, "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"]
[19.483543, "o", "\r\n"]
[20.486416, "o", "Editing the file in-place. As you can see, code fence detection still needs to be implemented for redcarpet...\r\n$ python -m md_toc -p redcarpet foo.md\r\n"]
[21.00377, "o", "$ cat foo.md\r\n"]
[21.007926, "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"]