Last modified: 2021-08-22 14:06

Using mdc

With no options set mdc creates HTML files for each of the files from the command line:

mdc *.md

Notice that the output files contain the markup source at the end of the file as HTML comment but .html are not accepted as arguments. With no filename mdc compiles the input from stdin.

Use the -m mode option to select another operation mode.

mode Function
compile Translate the given markup files.
edit Edit and compile the file's markup source.
source Print the HTML file's markup source.

edit and source work only on a single file.

Other UNIX commands

Here are some hints how to use other shell commands with mdc.

lynx

lynx is a well-known HTTP/HTML-browser for the UNIX console. Calling an editor to edit local files is supported; simply press E inside lynx. However, the editor needs to be configured. For mdc-generated HTML files you would set the options -editor='mdc -m edit'. When you invoke the editor mdc

When editing markup from within an HTML file mdc creates a ~ backup file of it.

You can create a wrapper shell script like

#!/bin/sh
#
# mde - Run lynx to read and edit .md files
#


if [ -f ~/.config/lynx/markdown.lss ]; then
    OPT="$OPT -lss=~/.config/lynx/markdown.lss"
fi

exec lynx -scrollbar -use_mouse \
	$OPT \
	-editor='mdc -m edit' "$@"

that sets the editor plus you preferred options.

w3m

w3m is another console browser and it allows to editing local files too. For integration with mdc you would put

editor mdc -m edit %s

into ~/.w3m/config or set that with the -o option on the command line. Think about a wrapper script like the one above. Furthermore, in w3m you must use SHIFT+E to edit the file.

vi

vim can automatically reformat text to make if fit on lines. This works if you have set the line width first:

set tw=72

(tw is an alias for textwidth). For manual reformatting you must select the lines (SHIFT+V) and give the command gw. You can set the option

set formatoptions+=a

and vim breaks the lines automatically as you type the text. To activate these settings automatically put

setlocal textwidth=72 
setlocal formatoptions+=a

into your ~/.vim/ftplugin/markdown.vim.