ConsoleMD renders markdown to the console.
Due to the inexorable tides, ConsoleMD is now Python3 only. If things happen to work in Python2 then super great, but that is no longer a requirement.
It's highly recommended to install ConsoleMD inside a Python3 virtual environment.
# activate your python venv pip install consolemd # you probably want to make consolemd more accessible so... cd ~/bin ln -s ~/path/to/venv/bin/consolemd consolemd
If you'd like to hack on ConsoleMD and/or run some mediocre tests, then please do the following:
git clone https://github.com/kneufeld/consolemd.git cd consolemd # make a python3 virtual environment and activate it pip install -e .[test] python setup.py test # this will install some extra deps and run tests
You can treat
consolemd pretty much like you would
consolemd --help consolemd README.md cat README.md | consolemd
You can change the colors
consolemd uses via
-s or the environment
If your terminal doesn't support true color (16 million colors) then
--no-true-color or set environment variable
If you like really long lines that wrap at terminal edge then
--no-soft-wrap or set
To specify a max line width, then add
-w N to the command line or
MANWIDTH. Note that this feature
is pretty hacky and lines with internal formatting will likely end up
longer than the desired width.
A current at-time-of-writing list of pygment styles is the following:
abap algol algol_nu arduino autumn borland bw colorful default emacs friendly fruity igor lovelace manni monokai murphy native pastie perldoc rainbow_dash rrt sas stata tango trac vim vs xcode
native by default but
monokai is also very nice.
iTerm2 under OSX is great and nicely supports true color. Urxvt under Linux only pretends to be true color and doesn't do it very well.
If you have strange color issues then running with
should be the first thing you try. If that fixes your problem then
make sure to add
CONSOLEMD_TRUECOL=0 to your
See this gist for more info.
Italics, OSX, and you
For some reason Apple has disabled italics in the their
so you have to do a little patching to enable them. This is irrespective
of which terminal program you use but may depend on what
$TERM is set
Anyhow, based on this excellent post
tl;dr on enabling italics in OSX.
infocmp xterm-256color > /tmp/xterm-256color.terminfo printf '\tsitm=\\E[3m, ritm=\\E[23m,\n' >> /tmp/xterm-256color.terminfo tic /tmp/xterm-256color.terminfo
printf line above may not work quite right so edit
/tmp/xterm-256color.terminfo and manually append
to the end of the file.
Regardless, restart your terminal program of choice and italics should work. Test with:
echo `tput sitm`italics`tput ritm`
Why not just use pygments?
Because pygments highlights the markdown but doesn't strip out the control characters. Also, ConsoleMD uses CommonMark to parse the markdown instead of the lousy one in pygments (I'm allowed to say that since I'm the guy that wrote it).
Also, ConsoleMD uses some parts of pygments internally, and uses pygments to highlight code blocks.
Over the last few years there's been work on standardizing markdown with an official spec, that work happens at CommonMark.org.
The python implementation of the specification that I used is called CommonMark-py.
Github has recently (March 2017) converted all internal markdown to use a CommonMark parser, an interesting article can be found here.
Probably. There are lots of corner cases and it's not always clear what the proper output should even be. For instance, an executive decision was made to show url links as a list at the end of the document.
commonmark-py isn't very easy to use as a library so if
any node types got missed then chaos may ensue. Please open a bug (or even
better a pull request) so that
consolemd can get patched up.
Unicode is always fun: ȧƈƈḗƞŧḗḓ ŧḗẋŧ ƒǿř ŧḗşŧīƞɠ
If you help out in any way make sure you add your name to