Browse Source

Added new demo.

master
Franco Masotti 1 year ago
parent
commit
a18da366ad
Signed by: frnmst
GPG Key ID: 24116ED85666780A
  1. 4
      README.rst
  2. 4
      asciinema/md_toc_asciinema_7_0_0_demo.sh
  3. 45
      asciinema/md_toc_asciinema_7_1_0.json
  4. 164
      asciinema/md_toc_asciinema_7_1_0_demo.sh

4
README.rst

@ -36,8 +36,8 @@ improve document readability.
Video
-----
.. image:: https://asciinema.org/a/313824.png
:target: https://asciinema.org/a/313824
.. image:: https://asciinema.org/a/385730.png
:target: https://asciinema.org/a/385730
:align: center
Description

4
asciinema/md_toc_asciinema_7_0_0_demo.sh

@ -1,9 +1,9 @@
#!/bin/bash
#
# python -m md_toc_asciinema_6_0_0_demo.sh
# python -m md_toc_asciinema_7_0_0_demo.sh
#
# Copyright (C) 2019 frnmst (Franco Masotti) <franco.masotti@live.com>
# Copyright (C) 2020 frnmst (Franco Masotti) <franco.masotti@live.com>
#
# This file is part of md-toc.
#

45
asciinema/md_toc_asciinema_7_1_0.json

