Skip to content

Commit

Permalink
excluded grep's null-data option for Mac; fixed ekalinin#14
Browse files Browse the repository at this point in the history
  • Loading branch information
ekalinin committed Aug 2, 2015
1 parent cc60622 commit 9f4b683
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gh-md-toc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ gh_toc(){
fi
}

GH_GREP="grep -E --null-data --text -o"
if [ "$uname" = "Darwin" ]; then
GH_GREP="grep -E --text -o"
fi

#
# Grabber of the TOC from rendered html
#
Expand All @@ -106,7 +111,7 @@ gh_toc(){
#
gh_toc_grab() {
# find strings that corresponds to template
grep -E --null-data --text -o \
$GH_GREP \
'<h[1-6]>\s*<a\s*id="user-content-[^"]*"\s*class="anchor"\s*href="[^"]*"[^>]*>\s*<span[^<*]*</span>\s*</a>.*?\s*</h' | \
# replace all new lines except last one
sed 's/h$/h\nendd/g' | tr '\n' ' ' | sed 's/h endd/\h\n/g' | \
Expand Down

0 comments on commit 9f4b683

Please sign in to comment.