Markdown visualizer for the terminal with interactive features
Project description
mdt
MarkDown in Terminal - Renders a markdown page in the terminal
Welcome to MarkDown in the Terminal!
Hi! I am your first Markdown file that you can open with mdt
.
If you want to learn about mdt
, you can clone this repository and open me from the terminal with
mdt show README.md
If you want to play with Markdown, you can edit me. Once you have finished with me, you can run me in your terminal.
Project
This project is a Markdown file reader for your terminal.
mdt
is built with Python, and uses the following libraries:
- Mistletoe to parse Markdown files.
- Python Prompt Toolkit for the interactive mode.
- Click to handle commmand line parameters.
- ansiwrap to perform the word wrapping.
Features
mdt
has the following features:
- Interactive mode with dynamic adaptation to the terminal width.
- You can choose your favourite among some available themes.
- You can edit a them of add your own custom theme. Themes are defined with a simple JSON "CSS-like" format.
- Intelligent word wrapping.
In interactive mode you can:
- Open web links in the default browser (requires a graphic sessions to work).
- Follow links to local files forward and backward, allowing a convenient exploration of "wiki-style" files.
Installation
Clone the repository.
If you have administration permissions, run:
pip install mdt-viewer
Commands
The following options are available:
$ mdt --help
Usage: mdt [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
gallery Shows a gallery with the available themes.
show Display the specified Markdown file.
themes Lists of available themes.
Command gallery
Shows a sample markdown file with the application of all the available themes for demonstration purposes.
Command show
Displays the specified markdown file with the default theme.
The theme can be selected by specifying the number among the ones available, or by using the --theme-file
option to specify a custom theme.
$ mdt show --help
Usage: mdt show [OPTIONS] MDFILE
Display the specified Markdown file.
Options:
-i Interactive mode.
--col INTEGER Set the text width in number of columns.
--rmargin INTEGER Set the right margin.
--theme INTEGER Use a default theme by ID.
--theme-file TEXT Use the specified theme file.
--help Show this message and exit.
Interactive mode
With the -i
option, mdt
is started in "interactive mode".
It then uses an internal pager which allows the scrolling of the text, and an intelligent word-wrapping.
Moreover, by pressing the Tab
key, the pager moves to the next link in the markdown file.
Pressing ENTER
on a link opens that link.
A link to a web page opens the browser.
A link to a file on the filesystem opens that file in mdt
.
The history of opened files can be navigated using left and right arrows.
Command themes
mdt
comes with some sample themes.
This command lists the available themes.
More themes will be added. Pull requests are welcome to provide new themes.
Themimg
The themes are specified in a file with JSON format.
Examples are available in the mdt/themes
directory.
The format is inspired by the one in the Glamour Go library, with some additional fields to provide more options.
An example of theme file is:
{
"document": {
"prefix": "",
"suffix": "",
"margin": 2
},
"block_quote": {
"prefix": "",
"suffix": "",
"color": "",
"background_color": "",
"bold": false,
"underline": false,
"blink": false
},
...
where the styling items should be pretty straightforward to understand.
The available items that can be themed are: document
block_quote
, paragraph
, heading
, h1
, h2
, h3
, h4
, h5
, h6
, strikethrough
, emph
, strong
, item
, list
, link
, selected_link
, inline_code
, block_code
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mdt-viewer-0.2.0.tar.gz
.
File metadata
- Download URL: mdt-viewer-0.2.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 917f78e01e61c0c8f9337ded9ba4ef3fa4666273bbbb9488c0dcb160f316d246 |
|
MD5 | fd91c1e7009b17666a6361b953c68ba6 |
|
BLAKE2b-256 | 0aac7462c56b6e99561c11cc3e0f51fe2c69fdfbe16e13bea9b8d0a05d67e02e |
File details
Details for the file mdt_viewer-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: mdt_viewer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 31.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1e9f5e1f136be6d88df0ea69f4c28d322bec5a924f483beb71beecf61d94765 |
|
MD5 | 821917274f5b117b7634833ba40a786d |
|
BLAKE2b-256 | f1491244eec922bc2b48cb12329225660c3947d57bf9d7b7bd50e97983745c1d |