blib/lib/App/mdee.pm

filter: Statementstmt 100% 2 / 2 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 2 / 2 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/App/Greple/md/widen.pm ↑ Summary
1 package App::mdee;
2  
3 # DO NOT EDIT this file manually.
4 # POD documentation is appended from script/mdee at release time.
5 # See minil.toml for details.
6  
7 1 our $VERSION = "1.29";
8  
9 1 1;
10 =encoding utf-8
11  
12 =head1 NAME
13  
14 mdee - em·dee, Markdown Easy on the Eyes
15  
16 =head1 SYNOPSIS
17  
18 mdee [ options ] file ...
19  
20 -h --help show help
21 --version show version
22 -d --debug debug level (repeatable)
23 -x --[no-]trace trace mode (set -x)
24 -n --dryrun dry-run mode
25 -s --style=# output style (nup/pager/cat/filter/raw)
26 -f --filter shortcut for --style=filter
27 -p --plain shortcut for --style=pager
28 --[no-]fold line folding (default: on)
29 --[no-]refill join paragraph lines (default: off)
30 -r reverse the default of --refill
31 --[no-]table table formatting (default: on)
32 --[no-]trim trim cell spaces (default: on)
33 --[no-]nup nup paged output (default: on)
34 -V --parallel show files side by side
35 -L --[no-]lateral all pages in one row, scrolled sideways
36 --[no-]rule use Unicode rules for tables (default: on)
37 --ts --table-style=# table style: lattice, 3line or simple (default: lattice)
38 --cat-v visualize whitespace via cat-v
39 --[no-]image[=#] image types to show (default: png,jpeg,gif)
40 -w --width=# output width (default: terminal width)
41 --fold-width=# fold width (default: pane width - 3 - run-in)
42 --runin=# run-in width for line breaking (default: 4)
43 --runout=# run-out width for line breaking (default: 4)
44 --runlen=# set both run-in and run-out
45 --boundary=# fold boundary: word, space or none (default: word)
46 -t --theme=#[,#,...] color theme(s) (default: hashed,nomark,markcell,doubleline)
47 -m --mode=# light or dark (default: light)
48 -B --base-color=# override base color of theme
49 (e.g., Ivory, #780043, (120,0,67))
50 --config=KEY=VALUE set config parameter (e.g., h1=RD, FILE=...)
51 --cm --colormap=L=SPEC override color for element (e.g., h1=RD)
52 --hm --heading-markup=# enable markup in headings (all/bold/...)
53 --show=# set field visibility (e.g., italic=1)
54 -C --pane=#[,#] number of columns, and rows
55 -R --row=# number of rows
56 -G --grid=# grid layout (e.g., 2x3)
57 -P --page=# page height in lines
58 -S --pane-width=# pane width (default: 85)
59 --bs --border-style=# border style
60 --[no-]page-number page number on border (default: on)
61 --[no-]filename file name label (default: on)
62 --[no-]pager[=#] pager command
63 -T --device=# output device: tty, pdf, or a paper for PDF
64 (e.g., a4, a4p, a3l)
65 -o --output=FILE output file (PDF when it ends with .pdf)
66  
67 =head1 VERSION
68  
69 Version 1.29
70  
71 =cut
72 =head1 DESCRIPTION
73  
74 B<em·dee> (command: C<mdee>) is a terminal-based multi-column
75 Markdown text viewer with syntax highlighting, particularly
76 useful for reading documents generated by LLMs.
77  
78 =begin html
79  
80 <p><img width="1000" src="https://raw.githubusercontent.com/tecolicom/App-mdee/main/images/3-column.png">
81  
82 =end html
83  
84 It presents Markdown content in a clean, readable form: syntax
85 highlighting distinguishes document structure, line folding wraps
86 long list items, and tables are aligned with proper column
87 formatting. By default, markup characters (C<**>, C<`>,
88 C<[>...C<]>, etc.) are hidden so that the text reads naturally,
89 while color and styling preserve the structural information.
90 Closing hashes are appended to h3-h6 headers to make heading
91 levels visually distinct. On terminals supporting OSC 8, links
92 remain clickable.
93  
94 Use C<--no-theme> to display the original Markdown source with
95 markup characters intact.
96  
97 The same view is printed to PDF with C<-o file.pdf>. See
98 L</Printing to PDF>.
99  
100 =head2 Concept
101  
102 B<em·dee> began as a viewer for Markdown I<text>, not as a Markdown
103 renderer. The idea was to show a C<.md> file as it is written, line
104 for line, only made easier on the eyes with color: the Markdown is
105 not interpreted or reformatted. Some formatting has been added since
106 because it made the text more readable: tables are aligned, long
107 list items are folded, the default themes hide markup characters,
108 and closing hashes are appended to lower-level headings. With
109 C<--refill>, the lines that a Markdown parser has found to be
110 one paragraph are joined as well. Everything else is still the
111 source text. This is why backslash escapes such as C<\*> are shown
112 as written, and why C<--no-theme> gives back the original file, in
113 color.
114  
115 For full Markdown rendering, many other viewers are available, such
116 as C<glow> and C<mdcat>. Combine them with L<nup(1)|App::nup> for
117 similar paged output (e.g., C<nup glow README.md>, C<nup mdcat README.md>).
118  
119 The pipeline combines L<greple(1)|App::Greple> for colorization and
120 L<nup(1)|App::nup> for multi-column paged output.
121  
122 The following elements are highlighted. Elements marked with
123 C<--show> can be individually disabled via the C<--show> option.
124 Others are always processed for structural integrity.
125  
126 --show bold (**bold**, __bold__)
127 --show italic (*italic*, _italic_)
128 --show strike (~~strike~~)
129 --show code_inline (`code`)
130 --show header, h1-h6 (# heading)
131 --show horizontal_rule (---, ***, ___)
132 --show blockquote (> quote)
133 always code_mark (``` or ~~~)
134 code_block
135 code_info
136 always meta_mark (--- or +++ at the top)
137 meta_block
138 always comment (<!-- ... -->)
139 always link ([text](url))
140 image (![text])
141 image_link (![text](url))
142  
143 Tables and list item folding are controlled by C<--table> and
144 C<--fold> options, not by C<--show>.
145  
146 The code in a fenced code block is shown in the colors of its
147 language (C<```perl>), when L<Text::ANSI::Highlight> and the command
148 of its highlighter, C<pandoc> by default, are installed.
149 C<--config highlight=gnu> uses C<source-highlight>, and
150 C<--config highlight=0> turns it off. See
151 L<App::Greple::md/"Syntax Highlight of Code">.
152  
153 =head2 Multi-column Layout and Pagination
154  
155 By default, B<mdee> calculates the number of display columns by
156 dividing the output width (the terminal width unless C<--width>
157 is given) by the pane width (default 85 characters). This determines how the output is laid out and
158 paginated.
159  
160 When two or more columns fit, L<nup(1)|App::nup> arranges output
161 in multi-column layout with page-by-page pagination — content is
162 split into terminal-height pages viewed through a pager.
163  
164 When only one column fits, B<mdee> still uses nup for formatting
165 (borders, document layout) but disables page-by-page splitting,
166 so the content scrolls continuously in the pager. This avoids
167 wasted space from page breaks on narrow terminals while
168 maintaining the same visual appearance.
169  
170 To force page-by-page pagination even in single-column layout,
171 specify C<--nup> explicitly. The C<--pane-width> (C<-S>) option
172 adjusts the column width used for this calculation, and
173 C<--pane> (C<-C>) sets the number of columns directly. The
174 C<--width> (C<-w>) option replaces the terminal width in this
175 calculation and limits the output to that width.
176  
177 With two or more files, C<--parallel> shows the files side by side,
178 one pane per file, instead of one after another. Each file is
179 folded to its pane width, and the panes scroll together in the
180 pager. The screen shows as many files as fit, as many as the pages
181 of a single file, and the files that do not fit in one row continue
182 on the next, or on the right with C<--lateral>; C<--pane> (C<-C>)
183 sets the number of panes.
184  
185 Use C<-p> (C<--style=pager>) for a simpler view without nup
186 formatting — highlighted output is piped directly through a
187 pager. Use C<-f> (C<--style=filter>) to write highlighted
188 output to stdout without a pager, suitable for piping into
189 other commands.
190  
191 =head2 Printing to PDF
192  
193 B<mdee> prints the document to PDF when the output file ends with
194 C<.pdf>, or when a paper is given as the device with C<-T>.
195  
196 mdee -o README.pdf README.md # A4 in landscape
197 mdee -T a4p -o README.pdf README.md # A4 in portrait
198 mdee -T a3 README.md > README.pdf # A3, to the standard output
199  
200 The paper takes the place of the terminal. The number of columns is
201 the width of the paper in characters divided by the pane width, and
202 the text is folded for it, in the same way as on the terminal: A4 in
203 landscape is 206 characters wide and has two panes, and A4 in
204 portrait is 100 characters wide and has one. C<-C> and C<-S> work
205 as on the terminal. The mode is C<light> unless C<--mode> is given,
206 because the paper is white.
207  
208 A paper is given by its name, with the letter C<p> or C<l> for
209 portrait or landscape, and the margin in millimeters after C<:m>.
210 The default is landscape with a margin of 5 mm.
211  
212 mdee -T a4p:m10 -o README.pdf README.md
213  
214 A sheet has 60 lines. The rows of C<-C> divide the sheet, and the
215 size of the characters is kept: C<-C2,2> gives four pages of 30
216 lines on a sheet. C<-P> sets the lines of a page instead, and the
217 characters become smaller or larger to put the pages on the sheet:
218 C<-C2,2 -P60> prints four pages of 60 lines on a sheet in half the
219 size, as a printer does for 4-up.
220  
221 mdee -C2,2 -o README.pdf README.md
222 mdee -C2,2 -P60 -o README.pdf README.md
223  
224 L<nup(1)|App::nup> and
225 L<ansi2pdf(1)|https://github.com/tecolicom/App-ansi2pdf> make the
226 PDF, so C<ansi2pdf> has to be installed, and the output style has to
227 be C<nup>, which is the default. See C<-T> and C<-o> in
228 L</Output Options>.
229  
230 =head1 INSTALLATION
231  
232 =head2 Homebrew
233  
234 Use L<tecolicom/tap|https://github.com/tecolicom/homebrew-tap>:
235  
236 brew tap tecolicom/tap
237 brew install app-mdee
238  
239 =head2 CPAN
240  
241 cpanm -n App::mdee
242  
243 =head1 OPTIONS
244  
245 =head2 General Options
246  
247 =over 4
248  
249 =item B<-h>, B<--help>
250  
251 Show help message.
252  
253 =item B<--version>
254  
255 Show version.
256  
257 =item B<-d>, B<--debug>
258  
259 Set debug level. Can be repeated for increasing verbosity.
260  
261 =over 4
262  
263 =item C<-d>
264  
265 Show theme values (C<theme_light[]>/C<theme_dark[]>, C<md_config[]>)
266 and pipeline stage names.
267  
268 =item C<-dd>
269  
270 Above, plus full command lines for each pipeline stage.
271  
272 =back
273  
274 =item B<-x>, B<--trace>, B<--no-trace>
275  
276 Enable or disable shell trace mode (C<set -x>). Useful for
277 debugging script execution. Can be toggled: C<-x --no-x> enables
278 then disables tracing.
279  
280 =item B<-n>, B<--dryrun>
281  
282 Dry-run mode. Print the commands that would be run, one pipeline
283 stage per line joined with C<|>, without running them. Arguments
284 are quoted so that the output can be pasted into a shell. The
285 environment that B<mdee> sets (C<LESS>, C<LESSANSIENDCHARS>) is not
286 shown. With C<-d>, the stage names are printed to stderr as well.
287  
288 =back
289  
290 =head2 Processing Options
291  
292 =over 4
293  
294 =item B<-s> I<STYLE>, B<--style>=I<STYLE>
295  
296 Set the output style. Default is C<nup>. Available styles:
297  
298 =over 4
299  
300 =item C<nup> - Full pipeline: fold + table + nup paged output (default)
301  
302 =item C<pager> - Fold + table, output to pager (C<$PAGER> or C<less>)
303  
304 =item C<cat> - Fold + table, output to stdout
305  
306 =item C<filter> - Table only (no fold, no nup), suitable for piping
307  
308 =item C<raw> - Highlight only (no fold, no table, no nup)
309  
310 =back
311  
312 The style sets the initial state of C<--fold>, C<--table>, and
313 C<--nup> options. Subsequent options can override individual
314 settings:
315  
316 mdee -s filter --fold file.md # filter + fold
317 mdee -p --no-fold file.md # pager without fold
318  
319 =item B<-f>, B<--filter>
320  
321 Shortcut for C<--style=filter>. Reads from stdin (or files) and
322 outputs highlighted Markdown to stdout. Disables line folding and
323 nup paged output, but keeps table formatting enabled. Useful for
324 piping Markdown content through mdee for syntax highlighting.
325  
326 =item B<-p>, B<--plain>
327  
328 Shortcut for C<--style=pager>. Enables fold and table formatting,
329 outputs through a pager (C<$PAGER> or C<less>) instead of nup.
330  
331 =item B<--[no-]fold>
332  
333 Enable or disable line folding for list items, definition lists,
334 block quotes and, with C<--refill>, paragraphs. When enabled, long
335 lines are wrapped with proper indentation using
336 L<ansifold(1)|App::ansifold>: the continuation lines of a list item
337 are indented under its text, those of a block quote start with the
338 quote marker again. Default is enabled.
339  
340 Supported list markers: C<*>, C<+>, C<->, C<1.>, C<1)>, C<#.>, C<#)>.
341 The C<#.> and C<#)> forms are the auto-numbered lists of Pandoc's
342 Markdown.
343  
344 =item B<--[no-]refill>
345  
346 Join the lines of each paragraph into one line. Default is disabled;
347 C<default[refill]=1> in the configuration file enables it.
348  
349 =item B<-r>
350  
351 Reverse the default of B<--refill>: enable it when the default is
352 disabled, and disable it when C<default[refill]=1> enables it, as for
353 a file which is not Markdown. Each B<-r> reverses it again, so
354 B<-rr> gives the default back. B<--[no-]refill> given on the command
355 line takes effect over it.
356  
357 What a paragraph is, a Markdown parser decides: a run of lines at the
358 top level, in a block quote, in a list item or in a definition body.
359 Those lines are joined in the original text. Headings, tables, code
360 blocks, front matter and everything else stay as written. A hard
361 line break (two or more spaces or a backslash at the end of a line)
362 is kept.
363  
364 Lines are joined with one space, or with nothing after a fullwidth
365 punctuation character and between two characters of a script that is
366 written without spaces, as L<ansifold(1)|App::ansifold> does. When
367 fold is enabled, the joined paragraphs are folded to the fold width
368 like list items; otherwise each is one long line.
369  
370 The parser is L<Markdown::Perl>, which is installed with B<mdee>, or
371 the L<CommonMark> module (an interface to libcmark) when it is there,
372 which is faster. C<--config refill_parser=pandoc> uses pandoc 2.11.3
373 or later instead.
374  
375 Front matter at the top of the file, TOML between C<+++> lines or
376 YAML between C<---> lines (or ended by C<...>), is left as it is
377 and shown as a code block; C<--config front_matter=0> takes its lines
378 as Markdown.
379  
380 =item B<--[no-]table>
381  
382 Enable or disable table formatting. When enabled, Markdown tables
383 are formatted using L<ansicolumn(1)|App::ansicolumn> for aligned column display.
384 Column alignment specified in the separator line (C<:---> for left,
385 C<:---:> for center, C<---:> for right) is respected.
386 A C<< <br> >> (or C<< <br/> >>, C<< <br /> >>) in a cell breaks the
387 cell into lines after it; one in a code span, or escaped as
388 C<< \<br> >>, does not. The default theme C<nomark> hides the
389 C<< <br> >>, and C<--no-theme> shows it.
390 Default is enabled.
391  
392 When folding is enabled, a table wider than the table width is fit
393 into that width. The table width is the fold width; with nup, when
394 the fold width is not given, it is the fold width plus the run-in
395 width but one (81 for a pane of 85), because the lines of a table are
396 sent to nup to be kept intact, not folded (see C<--intact> of
397 L<ansicolumn(1)|App::ansicolumn>); C<--cat-v> does not do it, and
398 the table width is the fold width there. Columns that fit keep
399 their width, and the cells of over-wide columns are wrapped. A cell
400 has no space at its right, so the text of the last column goes up to
401 the end of the width (see C<table_gap> in C<--table-style>). Use C<--config
402 table_width=0> to disable wrapping, or C<--config table_width=N> to
403 use a different width. Per-column
404 widths can be given with C<--config table_cell=SPEC>, where SPEC
405 is a colon-separated list passed to ansicolumn's C<--cell> option
406 (for example C<0:10> fixes the second column at 10 columns, and
407 C<< '<30' >> caps every column at 30). Marks can be put at the
408 start of cell lines, in place of the cell's leading space so that
409 column widths do not change. C<--config table_cell_mark=STRING>
410 marks the first line of every body cell in a column that has a
411 wrapped cell; the header row and columns that fit are left alone.
412 The default theme C<markcell> sets it to C<‣> (U+2023).
413 C<--config table_wrap_mark=STRING> marks the second and later
414 lines of a wrapped cell, so that they are not read as new rows;
415 the theme C<markwrap> sets it to C<›> (U+203A). Without these
416 themes no mark is used.
417  
418 =item B<--[no-]trim>
419  
420 Trim whitespace from table cell content before formatting.
421 This is useful when the source table is pre-formatted with
422 aligned spacing, which would otherwise prevent column alignment
423 directives from working correctly. Default is enabled.
424  
425 =item B<--[no-]nup>
426  
427 Enable or disable L<nup(1)|App::nup> for multi-column paged output.
428 When disabled, output goes directly to stdout without formatting.
429 Default is enabled. When explicitly specified, forces nup's
430 native pagination even in single-column layout (which normally
431 uses the pager instead).
432  
433 =item B<--[no-]rule>
434  
435 Enable or disable Unicode rule characters for table borders.
436 When enabled, ASCII pipe characters (C<|>) are replaced with
437 Unicode box-drawing characters (C<│>, C<├>, C<┤>, C<┼>) and
438 dashes (C<->) in separator lines are replaced with horizontal
439 rules (C<─>). Default is enabled.
440  
441 =item B<--table-style>=I<STYLE>, B<--ts> I<STYLE>
442  
443 Select how tables are drawn. C<lattice> (default) keeps a separator
444 between the columns, C<│> or C<|> depending on C<--rule>. C<pipe> is
445 another name of it, kept for compatibility:
446  
447 Left│ Center│ Right│ Default
448 ─────┼───────┼──────┼────────
449 a │ b │ c│ d
450  
451 C<3line> separates the columns by spaces only and draws three rules: a
452 rule the width of the table above and below it, and a rule per column
453 below the header.
454  
455 ─────────────────────────────
456 Left Center Right Default
457 ───── ─────── ────── ────────
458 a b c d
459 ─────────────────────────────
460  
461 C<simple> also separates the columns by spaces only, and draws the
462 rule per column below the header and below the table.
463  
464 Left Center Right Default
465 ───── ─────── ────── ────────
466 a b c d
467 ───── ─────── ────── ────────
468  
469 The rules are drawn with C<-> with C<--no-rule>.
470  
471 In every style a cell has a space at its left, where the marks of
472 C<--table-wrap-mark> and C<--table-cell-mark> are put, and no space at
473 its right. C<--config table_gap=N> sets the number of columns between
474 the text of a cell and that place of the next column (default 1): the
475 last of them is the column separator, and the others are spaces at the
476 right of the cell. With C<table_gap=2> a cell of C<lattice> has a
477 space on both sides; the spaces at the right end of the table are then
478 left out when the table does not fit the width with them.
479  
480 =item B<--cat-v>
481  
482 Pass the output through L<cat-v(1)|App::cat::v> to visualize
483 whitespace and special characters. Spaces are shown as C<·>
484 and other invisible characters are made visible. Newline
485 visualization is disabled by default.
486  
487 =item B<-->[B<no->]B<image>[=I<TYPES>]
488  
489 Show images in the terminal (default: on). I<TYPES> is a list of
490 the types of images to show, separated by commas: C<png>, C<jpeg> and
491 C<gif> (default: all of them). B<--image=png> shows PNG only, and
492 B<--no-image> none. They are shown only in the terminals that
493 support them; see L</IMAGES>.
494  
495 =item B<-w> I<N>, B<--width>=I<N>
496  
497 Set the output width in characters. Default is the terminal
498 width. With nup, this width is used in place of the terminal
499 width to calculate the number of columns, and it is passed to
500 L<ansicolumn(1)|App::ansicolumn> so that the panes fit into it:
501  
502 mdee -w 170 file.md # two 85-column panes on a wide terminal
503 mdee -V -w 170 a.md b.md # two files in 85 columns each
504  
505 Without nup (C<--style=cat>, C<pager>, C<filter>, or C<--no-nup>),
506 the text itself is the output, so this is the fold width.
507  
508 =item B<--fold-width>=I<N>
509  
510 Set the fold width for text wrapping directly. Default is the
511 pane width (output width divided by the number of columns) minus
512 3 for borders and padding and the run-in width (see C<--runin>),
513 which gives 78 when pane-width is 85.
514 Only effective when C<--fold> is enabled. Tables are fit into the
515 same width when it is given; otherwise, with nup, into this width
516 plus the run-in width but one (see C<--table>).
517  
518 =item B<--runin>=I<N>, B<--runout>=I<N>, B<--runlen>=I<N>
519  
520 Set the run-in and run-out widths that L<ansicolumn(1)|App::ansicolumn>
521 uses for line breaking (kinsoku) when nup folds the panes.
522 C<--runlen> sets both; options given later override earlier ones.
523 Default is 4. A run-in character may go past the fold width, so
524 ansicolumn keeps the run-in width free at the end of the pane, and
525 the default fold width is made narrower by the same amount. These
526 values are given to nup, and they take precedence over the values
527 in F<~/.ansicolumnrc>. The same values are given to the md module
528 as C<fold_runin> and C<fold_runout>, so that the lines it folds run
529 in by the width kept free, not more.
530  
531 =item B<--boundary>=C<word>|C<space>|C<none>
532  
533 Set where L<ansicolumn(1)|App::ansicolumn> may break a line when nup
534 folds the panes, as its C<--boundary> option: C<word> (default) does
535 not break inside an alphanumeric word, C<space> not inside a sequence
536 of non-space characters, and C<none> breaks anywhere. Lists, tables
537 and the paragraphs joined by C<--refill> are folded by the md module
538 at word boundaries, and this option keeps the other paragraphs, which
539 are folded by nup, in step with them. The value is given to nup,
540 which gives it to ansicolumn after F<~/.ansicolumnrc>, so it takes
541 precedence over the value there.
542  
543 =back
544  
545 =head2 Theme Options
546  
547 B<em·dee> supports color themes for customizing syntax highlighting.
548 Themes define colors for various Markdown elements (headers, code blocks,
549 bold text, etc.).
550  
551 =over 4
552  
553 =item B<-t> I<NAME>, B<--theme>=I<NAME>[,I<NAME>,...]
554  
555 Select color themes. The default is C<hashed,nomark,markcell,doubleline>,
556 which appends closing hashes to h3-h6 headers, hides markup
557 characters for a clean reading experience, marks the rows of
558 tables whose cells are wrapped, and gives h4 a double underline.
559  
560 Themes specified with C<--theme> are added to the default, not
561 replacing it (C<default[theme]> in the configuration file replaces
562 it). Multiple themes can be specified as comma-separated names or
563 by repeating the option. Each theme is applied in order as a
564 transformation, and when two themes set the same value the later
565 one wins:
566  
567 mdee --theme=warm file.md # the default themes + warm
568 mdee --no-theme --theme=warm # warm only (clear default first)
569 mdee --no-theme file.md # no theme (show all markup)
570  
571 Use C<--no-theme> to clear the default theme. It can be combined
572 with C<--theme> to start fresh.
573  
574 See L</THEMES> for the themes that come with B<mdee> and how to
575 write one.
576  
577 Use C<-d> to dump current theme values in sourceable format.
578  
579 =item B<-m> I<MODE>, B<--mode>=I<MODE>
580  
581 Select light or dark mode. Default is C<light>.
582  
583 If the terminal supports background color detection (via
584 L<Getopt::EX::termcolor>), the mode is automatically selected based on
585 terminal luminance.
586 When the environment variable C<TERM_LUMINANCE> is set (0 to 100, as
587 L<Getopt::EX::termcolor> uses it), its value is taken instead and the
588 terminal is not asked; below 50 is dark.
589  
590 Each theme has light and dark variants optimized for different terminal
591 backgrounds. The built-in C<default> theme uses RoyalBlue as the base
592 color with automatic luminance adjustment:
593  
594 =over 4
595  
596 =item C<light> - RoyalBlue with luminance 25 (dark text for light backgrounds)
597  
598 =item C<dark> - RoyalBlue with luminance 80 (bright text for dark backgrounds)
599  
600 =back
601  
602 =item B<-B> I<COLOR>, B<--base-color>=I<COLOR>
603  
604 Override the theme's base color. The base color determines the overall
605 color scheme because all heading colors (h1, h2, h3, etc.) are derived
606 from it by adjusting luminance. For example, h2 might be C<${base}+y20>
607 (base color with luminance increased by 20).
608  
609 B<Simple color name> - luminance is adjusted automatically:
610  
611 When you specify just a color name (without C<E<lt>E<gt>> brackets or
612 other syntax), the default luminance adjustment is applied based on
613 the current mode:
614  
615 -B RoyalBlue # becomes <RoyalBlue>=y25 in light mode
616 # becomes <RoyalBlue>=y80 in dark mode
617  
618 This makes it easy to try different colors without worrying about
619 luminance values. The default adjustments (C<=y25> for light, C<=y80>
620 for dark) are designed to provide good contrast against typical terminal
621 backgrounds.
622  
623 B<Full color specification> - used exactly as specified:
624  
625 If you include C<E<lt>E<gt>> brackets, luminance modifiers, or use RGB
626 notation, the value is used as-is without any automatic adjustment:
627  
628 -B '<Ivory>' # original color, no adjustment
629 -B '<Ivory>=y50' # explicit luminance 50
630 -B '#780043' # burgundy in hex
631 -B '(120,0,67)' # same color in RGB decimal
632  
633 B<Customizing the default adjustment>:
634  
635 The automatic luminance adjustment values can be customized with the
636 C<--adjust> option:
637  
638 --adjust light='=y30' # use =y30 instead of =y25 for light mode
639 --adjust dark='=y70' # use =y70 instead of =y80 for dark mode
640  
641 B<Note>: Basic ANSI color codes (C<R>, C<G>, C<B>, etc.) cannot be used
642 because heading variations require luminance adjustment, which only works
643 with full color specifications (X11 names, RGB hex, or RGB decimal).
644  
645 =item B<--config>=I<KEY>=I<VALUE>
646  
647 Set config parameters from the command line. Parameters are
648 passed to the L<App::Greple::md> module via
649 L<Getopt::EX::Config>. Theme keys recognized by mdee (C<base>,
650 C<FILE>, C<FILE_FORMAT>) are consumed locally and applied to both
651 light and dark themes; all other parameters are forwarded to the
652 md module.
653  
654 Color labels (C<h1>, C<bold>, C<italic>, etc.) are accepted as
655 config parameters and override default colors. The C<${base}>
656 placeholder can be used and will be expanded at runtime.
657  
658 mdee --config h1=RD # red h1
659 mdee --config bold=GD --config italic=YI # green bold, yellow italic
660 mdee --config h1='L25D/R;E' # custom h1 with background
661 mdee --config FILE='L25D/R;E' # red file label
662 mdee --config FILE_FORMAT=%s: # simple format
663 mdee --config hashed.h3=1 # enable h3 closing hashes
664 mdee --config cjk_friendly=1 # see LIMITATIONS, Emphasis
665  
666 Theme keys consumed by mdee:
667  
668 =over 4
669  
670 =item C<base> - Base color (equivalent to C<--base-color>)
671  
672 =item C<FILE> - Color spec for file label (default: C<L25D/${base};E> for light, C<L00D/${base};E> for dark). This is passed to greple's C<FILE> label and cannot be set via C<--cm>.
673  
674 =item C<FILE_FORMAT> - Format string for file label passed to greple's C<--format FILE=> (default: C<\n %s\n\n>). Cannot be set via C<--cm>.
675  
676 =back
677  
678 All other keys are passed to the md module as config parameters.
679 See L</Highlight Options> for the list of available color labels.
680 The md module also accepts operational parameters such as
681 C<table_trim>, C<table_width>, C<table_cell>, C<rule>, C<osc8>,
682 C<tick_open>, C<tick_close>, etc.
683  
684 =back
685  
686 =head2 Highlight Options
687  
688 =over 4
689  
690 =item B<--colormap>=I<LABEL>=I<SPEC>, B<--cm> I<LABEL>=I<SPEC>
691  
692 Override the color for a specific element. I<LABEL> is one of the
693 color labels listed below. I<SPEC> follows
694 L<Term::ANSIColor::Concise> format.
695  
696 --colormap h1=RD # red bold headings
697 --colormap code_block=/L20;E # dark background for code blocks
698 --colormap bold='${base}D' # base color bold
699  
700 This option is passed to the L<App::Greple::md> module, as a module
701 option before C<--> in the B<greple> command line (see it with C<-n>).
702 It is not the C<--cm> option of B<greple>, so C<FILE> and C<FILE_FORMAT>
703 are set by C<--config> instead.
704  
705 Available labels:
706  
707 h1 - h6 Heading levels 1 through 6
708 bold Bold (**text** or __text__)
709 italic Italic (*text* or _text_)
710 strike Strikethrough (~~text~~)
711 emphasis_mark Emphasis markers (**, *, __, _, ~~)
712 bold_mark Bold markers only (overrides emphasis_mark)
713 italic_mark Italic markers only (overrides emphasis_mark)
714 strike_mark Strike markers only (overrides emphasis_mark)
715 link Inline links [text](url)
716 image Images ![alt](url)
717 image_link Image links [![alt](img)](url)
718 link_mark Link/image brackets (overrides emphasis_mark)
719 br_mark <br> breaking a table cell (overrides emphasis_mark)
720 blockquote Blockquote marker (>)
721 horizontal_rule Horizontal rules (---, ***, ___)
722 comment HTML comments (<!-- ... -->)
723 code_mark Code block delimiters (``` and ~~~)
724 code_tick Inline code backtick markers
725 code_info Fenced code block info string
726 code_block Fenced code block body
727 code_inline Inline code body
728 meta_mark Front matter delimiter lines
729 meta_block Front matter body
730  
731 This option can be specified multiple times. Color labels can
732 also be set via C<--config>. When both are
733 specified, C<--cm> takes priority over C<--config>.
734  
735 =item B<--heading-markup>=I<STEPS>, B<--hm> I<STEPS>
736  
737 Control inline markup processing inside headings. By default,
738 headings are rendered with uniform heading color without processing
739 bold, italic, strikethrough, or inline code inside them. Links
740 are always processed as OSC 8 hyperlinks regardless of this option.
741  
742 Use C<all> or C<1> to enable all inline formatting within headings
743 using cumulative coloring. To select specific steps, list them
744 separated by colons.
745  
746 Available steps: C<inline_code>, C<horizontal_rules>, C<bold>,
747 C<italic>, C<strike>.
748  
749 mdee --hm all file.md # all markup
750 mdee --hm bold file.md # bold only
751 mdee --hm bold:italic file.md # bold and italic
752  
753 =item B<--show>=I<FIELD>[=I<VALUE>],...
754  
755 Control field visibility for highlighting. Empty value or C<0> disables
756 the field; any other value (including C<1>) enables it.
757  
758 --show italic # enable italic
759 --show bold=0 # disable bold
760 --show all # enable all fields
761 --show all= --show bold # disable all, then enable only bold
762  
763 Multiple fields can be specified with commas or by repeating the option.
764 The special field C<all> affects all fields and is processed first.
765  
766 See L</DESCRIPTION> for the list of available fields and
767 elements that are always active.
768 All controllable fields are enabled by default.
769  
770 =back
771  
772 =head2 Layout Options (passed to nup)
773  
774 =over 4
775  
776 =item B<-V>, B<--parallel>
777  
778 Show two or more files side by side, one pane per file, instead of
779 one after another. The screen shows as many files as fit, as many
780 as the pages of a single file, but not more than there are, and the
781 rest continue below; C<--pane> gives the number. Ignored with a
782 single file.
783  
784 With C<--lateral>, the rest go on to the right in one row instead,
785 and are scrolled sideways, a file at a time:
786  
787 mdee -LV *.md
788 mdee -LVC3 *.md
789  
790 =item B<-L>, B<--[no-]lateral>
791  
792 Put all the pages in one row, given to L<nup(1)|App::nup> as its
793 C<--lateral>. The screen shows as many pages as without it, and
794 space and C<b> of C<less> move by the screen as usual, while C<h> and
795 C<l> move by one page; see L<nup(1)|App::nup> for the keys and the
796 build of C<less> that keeps the pages at the edge of the screen. A
797 single pane goes to nup as well, so that the pages can be shifted one
798 by one. It cannot be used with C<--width>,
799 and nup refuses it with rows (C<-C2,2>, C<-R>, C<-G>) and PDF output.
800 With C<--parallel>, the files go on to the right in the same way,
801 each file a column scrolled up and down as usual; see C<--parallel>.
802 C<default[lateral]=1> in the configuration file makes it the default;
803 the default is left out where the option cannot be used, and
804 C<default[width]> is not used with it.
805  
806 =item B<-C> I<C>[,I<R>], B<--pane>=I<C>[,I<R>]
807  
808 Set the number of columns (panes). The number of rows may follow
809 after a comma: C<-C2,2> is 2 columns and 2 rows on a page, the same
810 as C<-C2 -R2>. When not specified (or 0),
811 the number of columns is calculated from the output width
812 (C<--width>, default terminal width) and C<--pane-width>. If only 1 column fits, nup formatting (borders
813 etc.) is preserved but pagination is handled by the pager instead.
814 Use C<--nup> to force nup's native pagination even in single column.
815  
816 =item B<-R> I<N>, B<--row>=I<N>
817  
818 Set the number of rows. C<-C> takes it as well, as C<-C2,2>.
819  
820 =item B<-G> I<CxR>, B<--grid>=I<CxR>
821  
822 Set grid layout. For example, C<-G2x3> creates 2 columns and 3 rows.
823 The text is folded for the number of columns of C<-C>, which this
824 option does not tell to mdee, so C<-C2,3> is better.
825  
826 =item B<-P> I<N>, B<--page>=I<N>
827  
828 Set the page height in lines.
829  
830 =item B<-S> I<N>, B<--pane-width>=I<N>
831  
832 Set the pane width in characters. Default is 85. This value is
833 used to calculate the number of columns from the output width,
834 and the default fold width. It has no effect when the number of
835 columns is given by C<--pane> or C<--parallel>.
836  
837 =item B<--bs>=I<STYLE>, B<--border-style>=I<STYLE>
838  
839 Set the border style.
840  
841 =item B<-->[B<no->]B<page-number>
842  
843 Show page number on the bottom border of each column. Enabled by
844 default. Use C<--no-page-number> to disable.
845  
846 =item B<-->[B<no->]B<filename>
847  
848 Show the file name label at the top of each file. Enabled by
849 default. Use C<--no-filename> to hide it, for example when files are
850 shown side by side with C<--parallel> and the panes should start with
851 the text. The label format and color are set by the C<FILE_FORMAT>
852 and C<FILE> theme keys (see C<--config>).
853  
854 =back
855  
856 =head2 Output Options
857  
858 =over 4
859  
860 =item B<--[no-]pager>[=I<COMMAND>]
861  
862 Set the pager command. Use C<--pager=less> to specify a pager,
863 or C<--no-pager> to disable paging.
864  
865 =item B<-T> I<DEVICE>, B<--device>=I<DEVICE>
866  
867 Set the device to show the output on, which is given to
868 L<nup(1)|App::nup>. The default is C<tty>, the terminal. Any other
869 device is a paper, and the output is printed to PDF by
870 L<ansi2pdf(1)|https://github.com/tecolicom/App-ansi2pdf>: C<a4> is A4
871 in landscape, C<a4p> is A4 in portrait and C<a3l> is A3 in landscape.
872 The device C<pdf> is the default paper, A4.
873  
874 mdee -T a4 README.md > README.pdf
875 mdee -T a4p -o README.pdf README.md
876  
877 The paper takes the place of the terminal, as described in
878 L</Printing to PDF>, and the pager is not used.
879  
880 This requires the nup style, and C<ansi2pdf>
881 0.1.3 or later for PDF (0.1.4 or later for the margin).
882  
883 =item B<-o> I<FILE>, B<--output>=I<FILE>
884  
885 Write the output to I<FILE>, which is given to L<nup(1)|App::nup>.
886 When the name ends with C<.pdf>, the output is PDF without C<-T> as
887 well. Otherwise, what is shown on the terminal is written to the
888 file as it is.
889  
890 mdee -o README.pdf README.md
891  
892 =back
893  
894 =head1 IMAGES
895  
896 B<mdee> shows images in the terminal, below the line that refers to
897 them. The line itself is kept, so the output with C<--no-image> is
898 the same text without the images. When the image is shown, the line
899 is markup only: it is shown as it is written, in C<code_info>, the
900 color of the info string of a code fence.
901  
902 =head2 Which Images
903  
904 An image is shown when its line contains nothing else. The line is
905 one of:
906  
907 =over 4
908  
909 =item * a Markdown image, C<![alt](file)>, or one in a link,
910 C<[![alt](file)](url)>;
911  
912 =item * an HTML C<< <img src="file"> >>, alone or inside C<< <p> >>,
913 C<< <div> >>, C<< <a> >> or C<< <center> >>. This is the form which
914 is written in C<=begin html> in POD and copied into README.
915  
916 =back
917  
918 Images inside a paragraph or a code block are not shown.
919  
920 =head2 Image Files
921  
922 The file is read from the local disk, by a path relative to the
923 Markdown file or an absolute path. Nothing is fetched from the
924 network, with one exception for GitHub URLs:
925  
926 https://raw.githubusercontent.com/OWNER/REPO/BRANCH/PATH
927 https://github.com/OWNER/REPO/blob/BRANCH/PATH
928  
929 These are read as the file I<PATH> in the git work tree of the Markdown
930 file, if one of its remotes is C<github.com/OWNER/REPO>. The branch is
931 ignored. The README files of CPAN distributions often refer to their
932 images this way.
933  
934 PNG, JPEG and GIF files are shown, those of the types given to
935 B<--image>. The type is detected from the content, not the file name. JPEG and GIF are converted to PNG with
936 C<sips> (macOS) or ImageMagick; without either, they are not shown.
937 A PNG much larger than the screen is reduced by the same tools, to
938 send less data; without them, it is sent as it is.
939 A file that is not found is not shown.
940  
941 =head2 Size
942  
943 An image is shown at its pixel size, reduced to fit within the fold
944 width and within the terminal height minus four lines. With nup, an
945 image is not split across panes: if it does not fit in the rest of a
946 pane, it starts in the next one (requires
947 L<ansicolumn(1)|App::ansicolumn> 1.71 or later).
948  
949 =head2 Conditions
950  
951 Images are shown only when all of the following are true:
952  
953 =over 4
954  
955 =item * The output goes to the terminal or to a pipe, not to a file:
956 no C<-o> or C<--cat-v> (see below for paper). Through a pipe, the image data is
957 still sent to the terminal, and the program at the other end shows
958 the rows, as C<mdee -f file.md | LESSUTFCHARDEF=10EEEE:p less -R>
959 does.
960  
961 =item * The terminal is iTerm2 3.7.3 or later (C<TERM_PROGRAM=iTerm.app>),
962 Ghostty (C<TERM_PROGRAM=ghostty>) or kitty (C<TERM=xterm-kitty>).
963  
964 =item * The pager is C<less> 632 or later, which supports
965 C<LESSUTFCHARDEF>.
966  
967 =back
968  
969 The terminal is identified from the environment. A terminal started
970 from another one (for example, by C<open -a> from iTerm2) may inherit
971 the wrong C<TERM_PROGRAM>. Use C<--no-image> in that case.
972  
973 On paper (C<-T>, or C<-o> with a PDF file), the images are drawn by
974 B<ansi2pdf> instead: the rows of an image tell it the file, and
975 nothing is sent to the terminal. PNG and JPEG are drawn; GIF is not.
976 This requires B<ansi2pdf> that knows the rows of an image; an older
977 one prints them as characters it has no glyph for.
978  
979 =head2 How It Works
980  
981 Images are drawn with the Unicode placeholders of the kitty graphics
982 protocol. Each row of an image is a line of special characters, so
983 it is laid out in columns and paged like text, but never folded. The image data is sent
984 directly to the terminal once.
985  
986 As the rows are text, a search in C<less> can match them, as with
987 C<.*>. The matched cells are drawn in the color of the search
988 highlight instead of the image; C<ESC-u>, which turns the highlight
989 off, shows the image again.
990  
991 =head1 THEMES
992  
993 A theme changes how the document looks: the colors, the marks that
994 are shown or hidden, and the decoration of headings and tables.
995 Themes are chosen with C<--theme> (see L</Theme Options>), and each
996 is applied in order as a transformation of the default.
997  
998 =head2 Built-in Themes
999  
1000 =over 4
1001  
1002 =item C<hashed> (default)
1003  
1004 Append closing hashes to h3-h6 headers.
1005  
1006 =item C<nomark> (default)
1007  
1008 Hide emphasis markers (C<**>, C<*>, C<__>, C<_>, C<~~>),
1009 inline code backticks, link brackets (C<[>, C<]>), and the
1010 C<< <br> >> that breaks a table cell into lines.
1011 Content text keeps its formatting (bold, italic,
1012 strikethrough, code, clickable links) but the surrounding
1013 markers are not displayed. Table marks (C<markcell>,
1014 C<markwrap>) are independent of this theme.
1015  
1016 =item C<doubleline> (default)
1017  
1018 Give h4 headers a double underline, which is C<ESC[4:2m>, in the
1019 terminals known to take it, decided by environment variables: iTerm2,
1020 Ghostty, cmux, VS Code, WezTerm, kitty, Alacritty, Konsole, Windows
1021 Terminal and terminals based on VTE 0.52 or later. Elsewhere, inside
1022 B<tmux> and B<screen>, and where the variables do not reach, as through
1023 B<ssh>, this theme does nothing and h4 has a single underline, the same
1024 as h5. Many terminals do not take the sequence: it becomes a background color in Terminal.app and
1025 rxvt-unicode, and the Linux console and mosh drop the whole sequence
1026 with its color.
1027  
1028 =item C<warm>
1029  
1030 Change base color to Coral.
1031  
1032 =item C<fatchap>
1033  
1034 Add decorative border lines (C<#>) above and below h1 headings,
1035 using C<=+> to append a text transformation while preserving the
1036 original heading color.
1037  
1038 With C<--refill>, the added lines are not counted, so paragraphs below
1039 the h1 headings may not be folded properly by this module. The text
1040 itself does not change. For this reason, this theme turns off
1041 C<default[refill]> in the configuration file; C<--refill> given on the
1042 command line still works.
1043  
1044 =item C<widen>
1045  
1046 Give circled digits and the wastebasket (U+1F5D1) a column of their
1047 own, by adding a no-break space after them, for terminals that draw
1048 them over two columns on top of the next character, as on macOS.
1049 This gives the function of L<App::Greple::md::widen> to the C<--begin>
1050 option of the md module.
1051  
1052 The characters are listed in the array C<widen_chars> of the theme, as
1053 code points and ranges in hexadecimal. Add more in F<config.sh>:
1054  
1055 widen_chars+=(3248-324F) # circled numbers on black squares
1056  
1057 =item C<markcell> (default)
1058  
1059 In a table that has wrapped cells, mark the first line of every
1060 body cell in the wrapped columns with C<‣> (U+2023), so that the
1061 rows read like a bulleted list and the continuation lines stand
1062 apart. The header row, columns that fit, and tables that fit are
1063 not marked. Sets C<table_cell_mark>; C<nomark> does not affect it.
1064 To use another character, set it in the configuration file or in a
1065 theme of your own:
1066  
1067 md_config+=(table_cell_mark=∙) # U+2219
1068  
1069 =item C<markwrap>
1070  
1071 Mark the second and later lines of a wrapped table cell with C<›>
1072 (U+203A). Sets C<table_wrap_mark>. It can be combined with
1073 C<markcell>.
1074  
1075 =back
1076  
1077 =head2 Theme Files
1078  
1079 Theme files are searched in the following order:
1080  
1081 =over 4
1082  
1083 =item 1. User theme directory: C<${XDG_CONFIG_HOME:-~/.config}/mdee/theme/NAME.sh>
1084  
1085 =item 2. Share theme directory: installed with the distribution under C<auto/share/dist/App-mdee/theme/>
1086  
1087 =back
1088  
1089 Theme files are Bash scripts that can modify C<theme_light[]>,
1090 C<theme_dark[]>, C<md_config[]>, and/or C<pass_md[]>:
1091  
1092 # theme/warm.sh — change base color
1093 theme_light[base]='<Coral>=y25'
1094 theme_dark[base]='<Coral>=y80'
1095  
1096 # theme/hashed.sh — enable closing hashes on h3-h6
1097 md_config+=(hashed.h3=1 hashed.h4=1 hashed.h5=1 hashed.h6=1)
1098  
1099 # theme/nomark.sh — hide markers and brackets
1100 pass_md+=(--cm 'emphasis_mark=sub{""}')
1101 pass_md+=(--cm 'code_tick=sub{""}')
1102 pass_md+=(--cm 'link_mark=sub{""}')
1103  
1104 =head1 CONFIGURATION
1105  
1106 User configuration is loaded from:
1107  
1108 ${XDG_CONFIG_HOME:-~/.config}/mdee/config.sh
1109  
1110 This is a shell script that can set defaults and override colors:
1111  
1112 # ~/.config/mdee/config.sh
1113 default[mode]=dark # set default mode
1114 default[theme]=warm # set default theme(s)
1115 default[style]=pager # set default style
1116 default[width]=170 # set default output width
1117 default[fold_width]=80 # set default fold width
1118 default[refill]=1 # join paragraph lines
1119 default[lateral]=1 # all pages in one row
1120 default[base_color]=DarkCyan # set default base color
1121  
1122 A value which has spaces or characters special to the shell, as C<< < >>,
1123 C<< > >>, C<;> or C<|>, is put in quotes: C<< theme_light[base]='<DarkCyan>=y25' >>.
1124  
1125 The C<default> associative array supports the following keys:
1126  
1127 =over 4
1128  
1129 =item C<default[mode]> - Corresponds to C<--mode> (e.g., C<dark>, C<light>)
1130  
1131 =item C<default[theme]> - Corresponds to C<--theme> (e.g., C<warm>, C<warm,hashed>)
1132  
1133 =item C<default[style]> - Corresponds to C<--style> (e.g., C<pager>, C<cat>)
1134  
1135 =item C<default[width]> - Corresponds to C<--width> (e.g., C<170>)
1136  
1137 =item C<default[fold_width]> - Corresponds to C<--fold-width> (e.g., C<80>)
1138  
1139 =item C<default[refill]> - Corresponds to C<--refill> (C<1> to enable)
1140  
1141 =item C<default[lateral]> - Corresponds to C<--lateral> (C<1> to enable)
1142  
1143 =item C<default[pane_width]> - Corresponds to C<--pane-width> (e.g., C<100>)
1144  
1145 =item C<default[pane]> - Corresponds to C<--pane> (e.g., C<2> or C<2,2>)
1146  
1147 =item C<default[base_color]> - Corresponds to C<--base-color> (e.g., C<DarkCyan>)
1148  
1149 =back
1150  
1151 C<default[refill]> and C<default[lateral]> are on with any value,
1152 C<1>, C<0> and C<no> alike, and off when empty.
1153  
1154 B<Overriding theme colors>
1155  
1156 Config.sh can modify theme variables directly, using the same
1157 mechanism as theme files:
1158  
1159 # Change base color for both modes
1160 theme_light[base]='<DarkCyan>=y25'
1161 theme_dark[base]='<DarkCyan>=y80'
1162  
1163 # Enable md module features
1164 md_config+=(hashed.h3=1 hashed.h4=1 hashed.h5=1 hashed.h6=1)
1165  
1166 # Use another character for the table cell mark
1167 md_config+=(table_cell_mark=∙)
1168  
1169 These settings take precedence over the default themes.
1170  
1171 Changing the base color automatically affects all derived colors
1172 (h1, h2, bold, etc.) because the md module expands C<${base}>
1173 references.
1174  
1175 Use C<-d> to dump current theme values in sourceable format.
1176  
1177 B<Color specification format>
1178  
1179 Color specifications use L<Term::ANSIColor::Concise> format.
1180 The C<FG/BG> notation specifies foreground and background colors
1181 (e.g., C<L25D/${base};E> means gray foreground on base-colored background).
1182 The C<${base}> string is expanded to the base color value after loading.
1183  
1184 To change the text before it is formatted, give a function to the
1185 C<--begin> option of the md module:
1186  
1187 pass_md+=(--begin 'sub{ s/\(C\)/\x{A9}/g }')
1188  
1189 =head1 EXAMPLES
1190  
1191 mdee README.md # view markdown file
1192 mdee -C2 document.md # 2-column view
1193 mdee -C2,2 manual.md # 2x2 grid (4-up)
1194 mdee -w170 file.md # two 85-column panes on a wide terminal
1195 mdee -V -w170 a.md b.md # two files in 85 columns each
1196 mdee --fold-width=60 a.md # narrower text within the pane
1197 mdee --no-pager file.md # without pager
1198 mdee --no-nup file.md # output to stdout without nup
1199 mdee --no-fold file.md # disable line folding
1200 mdee --no-table file.md # disable table formatting
1201 mdee -r file.md # join paragraph lines
1202  
1203 # PDF
1204 mdee -o file.pdf file.md # A4 in landscape
1205 mdee -T a4p -o file.pdf file.md # A4 in portrait
1206 mdee -T a4p -C1,2 -o file.pdf file.md # two pages on a sheet
1207  
1208 # Output styles
1209 mdee -s pager file.md # fold + table, output to pager
1210 mdee -s cat file.md # fold + table, output to stdout
1211 mdee -s filter file.md # table only, no fold/nup
1212 mdee -s raw file.md # highlight only
1213  
1214 # Style shortcuts
1215 mdee -p file.md # same as --style=pager
1216 cat file.md | mdee -f # highlight stdin (filter mode)
1217 mdee -f file.md # highlighted output to stdout
1218  
1219 # Override individual settings
1220 mdee -f --fold file.md # filter + fold
1221 mdee -p --no-fold file.md # pager without fold
1222  
1223 # Theme examples
1224 mdee --mode=dark file.md # use dark mode
1225 mdee --mode=light file.md # use light mode
1226 mdee -B Ivory file.md # override base color
1227 mdee --mode=dark -B '#780043' file.md # dark mode with burgundy
1228 mdee --theme=warm file.md # warm (Coral) base color
1229 mdee --no-theme file.md # show all markup characters
1230  
1231 =head1 DEPENDENCIES
1232  
1233 This command requires the following:
1234  
1235 =over 4
1236  
1237 =item * L<App::Greple> - pattern matching and highlighting
1238  
1239 =item * L<App::Greple::tee> - filter integration
1240  
1241 =item * L<App::ansifold> - ANSI-aware text folding
1242  
1243 =item * L<App::ansicolumn> - ANSI-aware column formatting
1244  
1245 =item * L<App::nup> - N-up multi-column paged output
1246  
1247 =item * L<App::ansiecho> - ANSI color output
1248  
1249 =item * L<Getopt::Long::Bash> - bash option parsing
1250  
1251 =item * L<Getopt::EX::termcolor> - terminal background detection
1252  
1253 =back
1254  
1255 The code in fenced code blocks is colored by
1256 L<Text::ANSI::Highlight>, with C<pandoc> 3.4 or later
1257 (C<brew install pandoc>), or with C<source-highlight> or
1258 C<skylighting>. Without the command, the code is shown as it is.
1259  
1260 C<--refill> finds the paragraphs with L<Markdown::Perl> (pure Perl,
1261 installed with this distribution). The L<CommonMark> module, which
1262 needs the libcmark C library (C<brew install cmark>, C<apt-get install
1263 libcmark-dev>) and is only recommended, is used when it is there
1264 because it is faster; L<pandoc|https://pandoc.org> 2.11.3 or later is
1265 a third choice.
1266  
1267 =head1 LIMITATIONS
1268  
1269 =head2 HTML Comments
1270  
1271 Only HTML comments starting at the beginning of a line are highlighted.
1272 Inline comments are not matched to avoid conflicts with inline code
1273 containing comment-like text (e.g., C<< `<!-->` >>).
1274  
1275 =head2 Emphasis
1276  
1277 Emphasis patterns (bold and italic) do not span multiple lines.
1278 Multi-line emphasis text is not supported.
1279  
1280 C<***bold italic***> and C<___bold italic___> are supported.
1281 Other nested forms (e.g., C<< **bold _italic_** >>) are not.
1282  
1283 C<*> and C<**> start and end emphasis as in CommonMark: a delimiter
1284 with a letter on one side and punctuation on the other does not
1285 count, so C<L*=50, a*=68> is not italic. CommonMark counts Unicode
1286 punctuation, and this rejects some emphasis in Japanese text,
1287 such as C<日本語の*「強調」*です> and C<日本語の**強調。**です>. mdee
1288 shows them as the commonmark and gfm readers of pandoc and zenn.dev
1289 do, with the markers and without emphasis, so that such text can be
1290 found before it is published.
1291  
1292 With C<cjk_friendly=1> (C<--config cjk_friendly=1>, or
1293 C<md_config+=(cjk_friendly=1)> in F<config.sh>), the rules of
1294 L<markdown-cjk-friendly|https://github.com/tats-u/markdown-cjk-friendly>
1295 are used instead: CJK punctuation does not count, and a CJK character
1296 on the other side is as good as a space, so these are emphasis. This
1297 is a proposal, not part of CommonMark; use it for text that is
1298 processed by an implementation of it.
1299  
1300 =head2 Block Quotes
1301  
1302 A block quote is recognized by its C<E<gt>> markers at the start of a
1303 line, after up to three spaces. Only the markers are colored, not the
1304 quoted text. Headings, lists and code blocks inside a quote are not
1305 recognized, so they get no color of their own, and a code block in a
1306 quote does not protect its contents from inline highlighting.
1307  
1308 A line without a marker that continues a quoted paragraph (a lazy
1309 continuation in CommonMark) is shown as an ordinary line, unless
1310 C<--refill> joins it to the quote.
1311  
1312 =head2 Links
1313  
1314 Link patterns do not span multiple lines. The link text and URL must
1315 be on the same line.
1316  
1317 Reference-style links (C<[text][ref]> with C<[ref]: url> elsewhere)
1318 are not supported.
1319  
1320 =head2 Paragraph Refill
1321  
1322 C<--refill> joins lines by the rules of Markdown, as the parser
1323 reads them. Lines of verse, addresses or lyrics that rely on the line
1324 breaks without a hard line break (two spaces or a backslash at the
1325 end of the line) are joined as well, and so are the lines of a
1326 display math block between C<$$> lines. Do not use C<--refill>
1327 for such documents.
1328  
1329 =head2 Table Alignment
1330  
1331 Column alignment assumes that cell content in the source is not
1332 pre-padded. If the source table is already formatted with aligned
1333 spacing (e.g., C<| c |>), the embedded spaces become part of
1334 the cell content and alignment directives in the separator line
1335 will not produce the expected result. This is by design: pre-formatted
1336 tables are assumed to be correctly aligned as-is.
1337  
1338 =head2 OSC 8 Hyperlinks
1339  
1340 Links are converted to OSC 8 terminal hyperlinks for clickable URLs:
1341  
1342 =over 4
1343  
1344 =item C<[text](url)> - C<[text]> links to url
1345  
1346 =item C<![alt](url)> - C<![alt]> links to url (image)
1347  
1348 =item C<[![alt](img)](url)> - C<!> links to img, C<[alt]> links to url
1349  
1350 =back
1351  
1352 This requires terminal support. Compatible terminals include iTerm2,
1353 Kitty, WezTerm, Ghostty, and recent versions of GNOME Terminal.
1354 Apple's default Terminal.app does not support OSC 8.
1355  
1356 When using C<less> as pager, version 566 or later is required with
1357 C<-R> option.
1358  
1359 For OSC 8 specification, see:
1360 L<https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>
1361  
1362 =head2 Terminal Luminance
1363  
1364 Without C<--mode> or C<default[mode]>, B<mdee> asks the terminal for
1365 its background color (OSC 11) through L<Getopt::EX::termcolor> to
1366 choose between light and dark mode. Set C<TERM_LUMINANCE> to a value
1367 from 0 to 100 to give the answer yourself and skip the query, for
1368 example in scripts or tests, where a reply that arrives late would
1369 show up as terminal input.
1370  
1371 =head2 Less Environment Variables
1372  
1373 When C<less> is used as pager (either directly via C<--style=pager> or
1374 through C<nup>), the following environment variables affect behavior.
1375 B<mdee> sets defaults for these when they are not already defined:
1376  
1377 =over 4
1378  
1379 =item C<LESS>
1380  
1381 Default: C<-R>. The C<-R> option is required for ANSI color
1382 sequences to be displayed correctly.
1383  
1384 B<mdee> always adds C<-X>, whether C<LESS> is defined or not. With
1385 it, C<less> does not use the alternate screen: the last page stays on
1386 the screen after C<less> ends, and images (see L</IMAGES>) are shown
1387 on the same screen that their data is sent to. To use the alternate
1388 screen, give C<-+X> in the pager command, such as
1389 C<NUP_PAGER="less -+X">.
1390  
1391 =item C<LESSUTFCHARDEF>
1392  
1393 When images are shown, B<mdee> adds C<10EEEE:p>, so that C<less>
1394 treats the placeholder character of the images as printable.
1395  
1396 =item C<LESSANSIENDCHARS>
1397  
1398 Default: C<mK>. This tells C<less> to recognize ANSI sequences
1399 ending with C<m> (SGR color) and C<K> (erase line). The erase line
1400 sequence is used for background color rendering.
1401  
1402 =back
1403  
1404 If you already have these variables set in your environment, B<mdee>
1405 does not override them.
1406  
1407 =head1 SEE ALSO
1408  
1409 =over 4
1410  
1411 =item L<Implementation of em·dee|https://github.com/tecolicom/App-mdee/blob/main/IMPLEMENTATION.md>
1412  
1413 How the pipeline, the themes and the colors work inside.
1414  
1415 =item L<App::Greple::md>
1416  
1417 Greple module for Markdown syntax highlighting, table formatting,
1418 and text folding. Bundled with this distribution.
1419  
1420 =item L<greple>
1421  
1422 General-purpose extensible grep tool used for pattern matching.
1423  
1424 =item L<nup>
1425  
1426 Multi-column paged output formatter.
1427  
1428 =item L<ansi2pdf|https://github.com/tecolicom/App-ansi2pdf>
1429  
1430 Renders the output to PDF.
1431  
1432 =item L<ansifold|https://metacpan.org/dist/App-ansifold/view/script/ansifold>
1433  
1434 ANSI-aware text folding for line wrapping.
1435  
1436 =item L<ansicolumn>
1437  
1438 ANSI-aware column formatting for table alignment.
1439  
1440 =item L<CommonMark>, L<Markdown::Perl>, L<pandoc|https://pandoc.org>
1441  
1442 One of them finds the paragraphs for C<--refill>.
1443  
1444 =item L<CommonMark Spec 0.31.2, Emphasis and strong emphasis|https://spec.commonmark.org/0.31.2/#emphasis-and-strong-emphasis>
1445  
1446 The rules that C<*> and C<**> follow by default (see L</Emphasis>).
1447  
1448 =item L<CommonMark CJK-friendly Amendments|https://github.com/tats-u/markdown-cjk-friendly/blob/main/specification.md>
1449  
1450 The rules that C<cjk_friendly=1> follows. The proposal comes from
1451 L<commonmark-spec issue #650, Emphasis with CJK punctuation|https://github.com/commonmark/commonmark-spec/issues/650>,
1452 open since 2020.
1453  
1454 =item L<Terminal graphics protocol, Unicode placeholders|https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders>
1455  
1456 The protocol by which images are shown (see L</IMAGES>).
1457  
1458 =item L<Text::ANSI::Image>
1459  
1460 Draws the images as lines of text by the protocol.
1461  
1462 =item L<https://github.com/tecolicom/App-mdee>
1463  
1464 Repository and bug tracker.
1465  
1466 =back
1467  
1468 =head1 AUTHOR
1469  
1470 Kazumasa Utashiro
1471  
1472 =head1 LICENSE
1473  
1474 Copyright © 2026 Kazumasa Utashiro.
1475  
1476 This software is released under the MIT License.
1477 L<https://opensource.org/licenses/MIT>
1478  
1479 =cut
« blib/lib/App/Greple/md/widen.pm ↑ Summary