Skip to content

Commit 52169ad

Browse files
committed
Clean up
1 parent 9d3f330 commit 52169ad

File tree

2 files changed

+3
-63
lines changed

2 files changed

+3
-63
lines changed

ghdoc.go

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,16 @@ func (doc *GHDoc) GrabToc() *GHToc {
152152

153153
hdrs := findHeadersInString(doc.html)
154154

155+
// Determine the min depth represented by the slice of headers. For example, if a document only
156+
// has H2 tags and no H1 tags. We want the H2 TOC entries to not have an indent.
155157
minHxDepth := MaxHxDepth
156158
for _, hdr := range hdrs {
157159
if hdr.Depth < minHxDepth {
158160
minHxDepth = hdr.Depth
159161
}
160162
}
161163

164+
// Populate the toc with entries
162165
toc := GHToc{}
163166
for _, hdr := range hdrs {
164167
hDepth := int(hdr.Depth)
@@ -193,68 +196,6 @@ func (doc *GHDoc) tocLink(href string) string {
193196
return link
194197
}
195198

196-
//func (doc *GHDoc) GrabToc() *GHToc {
197-
// doc.d("GrabToc: start, html size: " + strconv.Itoa(len(doc.html)))
198-
// defer doc.d("GrabToc: done.")
199-
200-
// r := headerRegexp()
201-
// listIndentation := generateListIndentation(doc.Indent)
202-
203-
// toc := GHToc{}
204-
// minHeaderNum := 6
205-
// var groups []map[string]string
206-
// doc.d("GrabToc: matching ...")
207-
// for idx, match := range r.FindAllStringSubmatch(doc.html, -1) {
208-
// doc.d("GrabToc: match #" + strconv.Itoa(idx) + " ...")
209-
// group := make(map[string]string)
210-
// // fill map for groups
211-
// for i, name := range r.SubexpNames() {
212-
// if i == 0 || name == "" {
213-
// continue
214-
// }
215-
// doc.d("GrabToc: process group: " + name + ": " + match[i] + " ...")
216-
// group[name] = removeStuff(match[i])
217-
// }
218-
// // update minimum header number
219-
// n, _ := strconv.Atoi(group["num"])
220-
// if n < minHeaderNum {
221-
// minHeaderNum = n
222-
// }
223-
// groups = append(groups, group)
224-
// }
225-
226-
// var tmpSection string
227-
// doc.d("GrabToc: processing groups ...")
228-
// doc.d("Including starting from level " + strconv.Itoa(doc.StartDepth))
229-
// for _, group := range groups {
230-
// // format result
231-
// n, _ := strconv.Atoi(group["num"])
232-
// if n <= doc.StartDepth {
233-
// continue
234-
// }
235-
// if doc.Depth > 0 && n > doc.Depth {
236-
// continue
237-
// }
238-
239-
// link, _ := url.QueryUnescape(group["href"])
240-
// if doc.AbsPaths {
241-
// link = doc.Path + link
242-
// }
243-
244-
// tmpSection = removeStuff(group["name"])
245-
// if doc.Escape {
246-
// tmpSection = EscapeSpecChars(tmpSection)
247-
// }
248-
// tocItem := strings.Repeat(listIndentation(), n-minHeaderNum-doc.StartDepth) + "* " +
249-
// "[" + tmpSection + "]" +
250-
// "(" + link + ")"
251-
// //fmt.Println(tocItem)
252-
// toc = append(toc, tocItem)
253-
// }
254-
255-
// return &toc
256-
//}
257-
258199
// GetToc return GHToc for a document
259200
func (doc *GHDoc) GetToc() *GHToc {
260201
if err := doc.Convert2HTML(); err != nil {

headerfinder.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func findHeaders(r io.Reader) []Header {
3737
tt := tokenizer.Next()
3838
switch tt {
3939
case html.ErrorToken:
40-
// TODO(chuck): Check if this is io.EOF?
4140
return hdrs
4241
case html.StartTagToken:
4342
t := tokenizer.Token()

0 commit comments

Comments
 (0)