diff options
| author | Evan Silberman <[email protected]> | 2024-03-08 15:12:02 -0800 |
|---|---|---|
| committer | Evan Silberman <[email protected]> | 2024-09-02 11:08:13 -0700 |
| commit | d09477400fc6904de3e3c6c2e05834925536a9da (patch) | |
| tree | 66868556cf27e64d4cf8974e8dafe379eb1eec09 /data | |
| parent | 5e5ce1fae42ff89f50bd746466e1551aaee2f93e (diff) | |
Introduce ANSI writer for formatted console output
The ANSI writer (-t ansi) outputs a document formatted with ANSI control
sequences for reading on the console.
Most Pandoc elements are supported and printed in a reasonable way, if
not always ideally. This version does no detection of terminal
capabilities nor does it fall back to different output styles for
less-capable terminals.
Some gory details:
- Title blocks are formatted with modest extravagance in --standalone
mode.
- Strong, Emph, Underline, and Strikeout spans are all formatted
accordingly using SGR codes (which will be silently ignored by
terminals that don't support them).
- Headings have somewhat arbitrary styles applied to them that
probably need immediate improvement.
- Blockquotes and all flavors of list look pretty good.
- Code spans are colored magenta-on-white, which on the author's
terminal looks kind of like the pinkish treatment of code spans used
by many stylesheets. This probably isn't a good final decision.
- Code blocks are formatted by Skylighting's formatANSI using standard
writer options and included directly in the output. This has some
issues; see code comments.
- Links are printed with OSC 8 to create hyperlinks and colored cyan.
The author's terminal automatically adds a dotted-underline to OSC 8
hyperlinks, but only colors them differently on command-mouseover.
Setting an underlined style on links may be more broadly accessible.
OSC 8 support is not checked for, so on terminals not supporting it or
with support disabled, the link text will be colored but not do
anything and the links will not be printed.
- Images are displayed as their alt text. Support for the Kitty and
iTerm 2 inline image protocols is planned. Supporting other terminals
by using Chafa (https://hpjansson.org/chafa/) to print sixels etc would
be cool too but the author would have to do some FFI stuff and it would
add a dependency to Pandoc.
- Tables are replaced with a useless placeholder. Table output using
box-drawing characters is desired.
- Subscripts and Superscripts are just parenthesized when accurate Unicode
representations aren't available. Because these span types could have
all kinds of semantics, there's not an obvious thing to do with them.
- Simple math is translated to Pandoc inlines using existing
functionality. An ambitious person could look into emulating the
console-mode math output of a computer algebra system, or rendering each
display math element as an image with TeX or Typst and including it, or
some other thing.
Diffstat (limited to 'data')
| -rw-r--r-- | data/templates/default.ansi | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/data/templates/default.ansi b/data/templates/default.ansi new file mode 100644 index 000000000..9f6ca96de --- /dev/null +++ b/data/templates/default.ansi @@ -0,0 +1,21 @@ +$if(titleblock)$ +$titleblock$ + +$endif$ +$for(header-includes)$ +$header-includes$ + +$endfor$ +$for(include-before)$ +$include-before$ + +$endfor$ +$if(toc)$ +$table-of-contents$ + +$endif$ +$body$ +$for(include-after)$ + +$include-after$ +$endfor$ |
