INSTALLATION
$ pip3 install toc2md
HELP
$ toc2md -h
USAGE
$ toc2md [-h] [-H] [-V] [-v] [file]
Insert or update nested chapter numbering and linked Table Of Contents into a MarkDown file
If we type at terminal:
$ toc2md -v example.md
toc2md program:
- copies `example.md` into a timestamped backup file `example-YYYY.mm.dd-HH:MM:SS.md`
- writes (only if '-v' is present) on standard output something like:
file '/home/xxxx/example.md' has been backed up...
...into '/home/xxxx/example-2020.06.05-18.19.07.md'
- reads example.md
- checks correct heading sequence (see below)
- deletes old chapter numbering (if any) and old TOC (if any)
- inserts new nested chapter numbering and new linked TOC
- rewrites the updated version into example.md
- writes (only if '-v' is present) on standard output something like:
file '/home/xxxx/example.md' has been updated
There is neither configuration file nor options. Logic has been kept as simple
as possible, but the file to be processed must obey some rule, as follows.
toc2md processing is driven by headings in input file. A heading for us is a line
which starts with a '#' character. The heading level is the number of leading '#'
characters, between 1 and 6. So a heading is made by:
- a string of 1 to 6 '#' characters
- a blank
- a title
Title must start with an alphabetic character.
'#' characters after the sixth are silently discarded.
The blank after '#' characters if not present is silently inserted.
Any line not starting with '#' is processed as normal text, including MD headings as:
Something
===
or HTML headings like:
<h3>Something Else</h3>
which are anyway deprecated and must be avoided.
Titles in headings are:
- level 1 heading: title of the whole document
- first level 2 heading: title of the TOC
- following level 2 headings: titles of level 1 chapters (as 1. 2. ...)
- level 3 headings: titles of level 2 chapters (as 1.1. 1.2. ...)
- level 4 headings: titles of level 3 chapters (as 1.1.1. 1.1.2. ...)
- level 5 headings: titles of level 4 chapters (as 1.1.1.1. 1.1.1.2. ...)
- level 6 headings: titles of level 5 chapters (as 1.1.1.1.1. 1.1.1.1.2. ...)
So the input file must contain the following headings, freely intermixed with
normal text, but in this order:
- one level 1 heading with title of the whole document
- one level 2 heading with title of the TOC
- one level 2 heading with title of the first level 1 chapter (1.)
- zero or more level 2..6 headings with titles of level 1..5 chapters
Beware: no heading can ever have a level higher than that of the previous
heading plus one.
Each non-heading line in input is transcribed as it is into output, except for
those between the first and second level 2 headings. These lines are supposed to
be the old TOC and hence are deleted and replaced in output by the new TOC.
Chapter numbering in input headings is deleted and replaced in output by the new
chapter numbering.
For further details type at terminal:
$ toc2md -H
POSITIONAL ARGUMENTS
file markdown file to be backed up, read, processed and
rewritten
OPTIONAL ARGUMENTS
-h, --help show this help message and exit
-H, --user-guide open User Guide in PDF format and exit
-V, --version show program's version number and exit
-v, --verbose show what happens
Metadata
Release files for toc2md 0.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| toc2md-0.9.5.tar.gz | 603.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| toc2md-0.9.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.2 MB
Release files / toc2md-0.9.5.tar.gz
| Download URL | toc2md-0.9.5.tar.gz |
|---|---|
| Size | 603.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6a9978297e60cb3f2c0d3568e90c01b44f29dca038c786b769a843d6434c27c
|
|
BLAKE2b-256 checksum How to use checksums |
c3e84bd3283c91749e51df15726751d5089092e52a456b5457cab5c2fe5579f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.23.0
|
Release files / toc2md-0.9.5-py3-none-any.whl
| Download URL | toc2md-0.9.5-py3-none-any.whl |
|---|---|
| Size | 604.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a694f50c12b600b0d874ee167dbfe1aeecd6aba088e5415751a30ce6a2a59fe8
|
|
BLAKE2b-256 checksum How to use checksums |
db075c68dfda7ef1bbf130cdde26b811763a3fb647b8c8d97a7e9f046e34539f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.23.0
|
Security for toc2md 0.9.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.