markdown tools
This commit is contained in:
32
reporting/md-color
Executable file
32
reporting/md-color
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
function helpexit() {
|
||||
echo "Colorify a markdown document"
|
||||
echo "Give filename(s) as the argument"
|
||||
echo " Depends on highbeam "
|
||||
exit
|
||||
}
|
||||
[[ -z "$1" ]] && helpexit
|
||||
[[ "$1" = "-h" ]] && helpexit
|
||||
|
||||
export HB_RULES='"^\s*\*.*" "$y" \
|
||||
"^[[:space:]]*[0-9]\+\..*" "$y" \
|
||||
"^#.*" "$W" \
|
||||
"^\s\s\s\s[^\*0-9].*" "$c" \
|
||||
"\`[^[[:space:]]]*[^\`]\+\`" "$c" \
|
||||
"\[[^]]\+\]([^)]\+)" "$B" \
|
||||
"\*[^[[:space:]]]*[^\*]\+\*" "$H" \
|
||||
"_[^[[:space:]]]*[^\_]\+_" "$H" \
|
||||
"<[^>]\+>" "$K" \
|
||||
'
|
||||
|
||||
# * bullets
|
||||
# 1. ordered list
|
||||
# ## Headers
|
||||
# code block
|
||||
# code inline
|
||||
# [links](URL)
|
||||
# *bold*
|
||||
# _bold_
|
||||
# <> tags
|
||||
cat "$@" | highbeam
|
||||
|
||||
19
reporting/md-toc
Executable file
19
reporting/md-toc
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
function helpexit() {
|
||||
echo "Print out TOC of a markdown document"
|
||||
echo "Give filename(s) as the argument"
|
||||
echo " -n to number TOC elements instead of bullet"
|
||||
exit
|
||||
}
|
||||
[[ -z "$1" ]] && helpexit
|
||||
[[ "$1" = "-h" ]] && helpexit
|
||||
[[ "$1" = "-n" ]] && {
|
||||
NUMBER=1
|
||||
shift
|
||||
}
|
||||
|
||||
[[ "$NUMBER" -eq 1 ]] && {
|
||||
grep ^# "$@" | sed -e 's,^#,1.,' -e ':loop' -e 's,1.#, 1.,' -e 't loop' | pandoc -t markdown_strict
|
||||
} || {
|
||||
grep ^# "$@" | sed -e 's,^#,*,' -e ':loop' -e 's,*#, *,' -e 't loop'
|
||||
}
|
||||
16
reporting/md-view
Executable file
16
reporting/md-view
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
function helpexit() {
|
||||
echo "View a markdown document"
|
||||
echo "Give filename(s) as the argument"
|
||||
echo " Depends on pandoc and lynx "
|
||||
exit
|
||||
}
|
||||
[[ -z "$1" ]] && helpexit
|
||||
[[ "$1" = "-h" ]] && helpexit
|
||||
|
||||
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/markdown$$.html
|
||||
trap "rm -f $tempfile" 0 1 2 5 15
|
||||
|
||||
|
||||
cat "$@" | pandoc -s > "$tempfile"
|
||||
lynx -force_html "$tempfile"
|
||||
Reference in New Issue
Block a user