App-mdee
view release on metacpan or search on metacpan
script/mdee view on Meta::CPAN
[ rule | # table rule lines ]=_
[ width | w :=i # fold width ]=0
[ theme | t @ # color theme ]=
[ mode | m : # light or dark ]=
[ base-color | B : # base color ]=
[ config | %! # theme override ]=
[ adjust | % # color adjustment ]=
[ colormap|cm | :>pass_md # color map ]=
[heading-markup|hm : # markup in headings ]=
[ show | %! # field visibility ]=
[ pager | ?! # pager command ]=
[ pane | C :=i # number of columns ]=0
[ pane-width | S :=i # pane width ]=85
[ grid | G :>pass_nup # grid layout ]=
[ row | R :>pass_nup # number of rows ]=
[ page | P :>pass_nup # page height ]=
[ border-style | bs :>pass_nup # border style ]=
[ page-number | >pass_nup # page number ]=
[ cat-v | V # visualize whitespace ]=
)
##############################################################################
# Theme base colors
##############################################################################
declare -A theme_light=([base]='<RoyalBlue>=y25' [FILE]='L25D/L10E' [FILE_FORMAT]='\n %s\n\n')
declare -A theme_dark=([base]='<RoyalBlue>=y80' [FILE]='L00D/L15E' [FILE_FORMAT]='\n %s\n\n')
declare -a md_config=()
declare -a show_fields=(
bold strike italic code_inline
header h1 h2 h3 h4 h5 h6 horizontal_rule blockquote
)
# Patterns (name-pattern pairs)
# Highlighting and folding patterns are handled by App::Greple::md module.
declare -a patterns_default=()
# Build pattern associative array from patterns_default
# (built before theme loading so themes can modify patterns)
declare -A pattern
for ((_i=0; _i<${#patterns_default[@]}; _i+=2)); do
_name=${patterns_default[_i]}
[[ -v pattern[$_name] ]] && pattern[$_name]+='|'
pattern[$_name]+=${patterns_default[_i+1]}
done
# User config file path
config_file="${XDG_CONFIG_HOME:-$HOME/.config}/mdee/config.sh"
# Detect mode from terminal background luminance
# Returns "dark" if luminance < 50, "light" otherwise
# Returns empty string if luminance cannot be determined
detect_terminal_mode() {
local lum
lum=$(perl -MGetopt::EX::termcolor=luminance -e luminance 2>/dev/null) || return
[[ $lum ]] || return
(( lum < 50 )) && echo dark || echo light
}
##############################################################################
# Option callbacks
##############################################################################
help() {
sed -E \
-e '/^$/N' \
-e 's/^(\n*)=head[0-9]* */\1/' \
-e '/^\n*[#=]/d' \
-e '/Version/q' \
<<< "$pod"
exit 0
}
version() {
echo "$my_version"
exit 0
}
pager() {
[[ $pager ]] && pass_nup+=("--pager=$pager") || pass_nup+=("--no-pager")
}
filter() {
style=filter
}
plain() {
[[ $plain ]] && style=pager || style=nup
}
trace() {
[[ $trace ]] && set -x || set +x
}
_theme_specified=
theme() { _theme_specified=1; }
config() { _config+=("$2"); }
show() {
local arg=$2 key val
if [[ $arg == *=* ]]; then
key=${arg%%=*} val=${arg#*=}
else
key=$arg val=1
fi
if [[ $key == all ]]; then
for k in "${show_fields[@]}"; do
show[$k]=$val
done
fi
# Individual key=value is handled by getoptlong.sh
}
##############################################################################
# Parse options
##############################################################################
. getoptlong.sh OPTS "$@"
##############################################################################
( run in 1.243 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )