From 3df975c913bdac017c8d139b0d99428c5ecacce5 Mon Sep 17 00:00:00 2001 From: ZeroOnePro Date: Sat, 11 Jun 2022 16:42:34 +0900 Subject: [PATCH 1/8] Fixed an issue in which the file path containing spaces could not be grepped --- gh-md-toc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gh-md-toc b/gh-md-toc index d74ecab..bba85f8 100755 --- a/gh-md-toc +++ b/gh-md-toc @@ -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 "" $gh_src && grep -Fxq "" $gh_src; then + if grep -Fxq "" "$gh_src" && grep -Fxq "" "$gh_src"; then echo "Found markers" else echo "You don't have or in your file...exiting" From a67210267419f462ec44b857d651de35f3eb0a7a Mon Sep 17 00:00:00 2001 From: ZeroOnePro Date: Sun, 12 Jun 2022 04:39:48 +0900 Subject: [PATCH 2/8] fix remove backup file path --- .vscode/configurationCache.log | 1 + .vscode/dryrun.log | 8 + .vscode/settings.json | 3 + .vscode/targets.log | 302 +++++++++++++++++++++++++++++++++ gh-md-toc | 4 +- 5 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 .vscode/configurationCache.log create mode 100644 .vscode/dryrun.log create mode 100644 .vscode/settings.json create mode 100644 .vscode/targets.log diff --git a/.vscode/configurationCache.log b/.vscode/configurationCache.log new file mode 100644 index 0000000..97aea8a --- /dev/null +++ b/.vscode/configurationCache.log @@ -0,0 +1 @@ +{"buildTargets":["lint","release","test"],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}} \ No newline at end of file diff --git a/.vscode/dryrun.log b/.vscode/dryrun.log new file mode 100644 index 0000000..051e81c --- /dev/null +++ b/.vscode/dryrun.log @@ -0,0 +1,8 @@ +make --dry-run --always-make --keep-going --print-directory +make: Entering directory `/Users/sungminyou/Workspace/personal/github-markdown-toc' +bats tests +shellcheck -e SC2008 gh-md-toc +git tag `grep -o -E '[0-9]\.[0-9]\.[0-9]{1,2}' gh-md-toc` +git push --tags origin master +make: Leaving directory `/Users/sungminyou/Workspace/personal/github-markdown-toc' + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7636242 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "makefile.extensionOutputFolder": "./.vscode" +} diff --git a/.vscode/targets.log b/.vscode/targets.log new file mode 100644 index 0000000..0c72a82 --- /dev/null +++ b/.vscode/targets.log @@ -0,0 +1,302 @@ +make all --print-data-base --no-builtin-variables --no-builtin-rules --question +# GNU Make 3.81 +# Copyright (C) 2006 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. +# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# This program built for i386-apple-darwin11.3.0 + +make: *** No rule to make target `all'. Stop. + + +# Make data base, printed on Sun Jun 12 04:39:28 2022 + +# Variables + +# environment + +VSCODE_GIT_ASKPASS_MAIN = /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js +# automatic +" $gh_src; then + if grep -Fxq "" "$gh_src"; then # cut everything before the toc gh_tmp_file_md=$gh_file_md~~ sed '1,//d' $gh_file_md > $gh_tmp_file_md @@ -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 From af977239a1c8f8924e40db0ac5991bac9bbc159d Mon Sep 17 00:00:00 2001 From: Sungmin You Date: Sun, 12 Jun 2022 04:41:48 +0900 Subject: [PATCH 3/8] Delete configurationCache.log --- .vscode/configurationCache.log | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .vscode/configurationCache.log diff --git a/.vscode/configurationCache.log b/.vscode/configurationCache.log deleted file mode 100644 index 97aea8a..0000000 --- a/.vscode/configurationCache.log +++ /dev/null @@ -1 +0,0 @@ -{"buildTargets":["lint","release","test"],"launchTargets":[],"customConfigurationProvider":{"workspaceBrowse":{"browsePath":[],"compilerArgs":[]},"fileIndex":[]}} \ No newline at end of file From ff8946ecf671f9703db754c2d0b46fe009420339 Mon Sep 17 00:00:00 2001 From: Sungmin You Date: Sun, 12 Jun 2022 04:42:04 +0900 Subject: [PATCH 4/8] Delete dryrun.log --- .vscode/dryrun.log | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .vscode/dryrun.log diff --git a/.vscode/dryrun.log b/.vscode/dryrun.log deleted file mode 100644 index 051e81c..0000000 --- a/.vscode/dryrun.log +++ /dev/null @@ -1,8 +0,0 @@ -make --dry-run --always-make --keep-going --print-directory -make: Entering directory `/Users/sungminyou/Workspace/personal/github-markdown-toc' -bats tests -shellcheck -e SC2008 gh-md-toc -git tag `grep -o -E '[0-9]\.[0-9]\.[0-9]{1,2}' gh-md-toc` -git push --tags origin master -make: Leaving directory `/Users/sungminyou/Workspace/personal/github-markdown-toc' - From 72e99ea77a660237877208600cba86618fb58a3a Mon Sep 17 00:00:00 2001 From: Sungmin You Date: Sun, 12 Jun 2022 04:42:16 +0900 Subject: [PATCH 5/8] Delete settings.json --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7636242..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "makefile.extensionOutputFolder": "./.vscode" -} From c6797727cc4a33fd6a480c1f455c8dea8aa025e9 Mon Sep 17 00:00:00 2001 From: Sungmin You Date: Sun, 12 Jun 2022 04:42:22 +0900 Subject: [PATCH 6/8] Delete targets.log --- .vscode/targets.log | 302 -------------------------------------------- 1 file changed, 302 deletions(-) delete mode 100644 .vscode/targets.log diff --git a/.vscode/targets.log b/.vscode/targets.log deleted file mode 100644 index 0c72a82..0000000 --- a/.vscode/targets.log +++ /dev/null @@ -1,302 +0,0 @@ -make all --print-data-base --no-builtin-variables --no-builtin-rules --question -# GNU Make 3.81 -# Copyright (C) 2006 Free Software Foundation, Inc. -# This is free software; see the source for copying conditions. -# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -# This program built for i386-apple-darwin11.3.0 - -make: *** No rule to make target `all'. Stop. - - -# Make data base, printed on Sun Jun 12 04:39:28 2022 - -# Variables - -# environment - -VSCODE_GIT_ASKPASS_MAIN = /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js -# automatic - Date: Sun, 17 Jul 2022 16:03:02 +0900 Subject: [PATCH 7/8] add test case for file path with space --- tests/test directory/test_filepathwithspace.md | 7 +++++++ tests/tests.bats | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/test directory/test_filepathwithspace.md diff --git a/tests/test directory/test_filepathwithspace.md b/tests/test directory/test_filepathwithspace.md new file mode 100644 index 0000000..b91dff2 --- /dev/null +++ b/tests/test directory/test_filepathwithspace.md @@ -0,0 +1,7 @@ +# Title + +Blabla... + +## This is test for file path with space + +Blabla... diff --git a/tests/tests.bats b/tests/tests.bats index 5431db5..b4d000c 100755 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -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 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)" +} \ No newline at end of file From 7cb965816076549a501c4af9a56dda5378670d25 Mon Sep 17 00:00:00 2001 From: ZeroOnePro Date: Sun, 17 Jul 2022 16:49:06 +0900 Subject: [PATCH 8/8] modify test script - add --insert flag --- tests/test directory/test_filepathwithspace.md | 10 ++++++++++ tests/tests.bats | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test directory/test_filepathwithspace.md b/tests/test directory/test_filepathwithspace.md index b91dff2..aea1249 100644 --- a/tests/test directory/test_filepathwithspace.md +++ b/tests/test directory/test_filepathwithspace.md @@ -1,5 +1,15 @@ # Title + + +- [Title](#title) + - [This is test for file path with space](#this-is-test-for-file-path-with-space) + + + + + + Blabla... ## This is test for file path with space diff --git a/tests/tests.bats b/tests/tests.bats index b4d000c..ee525b9 100755 --- a/tests/tests.bats +++ b/tests/tests.bats @@ -203,7 +203,7 @@ test_help() { } @test "Toc for file path with space, #136" { - run $BATS_TEST_DIRNAME/../gh-md-toc tests/test\ directory/test_filepathwithspace.md + run $BATS_TEST_DIRNAME/../gh-md-toc --insert tests/test\ directory/test_filepathwithspace.md assert_success assert_equal "${lines[2]}" "* [Title](#title)"