• Stars
    star
    787
  • Rank 56,517 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

mdless

mdless is a utility that provides a formatted and highlighted view of Markdown files in Terminal.

I often use iTerm2 in visor mode, so qlmanage -p is annoying. I still wanted a way to view Markdown files quickly and without cruft.

![mdless screenshot](screenshots/mdless.png)

Features

  • Built in pager functionality with pipe capability, less replacement for Markdown files
  • Format tables
  • Colorize Markdown syntax for most elements
  • Normalize spacing and link formatting
  • Display footnotes after each paragraph
  • Inline image display (local, optionally remote) if using iTerm2 2.9+
  • Syntax highlighting when Pygments is installed
    • Only fenced code with a language defined (e.g. python) will be highlighted
    • Languages can also be determined by hashbang in the code block
  • List headlines in document
    • Display single section of the document based on headlines
  • Customizable colors
  • Add iTerm marks for h1-3 navigation when pager is disabled

Installation

gem install mdless

Dependencies

Some OSs are missing tput, which is necessary for mdless.

apt update
apt install ruby ncurses-utils
gem install mdless

Usage

mdless [options] path or cat [path] | mdless

The pager used is determined by system configuration in this order of preference:

  • $GIT_PAGER
  • $PAGER
  • git config --get-all core.pager
  • bat
  • less
  • more
  • cat
  • pager

Options

-c, --[no-]color                 Colorize output (default on)
-d, --debug LEVEL                Level of debug messages to output
-h, --help                       Display this screen
-i, --images=TYPE                Include [local|remote (both)] images in output (requires imgcat and iTerm2, default NONE)
-I, --all-images                 Include local and remote images in output (requires imgcat and iTerm2)
    --links=FORMAT               Link style ([inline, reference], default inline) [NOT CURRENTLY IMPLEMENTED]
-l, --list                       List headers in document and exit
-p, --[no-]pager                 Formatted output to pager (default on)
-P                               Disable pager (same as --no-pager)
-s, --section=NUMBER             Output only a headline-based section of the input (numeric from --list)
-t, --theme=THEME_NAME           Specify an alternate color theme to load
-v, --version                    Display version number
-w, --width=COLUMNS              Column width to format for (default terminal width)

Customization

On first run a default theme file will be placed in ~/.config/mdless/mdless.theme. You can edit this file to modify the colors mdless uses when highlighting your files. You can copy this file and create multiple theme options which can be specified with the -t NAME option. For example, create ~/.config/mdless/brett.theme and then call mdless -t brett filename.md.

Colors are limited to basic ANSI codes, with support for bold, underline, italics (if available for the terminal/font), dark and bright, and foreground and background colors.

Customizeable settings are stored in YAML format. A chunk of the settings file looks like this:

h1:
  color: b intense_black on_white
  pad: d black on_white
  pad_char: "="

Font and color settings are set using a string of color names and modifiers. A typical string looks like b red on_white, which would give you a bold red font on a white background. In the YAML settings file there's no need for quotes, just put the string following the colon for the setting.

Some extra (non-color) settings are available for certain keys, e.g. pad_char to define the right padding character used on level 1 and 2 headlines. Note that you can change the Pygments theme used for syntax highlighting with the code_block.pygments_theme setting. For a list of available styles (assuming you have Pygments installed), use pygmentize -L styles.

Note: the ANSI escape codes are reset every time the color changes, so, for example, if you have a key that defines underlines for the url in a link, the underline will automatically be removed when it gets to a bracket. This also means that if you define a background color, you'll need to define it again on all the keys that it should affect.

Base colors:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Emphasis:

  • b (bold)
  • d (dark)
  • i (italic)
  • u (underline)
  • r (reverse, negative)

To modify the emphasis, use 'b' (bold), 'i' (italic), 'u' (underline), e.g. u yellow for underlined yellow. These can be combined, e.g. b u red.

Use 'r' to reverse foreground and background colors. r white on_black would display as black on_white. 'r' alone will reverse the current color set for a line.

To set a background color, use on_[color] with one of the 8 colors. This can be used with foreground colors in the same setting, e.g. white on_black.

Use 'd' (dark) to indicate the darker version of a foreground color. On macOS (and possibly other systems) you can use the brighter version of a color by prefixing with "intense", e.g. intense_red or on_intense_black.

More Repositories

1

doing

Ruby
1,036
star
2

Slogger

Social logging script for Day One
Ruby
762
star
3

KeyBindings

DefaultKeybindings.dict for Mac OS X
HTML
689
star
4

cheaters

Customizable cheat sheet system for OS X
HTML
461
star
5

popclipextensions

Brett's PopClip Extensions
Python
431
star
6

MarkedCustomStyles

Custom Style Repository for Marked2.app
CSS
416
star
7

