Browse Source

Updated asciinema video.

master
Franco Masotti 6 months ago
parent
commit
1f35608e68
Signed by: frnmst
GPG Key ID: 24116ED85666780A
  1. 2
      Makefile
  2. 4
      README.rst
  3. 56
      asciinema/md_toc_asciinema_8_1_0.json
  4. 203
      asciinema/md_toc_asciinema_8_1_0_demo.sh

2
Makefile

@ -47,7 +47,7 @@ update: install-dev
pipenv run pre-commit autoupdate
demo:
asciinema/md_toc_asciinema_$$(git describe --tags $$(git rev-list --tags --max-count=1) | tr '.' '_')_demo.sh
pipenv run asciinema/md_toc_asciinema_$$(git describe --tags $$(git rev-list --tags --max-count=1) | tr '.' '_')_demo.sh
test:
pipenv run python -m unittest $(PACKAGE_NAME).tests.tests --failfast --locals --verbose

4
README.rst

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

56
asciinema/md_toc_asciinema_8_1_0.json

@ -0,0 +1,56 @@
{"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"]

203
asciinema/md_toc_asciinema_8_1_0_demo.sh

@ -0,0 +1,203 @@
#!/bin/bash
#
# python -m md_toc_asciinema_8_1_0_demo.sh
#
# Copyright (C) 2021 Franco Masotti (franco \D\o\T masotti {-A-T-} tutanota \D\o\T 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 3 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
gen_foo()
{
cat <<-EOF > foo.md
# Hi
<!--TOC-->
hey
## How are you? !!!
## fine, thanks
### Bye
## <small>__Bye bye__ **bye***</small>
\`\`\`python
# This is a code
# fence with comments that might represent ATX-style headings
# if not properly parsed
\`\`\`
bye
# boo
# a string with lots of spaces.
EOF
}
gen_foo_noncoherent()
{
cat <<-EOF > foo_noncoherent.md
# Hi
### boo
EOF
}
gen_foo_skiplines()
{
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 "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~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "1. inspecting the file...\n"
printf "$ cat foo.md\n"
cat foo.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "2. run with default options...\n"
printf "$ python -m md_toc github foo.md\n"
python -m md_toc github foo.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "3. ordered list...\n"
printf "$ python -m md_toc gitlab -o '.' foo.md\n"
python -m md_toc gitlab -o '.' foo.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "4. 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~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "5. no links...\n"
printf "$ python -m md_toc -l github foo.md\n"
python -m md_toc -l github foo.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "6. 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~~~~\n"
sleep ${TIMEOUT}
gen_foo_noncoherent
printf "7. inspecting the non-coherent file...\n"
printf "$ cat foo_noncoherent.md\n"
cat foo_noncoherent.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo_noncoherent
printf "8. 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~~~~\n"
sleep ${TIMEOUT}
gen_foo_noncoherent
printf "9. 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~~~~\n"
sleep ${TIMEOUT}
printf "10. 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~~~~\n"
sleep ${TIMEOUT}
gen_foo_skiplines
printf "11. 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~~~~\n"
sleep ${TIMEOUT}
gen_foo_skiplines
printf "12. 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~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "13. showing GitLab's removal of consecutive dashes in the link destination...\n"
printf "$ python -m md_toc gitlab -l 6 foo.md\n"
python -m md_toc gitlab -l 6 foo.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "14. editing file in place with a custom newline...\n"
printf "$ python -m md_toc --newline '\\\r\\\n' -p gitlab -l 6 foo.md\n"
python -m md_toc --newline '\r\n' -p gitlab -l 6 foo.md
printf "\n"
printf "$ cat --show-nonprinting --show-ends foo.md\n"
cat --show-nonprinting --show-ends foo.md
printf "\n~~~~\n"
sleep ${TIMEOUT}
gen_foo
printf "15. 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