Skip to content

Commit 8eee8f3

Browse files
authored
Merge pull request #36 from nevillelyh/master
add optional GitHub API token
2 parents 6f9365d + f8d1629 commit 8eee8f3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gh-md-toc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,22 @@ 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() {
6368
case $1 in
64-
https* | http*)
69+
https* | http*)
6570
echo "yes";;
6671
*)
6772
echo "no";;

0 commit comments

Comments
 (0)