Actions Status MetaCPAN Release

NAME

mdee - Markdown, Easy on the Eyes

SYNOPSIS

mdee [ options ] file ...

 -h  --help             show help
     --version          show version
 -d  --debug            debug level (repeatable)
 -n  --dryrun           dry-run mode
 -f  --filter           filter mode (highlight only)
     --[no-]fold        line folding (default: on)
     --[no-]table       table formatting (default: on)
     --[no-]nup         nup paged output (default: on)
 -w  --width=#          fold width (default: 80)
 -t  --theme=#          color theme
 -m  --mode=#           light or dark (default: light)
 -B  --base-color=#     override theme's base color
                        (e.g., <Red>, #FF5733, hsl(0,100,50))
     --list-themes      list built-in themes
     --show=#           set field visibility (e.g., italic=1)
 -C  --pane=#           number of columns
 -R  --row=#            number of rows
 -G  --grid=#           grid layout (e.g., 2x3)
 -P  --page=#           page height in lines
 -S  --pane-width=#     pane width (default: 85)
--bs --border-style=#   border style
     --[no-]pager[=#]   pager command

VERSION

Version 0.03

DESCRIPTION

mdee is a multi-column Markdown viewer with syntax highlighting, combining greple(1) for colorization and nup(1) for paged output.

Supported elements: headers (h1-h6), bold, italic, strikethrough, inline code, code blocks, HTML comments, tables, and list items.

This tool is designed for viewing Markdown not constrained by display formatting, such as output from LLMs (Large Language Models). It applies syntax highlighting with line folding and table alignment, but does not reflow paragraphs with hard line breaks. For full Markdown rendering, many other viewers are available. Combine them with nup(1) for similar paged output (e.g., nup glow README.md).

OPTIONS

General Options

Processing Options

Theme Options

mdee supports color themes for customizing syntax highlighting. Themes define colors for various Markdown elements (headers, code blocks, bold text, etc.).

Highlight Options

Layout Options (passed to nup)

Pager Options

EXAMPLES

mdee README.md              # view markdown file
mdee -C2 document.md        # 2-column view
mdee -G2x2 manual.md        # 2x2 grid (4-up)
mdee -w60 narrow.md         # narrower text width
mdee --no-pager file.md     # without pager
mdee --no-nup file.md       # output to stdout without nup
mdee --no-fold file.md      # disable line folding
mdee --no-table file.md     # disable table formatting

# Filter mode
cat file.md | mdee -f       # highlight stdin
mdee -f file.md             # highlight only (no paging)

# Theme examples
mdee --mode=dark file.md             # use dark mode
mdee --mode=light file.md            # use light mode
mdee -B '<Red>' file.md              # override base color
mdee --mode=dark -B '<Cyan>' file.md # dark mode with cyan base
mdee --list-themes                   # list available themes

DEPENDENCIES

This command requires the following:

IMPLEMENTATION

mdee is implemented as a Bash script that orchestrates multiple specialized tools into a unified pipeline. The architecture follows Unix philosophy: each tool does one thing well, and they communicate through standard streams.

The overall data flow is:

Input File
    |
    v
[greple] --- Syntax Highlighting
    |
    v
[ansifold] --- Text Folding (optional)
    |
    v
[ansicolumn] --- Table Formatting (optional)
    |
    v
[nup] --- Paged Output (optional)
    |
    v
Terminal/Pager

Pipeline Architecture

mdee dynamically constructs a pipeline based on enabled options. Each stage is represented as a Bash array containing the command and its arguments. The --dryrun option displays the constructed pipeline without execution.

Processing Stages

The pipeline consists of four configurable stages. Each stage can be enabled or disabled independently using --[no-]fold, --[no-]table, and --[no-]nup options.

Syntax Highlighting

The first stage uses greple(1) with the -G (grep mode) and --ci=G (capture index) options to apply different colors to each captured group in regular expressions.

Supported Markdown elements:

Code block detection follows the CommonMark specification:

Color Specifications

Colors are specified using Term::ANSIColor::Concise format. The --cm option maps colors to captured groups. For example, L00DE/${base} specifies gray foreground on base-colored background.

The color specification supports modifiers:

Example greple invocation:

greple -G --ci=G --all --need=0 \
    --cm 'L00DE/${base}' -E '^#\h+.*' \
    --cm '${base}D' -E '\*\*.*?\*\*' \
    file.md

Text Folding

The second stage wraps long lines in list items using ansifold(1) via Greple::tee. It preserves ANSI escape sequences and maintains proper indentation for nested lists.

The folding width is controlled by --width option (default: 80).

Table Formatting

The third stage formats Markdown tables using ansicolumn(1). Tables are detected by the pattern ^(\|.+\|\n){3,} and formatted with aligned columns while preserving ANSI colors.

Output Stage

The final stage uses nup(1) to provide multi-column paged output. Layout options (--pane, --row, --grid, --page) are passed directly to nup.

Theme System

mdee implements a theme system with light and dark mode variants.

Theme Structure

Each theme is defined as a Bash associative array with color definitions for each Markdown element:

declare -A theme_default_dark=(
    [base]='#CCCDFF'
    [h1]='L00DE/${base}'
    [h2]='L00DE/${base}-l10'
    ...
)

Base Color Expansion

The ${base} placeholder in color values is expanded after theme loading. This allows derived colors to be calculated from a single base color, making theme customization easier.

Terminal Mode Detection

mdee uses Getopt::EX::termcolor to detect terminal background luminance. If luminance is below 50%, dark mode is automatically selected.

LIMITATIONS

HTML Comments

Only HTML comments starting at the beginning of a line are highlighted. Inline comments are not matched to avoid conflicts with inline code containing comment-like text (e.g., `<!-->`).

Emphasis

Emphasis patterns (bold and italic) do not span multiple lines. Multi-line emphasis text is not supported.

Link patterns do not span multiple lines. The link text and URL must be on the same line.

Reference-style links ([text][ref] with [ref]: url elsewhere) are not supported.

Links are converted to OSC 8 terminal hyperlinks for clickable URLs. This requires terminal support. Compatible terminals include iTerm2, Kitty, WezTerm, Ghostty, and recent versions of GNOME Terminal. Apple's default Terminal.app does not support OSC 8.

When using less as pager, version 566 or later is required with -R option.

SEE ALSO

nup(1), greple(1), ansifold(1), ansicolumn(1)

AUTHOR

Kazumasa Utashiro

LICENSE

Copyright 2026 Kazumasa Utashiro.

This software is released under the MIT License. https://opensource.org/licenses/MIT