QuickQuestion

A simple, text-based system for building an easily-searchable knowlegebase on OS X. CLI, LaunchBar and Alfred included.
Shell
188
star
8

Brett-s-TextExpander-Snippets

General-use snippets for TextExpander on Mac
PHP
129
star
9

fish_files

Shell
125
star
10

OTask

Ruby CLI for OmniFocus
Ruby
122
star
11

na

Bash function for displaying next actions in plain-text files per project directory
Shell
113
star
12

nvremind

A scheduled background task to scan nvALT notes for @reminder() tags and trigger notifications based on dates.
Ruby
98
star
13

bunch

Documentation repository for Bunch.app
Ruby
88
star
14

vitag

Ruby
86
star
15

hookapp

HTML
81
star
16

Pinboard-to-OpenMeta

Saves Pinboard bookmarks as local webloc files on a Mac. Can add thumbnails and save PDF's, with external apps. Works with Tags.app or the OpenMeta cli utility.
Ruby
79
star
17

gather-cli

Swift
73
star
18

JekyllPlugins

A small collection of (often lame) Jekyll plugins
SCSS
65
star
19

ubersicht-widgets

CoffeeScript
62
star
20

niftymenu

JavaScript
59
star
21

hook_goodies

AppleScript
59
star
22

snibbets

Ruby
46
star
23

where

Shell
38
star
24

BetterTouchTool-Widgets

Ruby
38
star
25

searchlink

Ruby
34
star
26

howzit_old

Ruby
32
star
27

ExtraInfoPlus

AppleScript
32
star
28

blogsmith-tmbundle

TextMate bundle for blogging platforms with poor/no xmlrpc support
Ruby
31
star
29

bookmark-cli

CLI for OS X that returns a base64 string of bookmark data for a file, or locates a file given a base64 string
Objective-C
31
star
30

popupsCSS

iOS-esque popup styles
28
star
31

jquery-tldr

JavaScript
26
star
32

dotfiles

Various config files
Shell
24
star
33

tagbak

Ruby
24
star
34

nvWikiLink

Universal system for creating plain text wiki links to nvALT notes
Ruby
22
star
35

sidecar

Sidecar jacket for Simplify
HTML
19
star
36

jtag

Ruby
19
star
37

coughbutton

An iPhone-based cough button for your Mac using PHP and MuteMyMic
JavaScript
18
star
38

delimport-pinboard

Index your Pinboard bookmarks using Spotlight on Mac OS X.
Objective-C
18
star
39

CodeReminder

Ruby
17
star
40

MarkdownURLs.safariextension

The source for the TabLinks Safari Extension
JavaScript
16
star
41

na_gem

a command line tool for adding and listing project todos
Ruby
16
star
42

mmd2cheatset

Ruby
16
star
43

howzit

Ruby
14
star
44

notehub

Ruby
14
star
45

reiki

Shell
13
star
46

Character-pair-autocompletion

Character pair autocomplete is now possible on any Mac app using these TextExpander custom snippets including on selected text.
13
star
47

ttscoff.github.com

Brett Terpstra's GitHub website
CSS
12
star
48

bunchcli

Ruby
12
star
49

Twilight2.tmTheme

A mod of the classic Twilight theme for TextMate and Sublime Text
11
star
50

starter-book

An online book.
11
star
51

Sublime-Bunch

Bunch is a Mac automation app that runs on plain text files with the extension `.bunch`. It has its own "language", and this package provides syntax highlighting for Bunch files, as well as light/dark color schemes, snippets for common commands, and completion for app names.
Python
10
star
52

podtagger

Automated ID3 tagging for podcasts
Ruby
9
star
53

VSCode-Bunch

9
star
54

TextBuddyScripts

JavaScript
9
star
55

TabLinks

HTML
8
star
56

loadbar

CoffeeScript
8
star
57

LuckyCharms-tmTheme

A light theme for Sublime Text, VS Code, and Vim
Vim Script
8
star
58

fuzzy_cd

Shell
6
star
59

MailMateMate.mmBundle

Ruby
6
star
60

quix-mann

Merlin Mann's Custom Quix Commands
6
star
61

bookmarklets

Repo to run bookmarklets from inline scripts on github.com
JavaScript
5
star
62

omf-fuzzy_cd

Shell
4
star
63

EditScript

Ruby
3
star
64

itunescontrol-tmbundle

iTunes Controller for TextMate, highly experimental
Ruby
2
star
65

Dictionary-tmbundle

Various dictionary, spellchecking and thesaurus commands for TextMate
2
star
66

omf-packages

1
star
67

Marked

Marked.app - MultiMarkdown Preview Everywhere
1
star
68

homebrew-thelab

Ruby
1
star
69

htmlexperiments

Just dicking around
1
star