{"version": 2, "width": 147, "height": 41, "timestamp": 1691509712, "env": {"SHELL": "/bin/bash", "TERM": "rxvt-unicode-256color"}} [0.003171, "o", "Running a demo to show some of python -m md_toc's capabilities...\r\n\r\n"] [1.004212, "o", "$ python -m md_toc -h\r\n"] [1.110495, "o", "usage: __main__.py [-h] [-c | -i] [-d] [-l] [-m TOC_MARKER] [-n NEWLINE_STRING] [-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\noptions:\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 -d, --diff returns 128 if the newly generated TOC differs from the one already existing in the file\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 the table of contents. Put this value between single quotes.\r\n Defaults to ''\r\n -n NEWLINE_STRING, --newline-string NEWLINE_STRING\r\n the string used to separate the lines of the TOC. Use single quotes to delimit the string. If you output in place all the\r\n newlines of the input file will be replaced with this 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. 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 --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, 128 TOC differs from the one in the file (see --diff option)\r\n\r\nCopyright (C) 2017-2023 Franco Masotti, frnmst\r\nLicense GPLv3+: GNU GPL version 3 or later \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.130052, "o", "\r\n~~~~\r\n"] [2.132961, "o", "1. inspecting the file...\r\n$ cat foo.md\r\n"] [2.133859, "o", "# Hi\r\n\r\n\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## __Bye bye__ **bye***\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.13415, "o", "\r\n~~~~\r\n"] [3.136129, "o", "2. run with default options...\r\n$ python -m md_toc github foo.md\r\n"] [3.241206, "o", "- [Hi](#hi)\r\n - [How are you? !!!](#how-are-you-----------)\r\n - [fine, thanks](#fine-thanks)\r\n - [Bye](#bye)\r\n - [__Bye bye__ **bye***](#bye-bye-bye)\r\n- [boo](#boo)\r\n- [a string with lots of spaces.](#a-string--------------with----------------lots-of-spaces)\r\n"] [3.263165, "o", "\r\n~~~~\r\n"] [4.265376, "o", "3. ordered list...\r\n$ python -m md_toc gitlab -o '.' foo.md\r\n"] [4.374239, "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. [__Bye bye__ **bye***](#bye-bye-bye)\r\n2. [boo](#boo)\r\n3. [a string with lots of spaces.](#a-string-with-lots-of-spaces)\r\n"] [4.390588, "o", "\r\n~~~~\r\n"] [5.392815, "o", "4. constant ordered list...\r\n$ python -m md_toc github -c -o '.' foo.md\r\n"] [5.502382, "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. [__Bye bye__ **bye***](#bye-bye-bye)\r\n1. [boo](#boo)\r\n1. [a string with lots of spaces.](#a-string--------------with----------------lots-of-spaces)\r\n"] [5.522723, "o", "\r\n~~~~\r\n"] [6.525053, "o", "5. no links...\r\n$ python -m md_toc -l github foo.md\r\n"] [6.634906, "o", "- Hi\r\n - How are you? !!!\r\n - fine, thanks\r\n - Bye\r\n - __Bye bye__ **bye***\r\n- boo\r\n- a string with lots of spaces.\r\n"] [6.65035, "o", "\r\n~~~~\r\n"] [7.652633, "o", "6. no links and no indentation...\r\n$ python -m md_toc -l -i github foo.md\r\n"] [7.759164, "o", "- Hi\r\n- How are you? !!!\r\n- fine, thanks\r\n- Bye\r\n- __Bye bye__ **bye***\r\n- boo\r\n- a string with lots of spaces.\r\n"] [7.774487, "o", "\r\n~~~~\r\n"] [8.776603, "o", "7. inspecting the non-coherent file...\r\n$ cat foo_noncoherent.md\r\n"] [8.777219, "o", "# Hi\r\n### boo\r\n"] [8.777375, "o", "\r\n~~~~\r\n"] [9.779351, "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"] [9.887258, "o", "Traceback (most recent call last):\r\n"] [9.888371, "o", " File \"/home/vm/dev/personal/stable/md-toc/md_toc/__main__.py\", line 36, in main\r\n result = args.func(args)\r\n ^^^^^^^^^^^^^^^\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/cli.py\", line 79, in write_toc\r\n toc_struct = build_multiple_tocs(\r\n ^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 482, in build_multiple_tocs"] [9.888556, "o", "\r\n toc_struct: list = [\r\n ^\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 483, in \r\n build_toc(\r\n File \"/home/vm/dev/personal/stable/md-toc/md_toc/api.py\", line 370, in build_toc\r\n raise TocDoesNotRenderAsCoherentList\r\nmd_toc.exceptions.TocDoesNotRenderAsCoherentList\r\n"] [9.904954, "o", "\r\n~~~~\r\n"] [10.907169, "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.013827, "o", "- [Hi](#hi)\r\n - [boo](#boo)\r\n"] [11.035609, "o", "\r\n~~~~\r\n"] [12.036881, "o", "10. use stdin, no links and no indentation...\r\n$ cat foo.md | python -m md_toc -l -i - cmark -u '*'\r\n"] [12.144446, "o", "* Hi\r\n* How are you? !!!\r\n* fine, thanks\r\n* Bye\r\n* __Bye bye__ **bye***\r\n* boo\r\n* a string with lots of spaces.\r\n"] [12.160201, "o", "\r\n~~~~\r\n"] [13.162281, "o", "11. inspecting a file where the first 5 lines need to be skipped...\r\n$ cat foo_skiplines.md\r\n"] [13.163072, "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"] [13.163221, "o", "\r\n~~~~\r\n"] [14.165522, "o", "12. using the skip lines option...\r\n$ python -m md_toc -s 5 github foo_skiplines.md\r\n"] [14.274055, "o", "- [Hi](#hi)\r\n - [How](#how)\r\n - [Are](#are)\r\n - [You](#you)\r\n- [Today ?](#today-)\r\n"] [14.292361, "o", "\r\n~~~~\r\n"] [15.29451, "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"] [15.404072, "o", "- [Hi](#hi)\r\n - [How are you? !!!](#how-are-you-)\r\n - [fine, thanks](#fine-thanks)\r\n - [Bye](#bye)\r\n - [__Bye bye__ **bye***](#bye-bye-bye)\r\n- [boo](#boo)\r\n- [a string with lots of spaces.](#a-string-with-lots-of-spaces)\r\n"] [15.419992, "o", "\r\n~~~~\r\n"] [16.422107, "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"] [16.610443, "o", "\r\n$ cat --show-nonprinting --show-ends foo.md\r\n"] [16.611294, "o", "# Hi^M$\r\n^M$\r\n^M^M$\r\n^M^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 - [__Bye bye__ **bye***](#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^M$\r\n^M^M$\r\n^M^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## __Bye bye__ **bye***^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"] [16.611495, "o", "\r\n~~~~\r\n"] [17.61361, "o", "15. 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"] [17.765212, "o", "$ cat foo.md\r\n"] [17.766148, "o", "# Hi\r\n\r\n\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 - [__Bye bye__ **bye***](#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\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## __Bye bye__ **bye***\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"] [17.766623, "o", "\r\n~~~~\r\n"] [18.768502, "o", "16. TOC diff. Check if the existing TOC in the file is different from\r\nthe newly generated one. In this case they are different so the return value is 128. 0 is returned if they are equal...\r\n$ python -m md_toc -p --diff github -l 6 foo_with_toc.md\r\n"] [18.916994, "o", "$ echo ${?}\r\n128\r\n$ cat foo_with_toc.md\r\n"] [18.917963, "o", "# Hi\r\n\r\n\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 - [__Bye bye__ **bye***](#bye-bye-bye)\r\n- [boo](#boo)\r\n- [a string with lots of spaces.](#a-string--------------with----------------lots-of-spaces)\r\n\r\n\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## __Bye bye__ **bye***\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"]