Skip to content

Commit d750c7e

Browse files
committed
Merge branch 'master' of github.com:ekalinin/github-markdown-toc
2 parents 5b74455 + 8eee8f3 commit d750c7e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

gh-md-toc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# substr($0, length($0), 1)
1515
#
1616
# 3.2 Get level from 3.1 and insert corresponding number of spaces before '*':
17-
# sprintf("%*s", substr($0, length($0), 1)*2, " ")
17+
# sprintf("%*s", substr($0, length($0), 1)*3, " ")
1818
#
1919
# 4. Find head's text and insert it inside "* [ ... ]":
2020
# substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
@@ -51,20 +51,26 @@ gh_toc_load() {
5151
# <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'"
5252
gh_toc_md2html() {
5353
local gh_file_md=$1
54+
URL=https://api.github.com/markdown/raw
55+
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
56+
if [ -f "$TOKEN" ]; then
57+
URL="$URL?access_token=$(cat $TOKEN)"
58+
fi
5459
curl -s --user-agent "$gh_user_agent" \
5560
--data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
56-
https://api.github.com/markdown/raw
61+
$URL
5762
}
5863

5964
#
6065
# Is passed string url
6166
#
6267
gh_is_url() {
63-
if [[ $1 == https* || $1 == http* ]]; then
64-
echo "yes"
65-
else
66-
echo "no"
67-
fi
68+
case $1 in
69+
https* | http*)
70+
echo "yes";;
71+
*)
72+
echo "no";;
73+
esac
6874
}
6975

7076
#

0 commit comments

Comments
 (0)