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.
105 lines
2.2 KiB
105 lines
2.2 KiB
#!/bin/bash |
|
|
|
# |
|
# md_toc_asciinema_3_1_0_demo.sh |
|
# |
|
# Copyright (C) 2019 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 md_toc of this repository not the one installed on the system. |
|
export PYTHONPATH='..' |
|
|
|
printf "Running a demo to show some of md_toc's capabilities...\n" |
|
printf "\n" |
|
sleep 2 |
|
|
|
printf "$ md_toc -h\n" |
|
md_toc -h |
|
printf "\n" |
|
sleep 5 |
|
|
|
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 |
|
|
|
printf "Inspecting the file...\n" |
|
printf "$ cat foo.md\n" |
|
cat foo.md |
|
printf "\n" |
|
sleep 5 |
|
|
|
printf "Run with default options...\n" |
|
printf "$ md_toc foo.md github\n" |
|
md_toc foo.md github |
|
printf "\n" |
|
sleep 5 |
|
|
|
printf "Ordered list...\n" |
|
printf "$ md_toc foo.md gitlab -o\n" |
|
md_toc foo.md gitlab -o |
|
printf "\n" |
|
sleep 5 |
|
|
|
printf "No links...\n" |
|
printf "$ md_toc -l foo.md github\n" |
|
md_toc -l foo.md github |
|
printf "\n" |
|
sleep 5 |
|
|
|
printf "No links and no indentation...\n" |
|
printf "$ md_toc -l -i foo.md github\n" |
|
md_toc -l -i foo.md github |
|
printf "\n" |
|
sleep 5 |
|
|
|
printf "Use stdin and ...\n" |
|
printf "$ cat foo.md | md_toc -l -i cmark -u '*'\n" |
|
cat foo.md | md_toc -l -i cmark -u '*' |
|
printf "\n" |
|
sleep 5 |
|
|
|
printf "Editing the file in-place. As you can see, code fence \ |
|
detection still needs to be implemented for redcarpet..\n" |
|
printf "$ md_toc -p foo.md redcarpet\n" |
|
md_toc -p foo.md redcarpet |
|
printf "$ cat foo.md\n" |
|
cat foo.md |
|
|
|
rm foo.md
|
|
|