Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.

Commit

Permalink
Remove markdown links from TOC entries.
Browse files Browse the repository at this point in the history
e.g., the "Getting Help" chapter has section headings containing
markdown links, which were rendered poorly.
  • Loading branch information
flavorjones committed Apr 28, 2015
1 parent d330aa2 commit c4557a5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Rakefile
Expand Up @@ -87,12 +87,17 @@ end

def chapter_toc(content)
header_re = /^(##) /
markdown_link_re = /\[(.*)\](\[.*\]|\(.*\))/
toc = []
content = content.split("\n").map do |line|
if line =~ header_re
title = line.gsub(header_re, '')
header = $1

if title =~ markdown_link_re
title = title.gsub(markdown_link_re, '\1')
end

# extract id and store it into toc
id = title.downcase.gsub(/\W/, '_')
toc_entry = "1. [#{title}](##{id})"
Expand Down

0 comments on commit c4557a5

Please sign in to comment.