Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ gh_toc(){
exit 1
fi
local toc
toc=`echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent"`
toc=$(echo "$rawhtml" | gh_toc_grab "$gh_src_copy" "$indent")
echo "$toc"
if [ "$need_replace" = "yes" ]; then
if grep -Fxq "<!--ts-->" "$gh_src" && grep -Fxq "<!--te-->" "$gh_src"; then
Expand All @@ -184,7 +184,7 @@ gh_toc(){
local toc_path="${gh_src}.toc.${dt}"
local toc_createdby="<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
local toc_footer
toc_footer="<!-- Added by: `whoami`, at: `date` -->"
toc_footer="<!-- Added by: $(whoami), at: $(date) -->"
# http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
# clear old TOC
sed -i"${ext}" "/${ts}/,/${te}/{//!d;}" "$gh_src"
Expand Down Expand Up @@ -243,9 +243,10 @@ gh_toc_grab() {
}
print sprintf("%*s", (level-1)*'"$2"', "") "* [" text "](" gh_url modified_href ")"
'
if [ "`uname -s`" == "OS/390" ]; then
if [ "$(uname -s)" == "OS/390" ]; then
grepcmd="pcregrep -o"
echoargs=""
# shellcheck disable=SC2016
awkscript='{
level = substr($0, 3, 1)
text = substr($0, match($0, /<\/span><\/a>[^<]*<\/h/)+11, RLENGTH-14)
Expand All @@ -255,6 +256,7 @@ gh_toc_grab() {
else
grepcmd="grep -Eo"
echoargs="-e"
# shellcheck disable=SC2016
awkscript='{
level = substr($0, 3, 1)
text = substr($0, match($0, /">.*<\/h/)+2, RLENGTH-5)
Expand Down Expand Up @@ -302,10 +304,10 @@ gh_toc_get_filename() {
show_version() {
echo "$gh_toc_version"
echo
echo "os: `uname -s`"
echo "arch: `uname -m`"
echo "kernel: `uname -r`"
echo "shell: `$SHELL --version`"
echo "os: $(uname -s)"
echo "arch: $(uname -m)"
echo "kernel: $(uname -r)"
echo "shell: $($SHELL --version)"
echo
for tool in curl wget grep awk sed; do
printf "%-5s: " $tool
Expand Down Expand Up @@ -368,7 +370,7 @@ gh_toc_app() {
mkdir -p "$TMPDIR"
fi
local gh_tmp_md
if [ "`uname -s`" == "OS/390" ]; then
if [ "$(uname -s)" == "OS/390" ]; then
local timestamp
timestamp=$(date +%m%d%Y%H%M%S)
gh_tmp_md="$TMPDIR/tmp.$timestamp"
Expand Down
Loading