deprecate dedicatd comment stage

This commit is contained in:
dre 2021-07-11 14:53:44 +08:00
parent 71f73cb35b
commit 31f3a95ee0
3 changed files with 0 additions and 37 deletions

View file

@ -30,7 +30,6 @@ func main() {
s := pipe.New() s := pipe.New()
s.Use(mdproc.Preprocessor()) s.Use(mdproc.Preprocessor())
s.Use(mdproc.RemoveComments)
s.Use(mdproc.RemoveFrontMatter) s.Use(mdproc.RemoveFrontMatter)
s.Use(mdproc.FormatHeadings) s.Use(mdproc.FormatHeadings)
s.Use(mdproc.FormatLinks) s.Use(mdproc.FormatLinks)

View file

@ -1,35 +0,0 @@
package mdproc
import (
"bytes"
"regexp"
"github.com/n0x1m/md2gmi/pipe"
)
func RemoveComments(in chan pipe.StreamItem) chan pipe.StreamItem {
out := make(chan pipe.StreamItem)
go func() {
re := regexp.MustCompile(`(?s)<!--(.*?)-->`)
for b := range in {
data := b.Payload()
touched := false
for _, match := range re.FindAllSubmatch(data, -1) {
data = bytes.Replace(data, match[0], []byte(""), 1)
touched = true
}
if touched && len(bytes.TrimSpace(data)) == 0 {
continue
}
out <- pipe.NewItem(b.Index(), data)
}
close(out)
}()
return out
}

View file

@ -150,7 +150,6 @@ func TestMd2Gmi(t *testing.T) {
s := pipe.New() s := pipe.New()
s.Use(mdproc.Preprocessor()) s.Use(mdproc.Preprocessor())
s.Use(mdproc.RemoveComments)
s.Use(mdproc.RemoveFrontMatter) s.Use(mdproc.RemoveFrontMatter)
s.Use(mdproc.FormatHeadings) s.Use(mdproc.FormatHeadings)
s.Use(mdproc.FormatLinks) s.Use(mdproc.FormatLinks)