(.*?)<\/code><\/pre>/'"$style$indent"'\1'"$reset"'/;' \
-pe 's/
/\n'"$indent"'/g' <<< "$*"
# tput cuu 1
printf '%s' $'\e[A'
draw_line
}
list_parser() {
local tag text indent style list_style count
tag=$(get_tag "$*")
text=$(get_text "$*")
indent=$(indent_spaces)
list_style="$bullet_color$list_bullet$reset"
text=$(inline_parser "$text")
text=$(perl -pe 's///g;' \
-pe 's/
(.*?)<\/li>/'"$indent$list_style "'\1/g;' \
-pe 's/^
//;' \
-pe 's/
/\n'"$indent "'/g;' \
-pe 's/<(BR|\/p)>/\n/g' <<< "$text")
if [[ $tag = 'ol' ]]; then
count=1
text=$(while read -r; do
echo "${REPLY//$list_style/$count.}"
((count++))
done <<< "$text")
fi
echo "$text"
}
p_parser() {
local text
text=$(get_text "$*")
inline_parser "$text" | perl -pe 's/
//g;' -pe 's/
/\n/g;'
}
inline_parser() {
perl -pe 's/(.*?)<\/a>/'$link'\1'"$reset"'/g;' \
-pe 's/(.*?)<\/strong>/'$bold'\1'"$reset"'/g;' \
-pe 's/(.*?)<\/em>/'$italic'\1'"$reset"'/g;' \
-pe 's/(.*?)<\/code>/'$inline_code'\1'"$reset"'/g;' \
-pe 's/(.*?)<\/del>/'$strike'\1'"$reset"'/g;' \
-pe 's/(.*?)<\/u>/'$underline'\1'"$reset"'/g' <<< "$*"
}
draw_line() {
local line
printf -v line "%$(( $(tput cols) - (2 * $left_margin) ))s" ' '
printf "$line_color${line// /·}$reset\n"
}
contents_cleaner() {
local text
local tags='<\/(h[1-6]|p|ul|ol|blockquote|code><\/pre)>(?!<\/(blockquote|li)>)'
# Make text one single line...
text=$(perl -pe 's/\n/
/' <<< "$md_file")
# Fix pandoc blockquote and add line breaks after block tags...
text=$(perl -pe 's/(<\/p>)
(<\/blockquote>)/\1\2/g;' \
-pe 's/(
)
/\1\n/;' \
-pe 's/'$tags'/<\/\1>\n/g;' <<< "$text")
# Remove leading
s and fix pandoc headers...
text=$(perl -pe 's/^
//;' \
-pe 's/^(/\1>/' <<< "$text")
echo "$text"
}
contents_parser() {
local out
while read -r; do
case "${REPLY%%\>*}" in
\