Whoopsies fixed it
parent
e6a126ea0b
commit
4fdbee6df5
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue