diff --git a/main.go b/main.go
index 2c4d406..2fb2d57 100644
--- a/main.go
+++ b/main.go
@@ -38,11 +38,12 @@ type GHDoc struct {
Depth int
Escape bool
GhToken string
+ Indent int
}
// NewGHDoc create GHDoc
-func NewGHDoc(Path string, AbsPaths bool, Depth int, Escape bool, Token string) *GHDoc {
- return &GHDoc{Path, AbsPaths, Depth, Escape, Token}
+func NewGHDoc(Path string, AbsPaths bool, Depth int, Escape bool, Token string, Indent int) *GHDoc {
+ return &GHDoc{Path, AbsPaths, Depth, Escape, Token, Indent}
}
// GetToc return GHToc for a document
@@ -52,9 +53,9 @@ func (doc *GHDoc) GetToc() *GHToc {
return nil
}
if doc.AbsPaths {
- return GrabTocX(htmlBody, doc.Path, doc.Depth, doc.Escape)
+ return GrabTocX(htmlBody, doc.Path, doc.Depth, doc.Escape, doc.Indent)
}
- return GrabTocX(htmlBody, "", doc.Depth, doc.Escape)
+ return GrabTocX(htmlBody, "", doc.Depth, doc.Escape, doc.Indent)
}
//
@@ -126,6 +127,13 @@ func removeStuf(s string) string {
return res
}
+// generate func of custom spaces indentation
+func generateListIndentation(spaces int) func() string {
+ return func() string {
+ return strings.Repeat(" ", spaces)
+ }
+}
+
// Public
// EscapeSpecChars Escapes special characters
@@ -174,17 +182,18 @@ func ConvertMd2Html(localpath string, token string) (string, error) {
}
// GrabToc Create TOC by html from github
-func GrabToc(html string, absPath string, depth int) *GHToc {
- return GrabTocX(html, absPath, depth, true)
+func GrabToc(html string, absPath string, depth int, indent int) *GHToc {
+ return GrabTocX(html, absPath, depth, true, indent)
}
// GrabTocX Create TOC
-func GrabTocX(html string, absPath string, depth int, escape bool) *GHToc {
+func GrabTocX(html string, absPath string, depth int, escape bool, indent int) *GHToc {
re := `(?si)
This function should return list of available versions of the plugin. For example:
- `, "", 0) + `, "", 0, 2) for i := 0; i <= len(tocExpected)-1; i++ { if toc[i] != tocExpected[i] { t.Error("Res :", toc[i], "\nExpected :", tocExpected[i]) @@ -105,7 +105,7 @@ func Test_GrabTocBackquoted(t *testing.T) { The commandbar2
is better
Blabla...
- `, "", 0) + `, "", 0, 2) for i := 0; i <= len(tocExpected)-1; i++ { if toc[i] != tocExpected[i] { @@ -142,7 +142,7 @@ func Test_GrabTocDepth(t *testing.T) { The commandbar2
is better
Blabla...
- `, "", 1) + `, "", 1, 2) // fmt.Println(toc) @@ -160,7 +160,7 @@ func Test_GrabTocWithAbspath(t *testing.T) { } toc := *GrabToc(`