Skip to content

Commit ba89724

Browse files
committed
use github css style
1 parent 86c996f commit ba89724

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*~
22
pkg/*
33
*.html
4+
*.exe
45

ebook/build.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
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

1616
func (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

Comments
 (0)