Skip to content

Commit 7291b4a

Browse files
committed
move GHToc into separate file; add some logging
1 parent e50e5d6 commit 7291b4a

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ghdoc.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import (
1111
"strings"
1212
)
1313

14-
// GHToc GitHub TOC
15-
type GHToc []string
16-
1714
// Print TOC to the console
1815
func (toc *GHToc) Print(w io.Writer) error {
1916
for _, tocItem := range *toc {
@@ -103,16 +100,21 @@ func (doc *GHDoc) Convert2HTML() error {
103100
doc.d("Convert2HTML: start.")
104101
defer doc.d("Convert2HTML: done.")
105102

103+
// remote file may be of 2 types:
104+
// - raw md file (we need to download it locally and convert t HTML)
105+
// - html file (we need just to load it and parse TOC from it)
106106
if doc.IsRemoteFile() {
107107
htmlBody, ContentType, err := doc.httpGetter(doc.Path)
108108
doc.d("Convert2HTML: remote file. content-type: " + ContentType)
109109
if err != nil {
110+
doc.d("Convert2HTML: err=" + err.Error())
110111
return err
111112
}
112113

113114
// if not a plain text - return the result (should be html)
114115
if strings.Split(ContentType, ";")[0] != "text/plain" {
115116
doc.html = string(htmlBody)
117+
doc.d("Convert2HTML: not a plain text, body" + string(htmlBody)[:200])
116118
return nil
117119
}
118120

ghtoc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package ghtoc
2+
3+
// GHToc GitHub TOC
4+
type GHToc []string

0 commit comments

Comments
 (0)