@@ -2,7 +2,7 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/russross/blackfriday "
5
+ "github.com/fairlyblank/md2min "
6
6
"io/ioutil"
7
7
"os"
8
8
"path/filepath"
@@ -11,7 +11,7 @@ import (
11
11
)
12
12
13
13
// 定义一个访问者结构体
14
- type Visitor struct {}
14
+ type Visitor struct {}
15
15
16
16
func (self * Visitor ) visit (path string , f os.FileInfo , err error ) error {
17
17
if f == nil {
@@ -30,21 +30,18 @@ func (self *Visitor) visit(path string, f os.FileInfo, err error) error {
30
30
}
31
31
input , _ := ioutil .ReadAll (file )
32
32
input = regexp .MustCompile ("\\ [(.*?)\\ ]\\ (<?(.*?)\\ .md>?\\ )" ).ReplaceAll (input , []byte ("[$1](<$2.html>)" ))
33
- output := blackfriday .MarkdownCommon (input )
34
33
var out * os.File
35
34
if out , err = os .Create (strings .Replace (f .Name (), ".md" , ".html" , - 1 )); err != nil {
36
35
fmt .Fprintf (os .Stderr , "Error creating %s: %v" , f .Name (), err )
37
36
os .Exit (- 1 )
38
37
}
39
38
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 )
45
43
os .Exit (- 1 )
46
44
}
47
- out .Write ([]byte (footer ))
48
45
}
49
46
}
50
47
return nil
0 commit comments