AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Md file viewer4/5/2023 ![]() ![]() sudo) with pip, which is also wrapped by the Makefile: make install # pip install. Recommended is a system install (by using e.g. If not already done so, you can get the package manager with something equivalent to sudo apt-get install python3-pip. The most easy way to (un-)install the mdcat package is via pip. “Fenced” (```-style) code blocks: As the built-in fenced_code extension would be rather strict and doesn’t seem to properly work for me anyway, these blocks are supported by a custom extension.Īlso, utilities that correspond to ansiwrap.wrap and lored are partly re-implemented to fix their behaviour or to suit the usecase at hand.HTML-style comments: Comments like that are embedded anywhere in markdown will be stripped.In addition, the following extensions for common but non-standard syntax are provided to the parser: (See the -html option to print the HTML for debugging purposes.) This means that the supported markdown syntax is basically given by this library. The resulting HTML DOM tree is then iterated on for printing terminal-friendly formatted strings. Mdcat uses the python markdown package as its only dependency for parsing the input files. unwrapped) lines can be scrolled instead of wrapped by the -S flag. When using less, color codes are supported by the -R flag. If you want to copy/paste code blocks, use a pager for horizontal scrolling, or prefer code to be unwrapped/untouched in general, the -no-wrap-pre option can be used. The -pager option bypasses this problem as the width can be determined before connecting the output to the pager’s pipe. If the width cannot be automatically determined, the -columns option or the $COLUMNS environment variable can be used to set one explicitly.Īs bash provides this shell variable ( not as environment variable), it can be exported or -columns=$COLUMNS can be used or even aliased. ![]() This is usually reliable but does not work when all output (both stdout and stderr) is redirected or for example piped to a pager such as less. The current terminal width gets determined by the corresponding TIOCGWINSZ ioctl(). TLDR: For convenience and a “manpage-like” experience, pass the -pager option, which will spawn the $PAGER environment variable or less -SR as discussed below. pager|-p don't write to stdout but spawn a pager instead, as given by $PAGER or 'less' by default (default: False) no-wrap-pre don't prefix and wrap code/quote blocks – useful if you want to copy/paste or are using a pager with horizontal scroll (default: False) html print parsed HTML output instead, mostly useful for debugging (default: False) columns|-c COLUMNS terminal width, autodetect from $COLUMNS or ioctl() if not given, fallback 80 – tip: export or set -columns=$COLUMNS to take the shell width when using a pager (default: None) h, -help show this help message and exit The supported Markdown syntax is given by: įile.md markdown file to print, '-' for stdin Parse a markdown file and pretty-print to the terminal, including colors, glyphs, and text wrapping. In general, simply invoke mdcat with the markdown file to process. Mdcat comes only as a single python script with very few dependencies, and used with or without a pager, it can already provide a “manpage-like feeling” when reading markdown files. This feature set should already cover most parts of most markdown files as found in documentation or wikis. Styled emphasis and hyperlinks, smart list and text wrapping, and glyphs for example for highlighting code blocks. ![]() This is all that mdcat needs to print markdown files in a pleasant way: The purpose is to provide a rich-text-like experience derived from a plaintext file – and there are several viewers, editors, and converters – but this falls short in a terminal environment, where for example README.md files are often encountered.Īlmost all recent terminal emulators should support features such as colors, underlines, or drawing glyphs. While new features were added, the basics are still largely the same until nowadays. Markdown console viewer python bash 1 file 540 locĭespite being created already in 2004, the markdown markup syntax is still widely used for plain-text-based documentation purposes of various kinds. ![]()
0 Comments
Read More
Leave a Reply. |