@ -0,0 +1,45 @@
{"version": 2, "width": 83, "height": 46, "timestamp": 1611160459, "env": {"SHELL": "/bin/bash", "TERM": "rxvt-unicode-256color"}}
[0.006135, "o", "Running a demo to show some of python -m md_toc's capabilities...\r\n\r\n"]
[1.007122, "o", "$ python -m md_toc -h\r\n"]
[1.205091, "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\r\n the 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.\r\n Defaults to 0, i.e. do not skip any lines\r\n -v, --version"]
[1.205153, "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-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.22023, "o", "\r\n"]
[2.223355, "o", "Inspecting the file...\r\n$ cat foo.md\r\n"]
[2.223963, "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.224005, "o", "\r\n"]
[3.224999, "o", "Run with default options...\r\n$ python -m md_toc github foo.md\r\n"]
[3.439828, "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.457865, "o", "\r\n"]
[4.458982, "o", "Ordered list...\r\n$ python -m md_toc gitlab -o '.' foo.md\r\n"]
[4.648557, "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.664706, "o", "\r\n"]
[5.665772, "o", "Constant ordered list...\r\n$ python -m md_toc github -c -o '.' foo.md\r\n"]
[5.87788, "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)\r\n1. [boo](#boo)\r\n"]
[5.894791, "o", "\r\n"]
[6.895756, "o", "No links...\r\n$ python -m md_toc -l github foo.md\r\n"]
[7.10896, "o", "- Hi\r\n - How are you? !!!\r\n - fine, thanks\r\n - Bye\r\n - Bye bye\r\n- boo\r\n"]
[7.123939, "o", "\r\n"]
[8.125197, "o", "No links and no indentation...\r\n$ python -m md_toc -l -i github foo.md\r\n"]
[8.331182, "o", "- Hi\r\n- How are you? !!!\r\n- fine, thanks\r\n- Bye\r\n- Bye bye\r\n- boo\r\n"]
[8.346253, "o", "\r\n"]
[9.347239, "o", "Inspecting the non-coherent file...\r\n$ cat foo_noncoherent.md\r\n"]
[9.347893, "o", "# Hi\r\n### boo\r\n"]
[9.348052, "o", "\r\n"]
[10.350585, "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"]
[10.560376, "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 55, 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 367, 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 276, in build_toc\r\n raise TocDoesNotRenderAsCoherentList\r\nmd_toc.exceptions.TocDoesNotRenderAsCoherentList\r\n"]
[10.576715, "o", "\r\n"]
[11.578079, "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"]
[11.801014, "o", "- [Hi](#hi)\r\n - [boo](#boo)\r\n"]
[11.81771, "o", "\r\n"]
[12.818955, "o", "Use stdin, no links and no indentation...\r\n$ cat foo.md | python -m md_toc -l -i - cmark -u '*'\r\n"]
[13.029036, "o", "* Hi\r\n* How are you? !!!\r\n* fine, thanks\r\n* Bye\r\n* Bye bye\r\n* boo\r\n"]
[13.044662, "o", "\r\n"]
[14.045578, "o", "Inspecting a file where the first 5 lines need to be skipped...\r\n$ cat foo_skiplines.md\r\n"]
[14.046162, "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.046329, "o", "\r\n"]
[15.04761, "o", "Using the skip lines option...\r\n$ python -m md_toc -s 5 github foo_skiplines.md\r\n"]
[15.244163, "o", "- [Hi](#hi)\r\n - [How](#how)\r\n - [Are](#are)\r\n - [You](#you)\r\n- [Today ?](#today-)\r\n"]
[15.259783, "o", "\r\n"]
[16.260795, "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"]
[16.488959, "o", "$ cat foo.md\r\n"]
[16.489472, "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"]

164
asciinema/md_toc_asciinema_7_1_0_demo.sh

@ -0,0 +1,164 @@
#!/bin/bash
#
# python -m md_toc_asciinema_7_1_0_demo.sh
#
# Copyright (C) 2021 frnmst (Franco Masotti) <franco.masotti@live.com>
#
# This file is part of md-toc.
#
# md-toc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 5 of the License, or
# (at your option) any later version.
#
# md-toc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with md-toc. If not, see <http://www.gnu.org/licenses/>.
#
# Discover python -m md_toc of this repository not the one installed on the system.
export PYTHONPATH='..'
TIMEOUT=1
alias python='pipenv run python'
###
###
printf "Running a demo to show some of python -m md_toc's capabilities...\n"
printf "\n"
sleep ${TIMEOUT}
printf "$ python -m md_toc -h\n"
python -m md_toc -h
printf "\n"
sleep ${TIMEOUT}
cat <<-EOF > foo.md
# Hi
<!--TOC-->
hey
## How are you? !!!
## fine, thanks
### Bye
## Bye bye
\`\`\`python
# This is a code
# fence with comments that might represent ATX-style headings
# if not properly parsed
\`\`\`
bye
# boo
EOF
cat <<-EOF > foo_noncoherent.md
# Hi
### boo
EOF
cat <<-EOF > foo_skiplines.md
# I want this line to be a comment
#### And this as well
## And this
###### ByeBye
# Hi
## How
### Are
## You
# Today ?
EOF
printf "Inspecting the file...\n"
printf "$ cat foo.md\n"
cat foo.md
printf "\n"
sleep ${TIMEOUT}
printf "Run with default options...\n"
printf "$ python -m md_toc github foo.md\n"
python -m md_toc github foo.md
printf "\n"
sleep ${TIMEOUT}
printf "Ordered list...\n"
printf "$ python -m md_toc gitlab -o '.' foo.md\n"
python -m md_toc gitlab -o '.' foo.md
printf "\n"
sleep ${TIMEOUT}
printf "Constant ordered list...\n"
printf "$ python -m md_toc github -c -o '.' foo.md\n"
python -m md_toc github -c -o '.' foo.md
printf "\n"
sleep ${TIMEOUT}
printf "No links...\n"
printf "$ python -m md_toc -l github foo.md\n"
python -m md_toc -l github foo.md
printf "\n"
sleep ${TIMEOUT}
printf "No links and no indentation...\n"
printf "$ python -m md_toc -l -i github foo.md\n"
python -m md_toc -l -i github foo.md
printf "\n"
sleep ${TIMEOUT}
printf "Inspecting the non-coherent file...\n"
printf "$ cat foo_noncoherent.md\n"
cat foo_noncoherent.md
printf "\n"
sleep ${TIMEOUT}
printf "Trying to parse a non coherent markdown file will raise an exception...\n"
printf "$ python -m md_toc github foo_noncoherent.md\n"
python -m md_toc github foo_noncoherent.md
printf "\n"
sleep ${TIMEOUT}
printf "Try to parse a non coherent markdown file without checking for coherence...\n"
printf "$ python -m md_toc -c github foo_noncoherent.md\n"
python -m md_toc -c github foo_noncoherent.md
printf "\n"
sleep ${TIMEOUT}
printf "Use stdin, no links and no indentation...\n"
printf "$ cat foo.md | python -m md_toc -l -i - cmark -u '*'\n"
cat foo.md | python -m md_toc -l -i cmark -u '*'
printf "\n"
sleep ${TIMEOUT}
printf "Inspecting a file where the first 5 lines need to be skipped...\n"
printf "$ cat foo_skiplines.md\n"
cat foo_skiplines.md
printf "\n"
sleep ${TIMEOUT}
printf "Using the skip lines option...\n"
printf "$ python -m md_toc -s 5 github foo_skiplines.md\n"
python -m md_toc -s 5 github foo_skiplines.md
printf "\n"
sleep ${TIMEOUT}
printf "Editing the file in-place. As you can see, code fence \
detection still needs to be implemented for redcarpet...\n"
printf "$ python -m md_toc -p redcarpet foo.md\n"
python -m md_toc -p redcarpet foo.md
printf "$ cat foo.md\n"
cat foo.md
rm foo.md foo_noncoherent.md foo_skiplines.md
Loading…
Cancel
Save