From 542c51d25c05541d6ee35c862ec8f60ad01793cd Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Thu, 11 May 2023 22:22:44 +0100 Subject: Improve formatting of markdown manpage previews. --- doc/scd2gfm.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/tofi.1.md | 18 +++++++-------- doc/tofi.5.md | 71 ++++++++++++++++++++++------------------------------------ 3 files changed, 96 insertions(+), 53 deletions(-) create mode 100755 doc/scd2gfm.sh diff --git a/doc/scd2gfm.sh b/doc/scd2gfm.sh new file mode 100755 index 0000000..c966832 --- /dev/null +++ b/doc/scd2gfm.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Convert an scdoc file to GitHub markdown, with some custom tweaks to work +# around pandoc's poor formatting. +# +# Usage: +# ./scd2gfm < file.scd > file.md + +set -eu + +html=$(scd2html -f) +no_sections=$(echo "$html" | sed -e "s|\([^<]*\)|\1|g") +no_header=$(echo "$italics" | awk ' +/
/ { + header = 1 +} + +/<\/header>/ { + header = 0 +} + +!/header/ { + if (header == 0) { + print + } +} +') + +combine_blockquotes=$(echo "$no_header" | awk ' +/\/blockquote/ { + if (endblock > 0) { + print buffer + } + endblock = NR + buffer = $0 +} + +/

" + gsub("
", "") + buffer = "" + } else { + print buffer + print + buffer = "" + } +} + +!/blockquote/ { + if (endblock == NR - 2) { + print buffer + buffer = "" + } + print +} +') + +echo "$combine_blockquotes" | pandoc --from html --to gfm | sed "s/\s\+$//" diff --git a/doc/tofi.1.md b/doc/tofi.1.md index 79d6ce2..563feca 100644 --- a/doc/tofi.1.md +++ b/doc/tofi.1.md @@ -1,9 +1,9 @@ -# NAME +## NAME tofi - Tiny dynamic menu for Wayland, inspired by **rofi**(1) and **dmenu**(1). -# SYNOPSIS +## SYNOPSIS **tofi** \[options...\] @@ -11,7 +11,7 @@ tofi - Tiny dynamic menu for Wayland, inspired by **rofi**(1) and **tofi-drun** \[options...\] -# DESCRIPTION +## DESCRIPTION **tofi** is a tiny dynamic menu for Wayland compositors supporting the layer-shell protocol. It reads newline-separated items from stdin, and @@ -25,7 +25,7 @@ When invoked via the name **tofi-drun**, **tofi** will not accept items on stdin, and will generate a list of applications from desktop files as described in the Desktop Entry Specification. -# OPTIONS +## OPTIONS **-h, --help** @@ -38,7 +38,7 @@ described in the Desktop Entry Specification. All config file options described in **tofi**(5) are also accepted, in the form **--key=value**. -# KEYS +## KEYS \ \| \ \| \-k \| \-p \| \-k \| \-p \| \-h @@ -74,7 +74,7 @@ the form **--key=value**. > Quit without making a selection. -# FILES +## FILES */etc/xdg/tofi/config* @@ -102,10 +102,10 @@ the form **--key=value**. > Numeric count of commands selected in **tofi-drun**, to enable sorting > results by run count. -# AUTHORS +## AUTHORS -Philip Jones \ +Philip Jones \<\> -# SEE ALSO +## SEE ALSO **tofi**(5), **dmenu**(1) **rofi**(1) diff --git a/doc/tofi.5.md b/doc/tofi.5.md index 30ffb98..dfef45a 100644 --- a/doc/tofi.5.md +++ b/doc/tofi.5.md @@ -1,8 +1,8 @@ -# NAME +## NAME tofi - configuration file -# DESCRIPTION +## DESCRIPTION The config file format is basic .ini/.cfg style. Options are set one per line, with the syntax: @@ -14,13 +14,11 @@ given by enclosing them in double quotes like so: > option = " value " -Lines beginning with \# or ; are treated as comments. Section headers of -the form \[header\] are currently ignored. All options and values are case-insensitive, except where not possible (e.g. paths). Later options override earlier options, and command line options override config file options. -# SPECIAL OPTIONS +## SPECIAL OPTIONS **include**=*path* @@ -30,7 +28,7 @@ options. > Inclusion happens immediately, before the rest of the current file's > contents are parsed. -# BEHAVIOUR OPTIONS +## BEHAVIOUR OPTIONS **hide-cursor**=*true\|false* @@ -61,17 +59,10 @@ options. > > Defaults: > -> > > · -> > > -> > > tofi: None (no history file) -> > -> > > · -> > > -> > > tofi-run: *\$XDG_STATE_HOME/tofi-history* -> > -> > > · -> > > -> > > tofi-drun: *\$XDG_STATE_HOME/tofi-drun-history* +> +> > - tofi: None (no history file) +> > - tofi-run: *\$XDG_STATE_HOME/tofi-history* +> > - tofi-drun: *\$XDG_STATE_HOME/tofi-drun-history* **matching-algorithm**=*normal\|prefix\|fuzzy* @@ -173,7 +164,7 @@ options. > > Default: false -# STYLE OPTIONS +## STYLE OPTIONS **font**=*font* @@ -291,7 +282,8 @@ options. **placeholder-color**=*color* -> Color of placeholder input text. See **COLORS** for more information. +> Color of placeholder input text. See **COLORS** for more +> information. > > Default: \#FFFFFFA8 @@ -354,7 +346,8 @@ options. **text-cursor-background**=*color* -> Color of text behind the text cursor when **text-cursor-style**=block. +> Color of text behind the text cursor when +> **text-cursor-style**=block. > > Default: same as **background-color** @@ -466,8 +459,8 @@ options. **selection-background-padding**=*directional* -> Extra padding of the selected result background. See **DIRECTIONAL** -> VALUES for more information. +> Extra padding of the selected result background. See **DIRECTIONAL +> VALUES** for more information. > > Default: 0 @@ -495,7 +488,8 @@ options. **height**=*px\|%* -> Height of the window. See **PERCENTAGE VALUES** for more information. +> Height of the window. See **PERCENTAGE VALUES** for more +> information. > > Default: 720 @@ -620,12 +614,12 @@ options. > > Default: true -# COLORS +## COLORS Colors can be specified in the form *RGB*, *RGBA*, *RRGGBB* or *RRGGBBAA*, optionally prefixed with a hash (#). -# PERCENTAGE VALUES +## PERCENTAGE VALUES Some pixel values can optionally have a % suffix, like so: @@ -634,35 +628,24 @@ Some pixel values can optionally have a % suffix, like so: This will be interpreted as a percentage of the screen resolution in the relevant direction. -# DIRECTIONAL VALUES +## DIRECTIONAL VALUES The background box padding of a type of text can be specified by one to four comma separated values, with meanings similar to the CSS padding property: -> · -> -> One value sets all edges. - -> · -> -> Two values set (top & bottom), (left & right) edges. - -> · -> -> Three values set (top), (left & right), (bottom) edges. - -> · -> -> Four values set (top), (right), (bottom), (left) edges. +- One value sets all edges. +- Two values set (top & bottom), (left & right) edges. +- Three values set (top), (left & right), (bottom) edges. +- Four values set (top), (right), (bottom), (left) edges. Specifying -1 for any of the values will pad as far as possible in that direction. -# AUTHORS +## AUTHORS -Philip Jones \ +Philip Jones \<\> -# SEE ALSO +## SEE ALSO **tofi**(1), **dmenu**(1) **rofi**(1) -- cgit v1.2.3