Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ekalinin/github-markdown-toc
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Oct 4, 2017
2 parents 5b74455 + 8eee8f3 commit d750c7e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# substr($0, length($0), 1)
#
# 3.2 Get level from 3.1 and insert corresponding number of spaces before '*':
# sprintf("%*s", substr($0, length($0), 1)*2, " ")
# sprintf("%*s", substr($0, length($0), 1)*3, " ")
#
# 4. Find head's text and insert it inside "* [ ... ]":
# substr($0, match($0, /a>.*<\/h/)+2, RLENGTH-5)
Expand Down Expand Up @@ -51,20 +51,26 @@ gh_toc_load() {
# <p>Hello world github/linguist#1 <strong>cool</strong>, and #1!</p>'"
gh_toc_md2html() {
local gh_file_md=$1
URL=https://api.github.com/markdown/raw
TOKEN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/token.txt"
if [ -f "$TOKEN" ]; then
URL="$URL?access_token=$(cat $TOKEN)"
fi
curl -s --user-agent "$gh_user_agent" \
--data-binary @"$gh_file_md" -H "Content-Type:text/plain" \
https://api.github.com/markdown/raw
$URL
}

#
# Is passed string url
#
gh_is_url() {
if [[ $1 == https* || $1 == http* ]]; then
echo "yes"
else
echo "no"
fi
case $1 in
https* | http*)
echo "yes";;
*)
echo "no";;
esac
}

#
Expand Down

0 comments on commit d750c7e

Please sign in to comment.