Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ You can easily combine both ways:
* [Usage](https://github.com/ekalinin/sitemap.js/blob/master/README.md#usage)
* [License](https://github.com/ekalinin/sitemap.js/blob/master/README.md#license)

Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
```

Auto insert and update TOC
Expand Down Expand Up @@ -266,7 +266,7 @@ Table of Contents
!! TOC added into a separate file: 'README.test.md.toc.2018-02-04_192655'


Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
```

Now check the same file:
Expand Down
5 changes: 3 additions & 2 deletions gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ gh_toc(){
local dt=`date +'%F_%H%M%S'`
local ext=".orig.${dt}"
local toc_path="${gh_src}.toc.${dt}"
local toc_createdby="<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
local 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"
# create toc file
echo "${toc}" > "${toc_path}"
if [ "${no_footer}" != "yes" ]; then
echo -e "\n${toc_footer}\n" >> "$toc_path"
echo -e "\n${toc_createdby}\n${toc_footer}\n" >> "$toc_path"
fi

# insert toc file
Expand Down Expand Up @@ -351,7 +352,7 @@ gh_toc_app() {
done

echo ""
echo "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
echo "<!-- Created by https://github.com/ekalinin/github-markdown-toc -->"
}

#
Expand Down
6 changes: 3 additions & 3 deletions tests/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ load test_helper
assert_equal "${lines[16]}" "* [Docker](#docker)"
assert_equal "${lines[17]}" " * [Local](#local)"
assert_equal "${lines[18]}" " * [Public](#public)"
assert_equal "${lines[19]}" "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
assert_equal "${lines[19]}" "<!-- Created by https://github.com/ekalinin/github-markdown-toc) -->

}

Expand All @@ -40,7 +40,7 @@ load test_helper
assert_equal "${lines[3]}" " * [Installation](#installation)"
assert_equal "${lines[4]}" " * [Usage](#usage)"
assert_equal "${lines[5]}" " * [License](#license)"
assert_equal "${lines[6]}" "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
assert_equal "${lines[6]}" "<!-- Created by https://github.com/ekalinin/github-markdown-toc) -->
}

@test "TOC for mixed README.md (remote/local)" {
Expand Down Expand Up @@ -70,7 +70,7 @@ load test_helper
assert_equal "${lines[18]}" " * [Installation](https://github.com/ekalinin/sitemap.js/blob/6bc3eb12c898c1037a35a11b2eb24ababdeb3580/README.md#installation)"
assert_equal "${lines[19]}" " * [Usage](https://github.com/ekalinin/sitemap.js/blob/6bc3eb12c898c1037a35a11b2eb24ababdeb3580/README.md#usage)"
assert_equal "${lines[20]}" " * [License](https://github.com/ekalinin/sitemap.js/blob/6bc3eb12c898c1037a35a11b2eb24ababdeb3580/README.md#license)"
assert_equal "${lines[21]}" "Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)"
assert_equal "${lines[21]}" "<!-- Created by https://github.com/ekalinin/github-markdown-toc) -->
}

@test "TOC for markdown from stdin" {
Expand Down