Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from ekalinin:master #1

Open
wants to merge 157 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
c0ebe19
0.4.8
ekalinin Apr 21, 2017
969a8e5
Fix comments
May 18, 2017
baf5005
Merge pull request #33 from hzy001/master
ekalinin May 18, 2017
2b8c6a7
Use case builtin for pattern matching
aureliojargas Jun 9, 2017
6f9365d
Merge pull request #35 from aureliojargas/patch-1
ekalinin Jun 10, 2017
5addc43
remove extra white spaces
nevillelyh Aug 7, 2017
f8d1629
check for github token
nevillelyh Aug 7, 2017
8eee8f3
Merge pull request #36 from nevillelyh/master
ekalinin Aug 7, 2017
c17fb22
fixed #38. seems like new GH layout
ekalinin Oct 4, 2017
ff241d5
0.4.9
ekalinin Oct 4, 2017
5b74455
0.4.9
ekalinin Oct 4, 2017
d750c7e
Merge branch 'master' of github.com:ekalinin/github-markdown-toc
ekalinin Oct 4, 2017
0cb6123
Confirmed macOS Compatibility
Jan 31, 2018
f2c48b8
Merge pull request #43 from torch2424/osx-compatibility
ekalinin Feb 3, 2018
5c4bcbd
Auto TOC insert/update. Fix #41
ekalinin Feb 4, 2018
590e641
0.5.0
ekalinin Feb 4, 2018
41236dc
Fix sed syntax for Linux
chrisob Feb 28, 2018
1590bc1
Merge pull request #44 from chrisob/linux_fix
ekalinin Feb 28, 2018
90e3a94
Replace hard coded $app_name
phyrog Apr 27, 2018
27dbf14
fixed TOC insert on OSX, fixed #46
ekalinin May 16, 2018
54f4ba8
Fail explicitly if no network connectivity
zeitounator Sep 11, 2018
fa45ba5
Merge pull request #48 from zeitounator/fix/silentFailNoNetwork
ekalinin Sep 11, 2018
a96f29b
Store output to file
naneri Oct 3, 2018
066a3e3
Merge pull request #49 from naneri/patch-1
ekalinin Oct 4, 2018
06ac6fd
Merge pull request #45 from phyrog/master
ekalinin Oct 4, 2018
2b730a4
github api rate limited exceeded error is now reported and not silent…
stas00 Oct 9, 2018
b677e6e
Merge pull request #50 from stas00/master
ekalinin Oct 9, 2018
bbb3916
fix(README.md): installation instructions for OSX
majg0 Nov 2, 2018
aba04da
Merge pull request #53 from martingronlund/patch-1
ekalinin Nov 2, 2018
ca13c65
Correct BaseName Handling for Spaces in Path
Qualous Dec 19, 2018
9164aea
Tabs to spaces
Qualous Dec 19, 2018
3e881f9
--version shows version of all used tools
ekalinin Dec 29, 2018
09419c2
fixed new html layout. more readble awk code
ekalinin Dec 29, 2018
0d36e74
0.5.1
ekalinin Dec 29, 2018
c2479a7
add support for GH_TOC_TOKEN env variable
ekalinin Dec 29, 2018
c2301fa
global code replacement
ekalinin Dec 29, 2018
d2293b4
better --version handler (os, shell)
ekalinin Dec 29, 2018
dfba331
0.6.0
ekalinin Dec 29, 2018
0e25412
Update README.md
ekalinin Jan 15, 2019
3ffd9c2
Add installation instructions using Basher
Calinou Feb 7, 2019
05c1c4d
reverse the logic for handling GH_TOC_TOKEN to correct it
dhellmann Feb 20, 2019
be4fbab
Merge pull request #60 from dhellmann/fix-token-lookup-logic
ekalinin Feb 21, 2019
7b975d9
fix tests
ekalinin Feb 21, 2019
7f4a8cf
docs(readme): fix typo
myii Feb 22, 2019
4192e52
Merge pull request #61 from myii/patch-1
ekalinin Feb 25, 2019
3e96329
Fixed GitHub spelling
danspndl Mar 20, 2019
0ba828c
Fixed date
danspndl Mar 20, 2019
c9005b3
Merge pull request #65 from sdaniel55/fix-date
ekalinin Mar 20, 2019
acea0e6
add Dockerfile to run it from Docker
vemonet Mar 23, 2019
acc0f1f
add docker instructions to README.md
vemonet Mar 23, 2019
f25e277
slight change to docker part in readme
vemonet Mar 23, 2019
25a094c
Merge pull request #66 from vemonet/master
ekalinin Mar 23, 2019
852d427
Check if README.md has actual markers
jordantrizz May 8, 2019
d3b805a
Merge pull request #59 from Calinou/add-basher-installation
ekalinin May 14, 2019
6ca5217
Merge pull request #64 from sdaniel55/fix-github-spelling
ekalinin May 14, 2019
d0d8ab0
Merge pull request #72 from jordantrizz/check-markers
ekalinin May 14, 2019
7d9865f
Merge pull request #54 from Qualous/master
ekalinin May 14, 2019
f5c83ee
fix tests
ekalinin May 14, 2019
d6dd972
0.6.1
ekalinin May 14, 2019
83fadb6
set language in .travis.yml
ekalinin May 14, 2019
9229753
Pass auth in header not in uri
zeitounator Feb 14, 2020
9b0f537
Merge pull request #81 from zeitounator/fix/githubUriAuthDeprecation
ekalinin Feb 14, 2020
0089045
use Authorization header rather than query parameter
aglet Feb 19, 2020
56f7c59
bump version number in tests
aglet Feb 20, 2020
27b0f5a
Merge pull request #82 from robin-cruk/use-authorization-header
ekalinin Mar 2, 2020
c29d092
Added Create TOC without backup option --no-backup
jordantrizz Nov 25, 2019
b43bf68
Fix spaces
ekalinin Apr 28, 2020
76c9a6c
Merge pull request #70 from jordantrizz/nobackup
ekalinin Apr 28, 2020
110da86
Update gh-md-toc
erikengervall May 13, 2020
d24cfd8
Remove git blames
erikengervall May 13, 2020
a461dca
Merge pull request #89 from erikengervall/patch-3
ekalinin May 14, 2020
9df69f5
Merge pull request #88 from erikengervall/patch-1
ekalinin May 14, 2020
488f310
Update README.md
ekalinin May 24, 2020
f3e7b25
Allow gh-md-toc to run on z/OS Unix System Services and remove non-EB…
djfitzgerald Sep 30, 2020
d8a8c9b
Not my place to bump gh_toc_version
djfitzgerald Sep 30, 2020
c7b498c
IMPROVE COMMENT
ManishGuptaKuumar Oct 15, 2020
332de12
adding brew directions
moutons Nov 11, 2020
5e8eb72
Merge pull request #103 from moutons/moutons/document-brew-install
ekalinin Nov 11, 2020
3dcedc4
fixed token pass. Fixes #90
ekalinin Nov 15, 2020
a80ce50
Merge pull request #99 from djfitzgerald/master
ekalinin Nov 15, 2020
20d3cff
handle emojis. Fixes #102
ekalinin Nov 15, 2020
5193818
Fixed tests
ekalinin Nov 15, 2020
1ae5bf0
Add dockerimage.yml. Fixes #97
ekalinin Nov 15, 2020
5683af7
Merge branch 'master' of github.com:ekalinin/github-markdown-toc
ekalinin Nov 15, 2020
9236c57
0.7.0
ekalinin Nov 15, 2020
56fe53e
Fixed tests
ekalinin Nov 15, 2020
1c4f87c
Update README
ekalinin Nov 15, 2020
66c1a9c
Update README
ekalinin Nov 15, 2020
2e3c450
Fixed tests
ekalinin Nov 15, 2020
495dfb3
Fix for issue#100 ("+"s in titles)
shlomif Oct 24, 2020
6a7c738
Merge pull request #104 from shlomif/shlomif-issue100-better-fix--squ…
ekalinin Nov 18, 2020
33a84f4
Update issue templates
ekalinin Nov 18, 2020
1eecefd
Update issue templates
ekalinin Nov 23, 2020
327408f
Remove brew installation. Fixes #105
ekalinin Nov 23, 2020
d7e0761
README: add "TOC with Github Actions". Fixes #93
ekalinin Nov 24, 2020
1716618
Merge pull request #101 from ManishGuptaKuumar/master
ekalinin Dec 20, 2020
6feec24
Secure variable with quotes and curly braces
zeitounator Jan 30, 2021
d883e0b
Merge pull request #108 from zeitounator/fix/unary_operator_bug
ekalinin Feb 1, 2021
8c08a70
Remove duplicated backslash escape stopping utf8 chars decodding
zeitounator Feb 1, 2021
109a90d
Merge pull request #109 from zeitounator/fix/utf8-toc-generation-bug
ekalinin Feb 2, 2021
993239a
Add --hide-footer flag
damemi Mar 5, 2021
f623275
Merge pull request #112 from damemi/hide-footer
ekalinin Apr 5, 2021
d8db8d1
Fix the indentation of the generated TOC
Barthelemy Apr 23, 2021
efe9874
Customizable indentation size
Barthelemy Apr 23, 2021
8a1285e
Merge pull request #116 from Barthelemy/fix-indentation
ekalinin Apr 25, 2021
fc925aa
remove debug flag
Barthelemy Apr 26, 2021
1c4394a
docs: define TOC
Jul 6, 2021
d06b4b1
docs: redundant TOC
Jul 6, 2021
e111a73
Merge pull request #122 from thiswillbeyourgithub/master
ekalinin Jul 7, 2021
2e36a87
Merge pull request #123 from thiswillbeyourgithub/master
ekalinin Jul 8, 2021
c1b9134
fixed tests. #116
ekalinin Sep 5, 2021
17ec017
0.8.0
ekalinin Sep 5, 2021
8daa73c
Skip headers if end marker is present
Dec 27, 2021
d815f39
Add option --skip-header
Dec 27, 2021
22079e3
Add a test for --skip-header
Dec 27, 2021
edce94e
changed 'created by' to be an html comment
Captn138 Mar 11, 2022
31d8a3b
fix the tests
Captn138 Mar 11, 2022
e3b0c48
Action with far less footprint
jofas Mar 21, 2022
7b2c81e
portable sed commands
tedivm Mar 22, 2022
cd07e56
Merge pull request #130 from tedivm/patch-1
ekalinin Mar 22, 2022
de4180a
Add ci GH action
ekalinin Mar 26, 2022
ddc22f1
README: fix link
ekalinin Mar 26, 2022
f8d919e
Merge pull request #127 from Captn138/master
ekalinin Mar 26, 2022
239f540
Merge pull request #118 from Barthelemy/variable-indent
ekalinin Mar 26, 2022
192f5f3
Fix tests after #127
ekalinin Mar 26, 2022
d66f9ce
Bugfix & tests after #118
ekalinin Mar 26, 2022
ffd5cbc
README: it's better to use release version in GH action
ekalinin Mar 26, 2022
877f061
Merge pull request #129 from jofas/enhanced_github_action_documentation
ekalinin Mar 26, 2022
5659f2a
Del travis; Add gh & release badges into README
ekalinin Mar 26, 2022
9242567
Merge branch 'master' into issue-125-skip-headers
ekalinin Mar 26, 2022
1ee0be8
Fix spaces in help
ekalinin Mar 27, 2022
69e880a
Fixed "skip headers" test
ekalinin Mar 27, 2022
352d7ae
Merge pull request #126 from firebirdberlin/issue-125-skip-headers
ekalinin Mar 27, 2022
5d0d6e5
Better --help output: separate doc for each option;
ekalinin Mar 27, 2022
8f91bd0
Better --version output: cross OS output; move --help/version into se…
ekalinin Mar 27, 2022
a261661
fix assert_equal output in tests
ekalinin Mar 27, 2022
5e477fd
Fix indent argument parsing
qq88976321 May 2, 2022
73877e3
Fixed typo in the help command
jeanfi May 19, 2022
55f5c6d
fixed tests
jeanfi May 19, 2022
6bcc6f7
Merge pull request #132 from qq88976321/fix-indent-argument-parsing
ekalinin Jul 16, 2022
4357682
Merge pull request #133 from jeanfi/fix/typo
ekalinin Jul 16, 2022
3571fe6
Fix broken link
jv-k Dec 25, 2022
129b822
Merge pull request #140 from jv-k/patch-1
ekalinin Dec 25, 2022
661b5c5
Fixed an issue in which the file path containing spaces could not be …
ZeroOnePro Dec 25, 2022
c836e5e
Fix parsing of HTML returned from raw API (#144)
jkburges Sep 25, 2023
656b340
Repairing setext heading support, certain uses of backticks after Git…
coreysciuto-toast Oct 1, 2023
b9e7e61
0.9.0
ekalinin Oct 10, 2023
2918a7b
fix new GH output
ekalinin Nov 18, 2023
9618358
commented out some tests (with remote logic)
ekalinin Nov 18, 2023
1f20452
0.9.1
ekalinin Nov 18, 2023
31e0758
fix version test
ekalinin Nov 18, 2023
b985c02
run tests twice a week
ekalinin Nov 18, 2023
7d0a86b
Update for a new GH HTML layout
ekalinin Mar 3, 2024
84b4bbe
Makefile: fix regexp for release number
ekalinin Mar 3, 2024
91ba462
ci: setup GH_TOC_TOKEN env
ekalinin Mar 9, 2024
0ccf70d
fixed some warnings from shellcheck tool
ekalinin Mar 9, 2024
1c6184d
Don't leak GH token in token.txt (#155)
jofas Aug 4, 2024
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
Prev Previous commit
Next Next commit
Repairing setext heading support, certain uses of backticks after Git…
…Hub API format changes (ekalinin#145)

* Fix parsing of HTML returned from raw API

Github must have changed something on their end, the HTML seems to have changed a little.

* Adding some tests for setext header support

* Fixing the formatter

* Putting all the tests in the same directory

* Closer, but span tag doesn't work in some cases

* Fixed span issue

* Broke test formatting

* fixing local tests - remote is busted, formatting seems very different.

---------

Co-authored-by: Jon Burgess <[email protected]>
  • Loading branch information
coreysciuto-toast and jkburges committed Oct 1, 2023
commit 656b34011a482544a9ebb4116332c044834bdbbf
19 changes: 14 additions & 5 deletions gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ gh_toc(){
# $2 - number of spaces used to indent.
#
gh_toc_grab() {

href_regex="/href=\"[^\"]+?\"/"
lefttext_regex="/(<a class=\"heading-link\".*?>)(.*)(<span aria-hidden)/"
righttext_regex="/>.*/"

common_awk_script='
modified_href = ""
split(href, chars, "")
Expand All @@ -242,21 +247,22 @@ gh_toc_grab() {
echoargs=""
awkscript='{
level = substr($0, 3, 1)
text = substr($0, match($0, />[^<]*<span aria-hidden/)+1, RLENGTH-18)
href = substr($0, match($0, "href=\"([^\"]+)?\"")+6, RLENGTH-7)
lefttext = substr($0, match($0, '$lefttext_regex')+1, RLENGTH-18)
text = substr(lefttext, match(lefttext, '$righttext_regex')+1)
href = substr($0, match($0, '$href_regex')+6, RLENGTH-7)
'"$common_awk_script"'
}'
else
grepcmd="grep -Eo"
echoargs="-e"
awkscript='{
level = substr($0, 3, 1)
text = substr($0, match($0, />[^<]*<span aria-hidden/)+1, RLENGTH-18)
href = substr($0, match($0, "href=\"[^\"]+?\"")+6, RLENGTH-7)
lefttext = substr($0, match($0, '$lefttext_regex')+1, RLENGTH-18)
text = substr(lefttext, match(lefttext, '$righttext_regex')+1)
href = substr($0, match($0, '$href_regex')+6, RLENGTH-7)
'"$common_awk_script"'
}'
fi
href_regex='href=\"[^\"]+?\"'

# if closed <h[1-6]> is on the new line, then move it on the prev line
# for example:
Expand All @@ -265,6 +271,9 @@ gh_toc_grab() {
# became: The command <code>foo1</code></h1>
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<\/h/<\/h/g' |

# Sometimes a line can start with <span>. Fix that.
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n<span/<span/g' |

# find strings that corresponds to template
$grepcmd '<h.*id="user-content-[^"]*".*</h[1-6]' |

Expand Down
File renamed without changes.
9 changes: 2 additions & 7 deletions tests/test directory/test_filepathwithspace.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# 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 -->

* [Title](#title)
* [This is test for file path with space](#this-is-test-for-file-path-with-space)
<!--te-->

Blabla...
Expand Down
451 changes: 451 additions & 0 deletions tests/test directory/test_nonenglishchars.md

Large diffs are not rendered by default.

File renamed without changes.
44 changes: 44 additions & 0 deletions tests/test directory/test_setextwithformatting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Title one
=========

<!--ts-->
* [Title one](#title-one)
* [This is test for setext-style without formatting](#this-is-test-for-setext-style-without-formatting)
* [<em>Title two</em>](#title-two)
* [This is test for setext-style with formatting](#this-is-test-for-setext-style-with-formatting)
* [Title three](#title-three)
* [This is a regression test for atx-style](#this-is-a-regression-test-for-atx-style)
* [Title four is a particularly long title because of wrapping](#title-four-is-a-particularly-long-title-because-of-wrapping)
* [This is a test for long titles](#this-is-a-test-for-long-titles)
<!--te-->

Blabla...

## This is test for setext-style without formatting

Blabla...

*Title `two`*
=============

Blabla...

## This is test for setext-style with formatting

Blabla...

# Title `three`

Blabla...

## This is a regression test for atx-style

Blabla...

# Title four is a particularly long title because of wrapping

Blabla...

## This is a test for long titles

Blabla...
30 changes: 27 additions & 3 deletions tests/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ test_help() {
}

@test "TOC for non-english chars, #6, #10" {
run $BATS_TEST_DIRNAME/../gh-md-toc tests/test\ directory/test_nonenglishchars.md
assert_success

assert_equal "${lines[2]}" "* [命令行的艺术](#命令行的艺术)"
assert_equal "${lines[3]}" " * [必读](#必读)"
assert_equal "${lines[4]}" " * [基础](#基础)"
assert_equal "${lines[5]}" " * [日常使用](#日常使用)"
}

@test "TOC for non-english chars (remote load), #6, #10" {
run $BATS_TEST_DIRNAME/../gh-md-toc \
https://github.com/ekalinin/envirius/blob/f939d3b6882bfb6ecb28ef7b6e62862f934ba945/README.ru.md
assert_success
Expand Down Expand Up @@ -185,7 +195,7 @@ test_help() {
}

@test "TOC for text with backquote, #13" {
run $BATS_TEST_DIRNAME/../gh-md-toc tests/test_backquote.md
run $BATS_TEST_DIRNAME/../gh-md-toc tests/test\ directory/test_backquote.md
assert_success

assert_equal "${lines[2]}" "* [The command foo1](#the-command-foo1)"
Expand All @@ -196,16 +206,30 @@ test_help() {
}

@test "TOC for text with plus signs, #100" {
run $BATS_TEST_DIRNAME/../gh-md-toc tests/test_plussign.md
run $BATS_TEST_DIRNAME/../gh-md-toc tests/test\ directory/test_plussign.md
assert_success

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
run $BATS_TEST_DIRNAME/../gh-md-toc --no-backup --hide-footer 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)"
}

@test "Toc for setext heading with formatting, #145" {
run $BATS_TEST_DIRNAME/../gh-md-toc --no-backup --hide-footer tests/test\ directory/test_setextwithformatting.md
assert_success

assert_equal "${lines[2]}" "* [Title one](#title-one)"
assert_equal "${lines[3]}" " * [This is test for setext-style without formatting](#this-is-test-for-setext-style-without-formatting)"
assert_equal "${lines[4]}" "* [<em>Title two</em>](#title-two)"
assert_equal "${lines[5]}" " * [This is test for setext-style with formatting](#this-is-test-for-setext-style-with-formatting)"
assert_equal "${lines[6]}" "* [Title three](#title-three)"
assert_equal "${lines[7]}" " * [This is a regression test for atx-style](#this-is-a-regression-test-for-atx-style)"
assert_equal "${lines[8]}" "* [Title four is a particularly long title because of wrapping](#title-four-is-a-particularly-long-title-because-of-wrapping)"
assert_equal "${lines[9]}" " * [This is a test for long titles](#this-is-a-test-for-long-titles)"
}