Whoopsies fixed it

master
Bel LaPointe 2020-08-07 13:46:39 -06:00
parent e6a126ea0b
commit 4fdbee6df5
2 changed files with 13 additions and 8 deletions

View File

@ -34,6 +34,9 @@ func (n *Notes) Comment(urlPath string, lineno int, comment string) error {
writer := io.Writer(f2)
for i := 0; i < lineno+1; i++ {
line, _, err := reader.ReadLine()
if err == io.EOF {
break
}
if err != nil {
return err
}
@ -46,14 +49,13 @@ func (n *Notes) Comment(urlPath string, lineno int, comment string) error {
return err
}
}
formatted := "\n"
formatted += fmt.Sprintf("> *%s*\n", comment)
formatted := fmt.Sprintf("> *%s*\n\n", comment)
_, err = io.Copy(writer, strings.NewReader(formatted))
if err != nil {
return err
}
_, err = io.Copy(writer, reader)
if err != nil {
if err != nil && err != io.EOF {
return err
}
f2.Close()

View File

@ -41,18 +41,21 @@ func (n *Notes) commentFormer(urlPath string, md []byte) html.RenderNodeFunc {
nextHeader := func() {
cur++
for cur < len(lines) {
if bytes.Contains(lines[cur], []byte("```")) {
cur++
for cur < len(lines) && !bytes.Contains(lines[cur], []byte("```")) {
for _, opener_closer := range [][]string{{"```", "```"}, {`<summary>`, `</summary>`}} {
if bytes.Contains(lines[cur], []byte(opener_closer[0])) {
cur++
for cur < len(lines) && !bytes.Contains(lines[cur], []byte(opener_closer[1])) {
cur++
}
cur++
}
cur++
}
if cur >= len(lines) {
break
}
line := lines[cur]
if ok, err := regexp.Match(`^\s*#+\s*[^\s]+\s*$`, line); err != nil {
ok, err := regexp.Match(`^\s*#+\s*.+$`, line)
if err != nil {
panic(err)
} else if ok {
return