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
6 changes: 3 additions & 3 deletions gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ gh_toc_md2html() {

local gh_tmp_file_md=$gh_file_md
if [ "$skip_header" = "yes" ]; then
if grep -Fxq "<!--te-->" $gh_src; then
if grep -Fxq "<!--te-->" "$gh_src"; then
# cut everything before the toc
gh_tmp_file_md=$gh_file_md~~
sed '1,/<!--te-->/d' $gh_file_md > $gh_tmp_file_md
Expand Down Expand Up @@ -168,7 +168,7 @@ gh_toc(){
local 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
if grep -Fxq "<!--ts-->" "$gh_src" && grep -Fxq "<!--te-->" "$gh_src"; then
echo "Found markers"
else
echo "You don't have <!--ts--> or <!--te--> in your file...exiting"
Expand Down Expand Up @@ -198,7 +198,7 @@ gh_toc(){
fi
echo
if [ "${no_backup}" = "yes" ]; then
rm ${toc_path} ${gh_src}${ext}
rm "$toc_path" "$gh_src$ext"
fi
echo "!! TOC was added into: '$gh_src'"
if [ -z "${no_backup}" ]; then
Expand Down
17 changes: 17 additions & 0 deletions tests/test directory/test_filepathwithspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Title

<!--ts-->

- [Title](#title)
- [This is test for file path with space](#this-is-test-for-file-path-with-space)

<!-- Created by https://github.com/ekalinin/github-markdown-toc -->
<!-- Added by: sungminyou, at: 2022년 7월 17일 일요일 16시 48분 18초 KST -->

<!--te-->

Blabla...

## This is test for file path with space

Blabla...
8 changes: 8 additions & 0 deletions tests/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,11 @@ test_help() {

assert_equal "${lines[2]}" "* [C vs C++](#c-vs-c)"
}

@test "Toc for file path with space, #136" {
run $BATS_TEST_DIRNAME/../gh-md-toc --insert tests/test\ directory/test_filepathwithspace.md
assert_success

assert_equal "${lines[2]}" "* [Title](#title)"
assert_equal "${lines[3]}" " * [This is test for file path with space](#this-is-test-for-file-path-with-space)"
}