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.
 
 
 

42 lines
6.2 KiB

{"version": 2, "width": 89, "height": 46, "timestamp": 1585155760, "env": {"SHELL": "/bin/bash", "TERM": "rxvt-unicode-256color"}}
[0.010153, "o", "Running a demo to show some of python -m md_toc's capabilities...\r\n\r\n"]
[1.011397, "o", "$ python -m md_toc -h\r\n"]
[1.144886, "o", "usage: __main__.py [-h] [-c | -i] [-l] [-m TOC_MARKER] [-p] [-s SKIP_LINES] [-v]\r\n {github,cmark,gitlab,commonmarker,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 the\r\n table of contents. Defaults to <!--TOC-->\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\r\n 0, i.e. do not skip any lines\r\n -v, --version"]
[1.144939, "o", " show program's version number and exit\r\n\r\nmarkdown parser:\r\n {github,cmark,gitlab,commonmarker,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-2020 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.153268, "o", "\r\n"]
[2.157095, "o", "Inspecting the file...\r\n$ cat foo.md\r\n"]
[2.157653, "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## 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"]
[2.157873, "o", "\r\n"]
[3.158819, "o", "Run with default options...\r\n$ python -m md_toc github foo.md\r\n"]
[3.291031, "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)\r\n- [boo](#boo)\r\n"]
[3.298924, "o", "\r\n"]
[4.299849, "o", "Ordered list...\r\n$ python -m md_toc gitlab -o '.' foo.md\r\n"]
[4.440878, "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)\r\n2. [boo](#boo)\r\n"]
[4.449244, "o", "\r\n"]
[5.450176, "o", "No links...\r\n$ python -m md_toc -l github foo.md\r\n"]
[5.587205, "o", "- Hi\r\n - How are you? !!!\r\n - fine, thanks\r\n - Bye\r\n - Bye bye\r\n- boo\r\n"]
[5.595605, "o", "\r\n"]
[6.596582, "o", "No links and no indentation...\r\n$ python -m md_toc -l -i github foo.md\r\n"]
[6.729254, "o", "- Hi\r\n- How are you? !!!\r\n- fine, thanks\r\n- Bye\r\n- Bye bye\r\n- boo\r\n"]
[6.737559, "o", "\r\n"]
[7.738477, "o", "Inspecting the non-coherent file...\r\n$ cat foo_noncoherent.md\r\n"]
[7.739502, "o", "# Hi\r\n### boo\r\n"]
[7.739825, "o", "\r\n"]
[8.74086, "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"]
[8.877359, "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 54, 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 335, 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 257, in build_toc\r\n raise TocDoesNotRenderAsCoherentList\r\nmd_toc.exceptions.TocDoesNotRenderAsCoherentList\r\n"]
[8.886285, "o", "\r\n"]
[9.887329, "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"]
[10.027086, "o", "- [Hi](#hi)\r\n - [boo](#boo)\r\n"]
[10.035279, "o", "\r\n"]
[11.036226, "o", "Use stdin, no links and no indentation...\r\n$ cat foo.md | python -m md_toc -l -i - cmark -u '*'\r\n"]
[11.163924, "o", "* Hi\r\n* How are you? !!!\r\n* fine, thanks\r\n* Bye\r\n* Bye bye\r\n* boo\r\n"]
[11.172106, "o", "\r\n"]
[12.173201, "o", "Inspecting a file where the first 5 lines need to be skipped...\r\n$ cat foo_skiplines.md\r\n"]
[12.174048, "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"]
[12.174162, "o", "\r\n"]
[13.175239, "o", "Using the skip lines option...\r\n$ python -m md_toc -s 5 github foo_skiplines.md\r\n"]
[13.312227, "o", "- [Hi](#hi)\r\n - [How](#how)\r\n - [Are](#are)\r\n - [You](#you)\r\n- [Today ?](#today-)\r\n"]
[13.32088, "o", "\r\n"]
[14.322071, "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"]
[14.491408, "o", "$ cat foo.md\r\n"]
[14.492049, "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 - [Bye bye](#bye-bye)\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\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## 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"]