@@ -2,7 +2,7 @@ package main
22
33import (
44 "fmt"
5- "github.com/russross/blackfriday "
5+ "github.com/fairlyblank/md2min "
66 "io/ioutil"
77 "os"
88 "path/filepath"
@@ -11,7 +11,7 @@ import (
1111)
1212
1313// 定义一个访问者结构体
14- type Visitor struct {}
14+ type Visitor struct {}
1515
1616func (self * Visitor ) visit (path string , f os.FileInfo , err error ) error {
1717 if f == nil {
@@ -30,21 +30,18 @@ func (self *Visitor) visit(path string, f os.FileInfo, err error) error {
3030 }
3131 input , _ := ioutil .ReadAll (file )
3232 input = regexp .MustCompile ("\\ [(.*?)\\ ]\\ (<?(.*?)\\ .md>?\\ )" ).ReplaceAll (input , []byte ("[$1](<$2.html>)" ))
33- output := blackfriday .MarkdownCommon (input )
3433 var out * os.File
3534 if out , err = os .Create (strings .Replace (f .Name (), ".md" , ".html" , - 1 )); err != nil {
3635 fmt .Fprintf (os .Stderr , "Error creating %s: %v" , f .Name (), err )
3736 os .Exit (- 1 )
3837 }
3938 defer out .Close ()
40- header := "<!doctype html>\n <html lang=\" en\" >\n <head>\n <meta charset=\" utf-8\" />\n </head>\n "
41- footer := "</html>\n "
42- out .Write ([]byte (header ))
43- if _ , err = out .Write (output ); err != nil {
44- fmt .Fprintln (os .Stderr , "Error writing output:" , err )
39+ md := md2min .New ("none" )
40+ err = md .Parse (input , out )
41+ if err != nil {
42+ fmt .Fprintln (os .Stderr , "Parsing Error" , err )
4543 os .Exit (- 1 )
4644 }
47- out .Write ([]byte (footer ))
4845 }
4946 }
5047 return nil
0 commit comments