CLI
cli()
CLI tool to remove and restore markdown links.
Source code in src/mdminify/cli.py
6 7 8 9 | |
remove(input_md_file, output_md_file, output_json_file)
Removes markdown links from the input file and saves the plain text (without links) to the output markdown file, while storing the extracted links in a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_md_file |
str
|
Path to the markdown file that contains links. |
required |
output_md_file |
str
|
Path where the processed markdown (without links) will be saved. |
required |
output_json_file |
str
|
Path where the extracted links (as JSON) will be stored. |
required |
Side Effects
- Creates or overwrites the output markdown file with the plain text (links removed).
- Creates or overwrites the JSON file with the extracted links.
Example
$ mdminify remove input.md output.md links.json
This will process input.md, save the plain text (without links) to output.md,
and store the extracted links in links.json.
Source code in src/mdminify/cli.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
restore(plain_md_file, json_file, output_md_file)
Restores markdown links in the plain markdown file using the stored links from the JSON file, and saves the result to a new markdown file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plain_md_file |
str
|
Path to the plain markdown file (without links). |
required |
json_file |
str
|
Path to the JSON file that contains the extracted links. |
required |
output_md_file |
str
|
Path where the markdown file with restored links will be saved. |
required |
Side Effects
- Creates or overwrites the output markdown file with the restored markdown (links reinserted).
Example
$ mdminify restore output.md links.json restored.md
This will restore links in output.md using links.json, and save the result to restored.md.
Source code in src/mdminify/cli.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |