Skip to content

Commit 991b3dd

Browse files
committed
0.4.6: fixed #19
1 parent bb5e6f6 commit 991b3dd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

gh-md-toc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# substr($0, match($0, "href=\".*\" ")+5, RLENGTH-6)
2424
#
2525

26-
gh_toc_version="0.4.5"
26+
gh_toc_version="0.4.6"
2727

2828
gh_user_agent="gh-md-toc v$gh_toc_version"
2929

@@ -111,8 +111,9 @@ fi
111111
#
112112
gh_toc_grab() {
113113
# find strings that corresponds to template
114+
#'<h[1-6]>\s*<a\s*id="user-content-[^"]*"\s*class="anchor"\s*href="[^"]*"[^>]*>\s*<span[^<*]*</span>\s*</a>.*?\s*</h' | \
114115
$GH_GREP \
115-
'<h[1-6]>\s*<a\s*id="user-content-[^"]*"\s*class="anchor"\s*href="[^"]*"[^>]*>\s*<span[^<*]*</span>\s*</a>.*?\s*</h' | \
116+
'<h[1-6]>\s*<a\s*id="user-content-[^"]*"\s*class="anchor"\s*href="[^"]*"[^>]*>.*?</a>.*?\s*</h' | \
116117
# replace all new lines except last one
117118
sed 's/h$/h\nendd/g' | tr '\n' ' ' | sed 's/h endd/\h\n/g' | \
118119
# trim head spaces
@@ -123,7 +124,7 @@ gh_toc_grab() {
123124
# <h1> <a id="user-content-..." href="..."><span ...></span></a> ... </h
124125
# format result line
125126
echo -e "$(awk -v "gh_url=$1" '{
126-
print sprintf("%*s", substr($1, 3, 1)*2, " ") "* [" substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\".*\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')"
127+
print sprintf("%*s", substr($1, 3, 1)*2, " ") "* [" substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)"](" gh_url substr($0, match($0, "href=\"[^\"]+?\" ")+6, RLENGTH-8) ")"}' | sed 'y/+/ /; s/%/\\x/g')"
127128
}
128129

129130
#

0 commit comments

Comments
 (0)