Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelBoucey committed Aug 13, 2023
1 parent 980cb71 commit d798498
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"regexp"
"runtime"
"strconv"
"strings"
"strings"
)

func main() {
Expand Down Expand Up @@ -168,7 +168,9 @@ func main() {

for _, line := range tocLines {

_, _ = io.WriteString(mdTmpFile, line+newLine)
matches := headerLine.FindStringSubmatch(line)

_, _ = io.WriteString(mdTmpFile, strings.Repeat(" ", len(matches[1])-1)+"- "+"["+matches[2]+"](#"+matches[2]+") "+matches[3]+newLine)

}

Expand All @@ -179,8 +181,17 @@ func main() {

for _, line := range mdLines {

_, _ = io.WriteString(mdTmpFile, line+newLine)
matches := headerLine.FindStringSubmatch(line)

if len(matches) == 4 && *tocFlag {

_, _ = io.WriteString(mdTmpFile, matches[1]+" ["+matches[2]+"](#){name="+matches[2]+"} "+matches[3]+newLine)

} else {

_, _ = io.WriteString(mdTmpFile, line+newLine)

}
}

mdTmpFile.Close()
Expand All @@ -198,20 +209,29 @@ func main() {

for _, line := range tocLines {

matches := headerLine.FindStringSubmatch(line)
matches := headerLine.FindStringSubmatch(line)

fmt.Println(strings.Repeat(" ",len(matches[1])-1)+"+ "+matches[2]+" "+matches[3])
fmt.Println(strings.Repeat(" ", len(matches[1])-1) + "- " + "[" + matches[2] + "](#" + matches[2] + ") " + matches[3])

}

fmt.Println("<!-- /TOC -->"+newLine)
fmt.Println("<!-- /TOC -->" + newLine)

}


for _, line := range mdLines {

fmt.Println(line)
matches := headerLine.FindStringSubmatch(line)

if len(matches) == 4 && *tocFlag {

fmt.Println(matches[1] + " [" + matches[2] + "](#){name=" + matches[2] + "} " + matches[3])

} else {

fmt.Println(line)

}

}
}
Expand Down

0 comments on commit d798498

Please sign in to comment.