Skip to content

Commit ff21610

Browse files
committed
rm unused
1 parent d723761 commit ff21610

File tree

3 files changed

+33
-59
lines changed

3 files changed

+33
-59
lines changed

zh/build.go

+6-33
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
package main
22

33
import (
4+
"bufio"
45
"fmt"
6+
"github.com/a8m/mark"
57
"io/ioutil"
68
"os"
79
"path/filepath"
810
"regexp"
911
"strings"
10-
"bufio"
11-
// "net/http"
12-
// "github.com/fairlyblank/md2min"
13-
"github.com/a8m/mark"
14-
1512
)
1613

1714
// 定义一个访问者结构体
@@ -71,35 +68,11 @@ func (self *Visitor) md2html(arg map[string]string) error {
7168
opts.Smartypants = true
7269
opts.Fractions = true
7370
// r1 := []rune(s1)
74-
m := mark.New(input, opts)
75-
// md := md2min.New("none")
76-
// err = md.Parse([]byte(input), out)
77-
// client := &http.Client{}
78-
79-
// req, err := http.NewRequest("POST", "https://api.github.com/markdown/raw", strings.NewReader(input))
80-
// if err != nil {
81-
// handle error
82-
// }
83-
84-
// req.Header.Set("Content-Type", "text/plain")
85-
// req.Header.Set("charset", "utf-8")
86-
// req.Header.Set("User-Agent", "m2shad0w")
87-
//
88-
// resp, err := client.Do(req)
89-
90-
// defer resp.Body.Close()
91-
92-
// body, err := ioutil.ReadAll(resp.Body)
93-
// if err != nil {
94-
// handle error
95-
// }
96-
71+
m := mark.New(input, opts
9772
w := bufio.NewWriter(out)
98-
n4, err := w.WriteString(s + m.Render())
99-
fmt.Printf("wrote %d bytes\n", n4)
100-
// fmt.Printf("wrote %d bytes\n", n4)
101-
//使用 Flush 来确保所有缓存的操作已写入底层写入器。
102-
w.Flush()
73+
n4, err := w.WriteString(s + m.Render())
74+
fmt.Printf("wrote %d bytes\n", n4)
75+
w.Flush()
10376
if err != nil {
10477
fmt.Fprintln(os.Stderr, "Parsing Error", err)
10578
os.Exit(-1)

zh/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ WORKDIR="$(cd $(dirname $0); pwd -P)"
1515
#
1616
MSG_INSTALL_PANDOC_FIRST='请先安装pandoc,然后再次运行'
1717
MSG_SUCCESSFULLY_GENERATED='build-web-application-with-golang.epub 已经建立'
18-
MSG_CREATOR='M2shad0w'
18+
MSG_CREATOR='Astaxie'
1919
MSG_DESCRIPTION='一本开源的Go Web编程书籍'
2020
MSG_LANGUAGE='zh-CN'
2121
MSG_TITLE='Go Web编程'

zh/build_new.go

+26-25
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ package main
33
import (
44
"fmt"
55
"io/ioutil"
6+
"net/http"
67
"os"
78
"path/filepath"
89
"regexp"
910
"strings"
10-
"bufio"
11-
"net/http"
1211
)
1312

13+
// 开发者 github token
1414
const token = ""
15+
1516
// 定义一个访问者结构体
1617
type Visitor struct{}
1718

@@ -66,31 +67,31 @@ func (self *Visitor) md2html(arg map[string]string) error {
6667
}
6768
defer out.Close()
6869
client := &http.Client{}
69-
70-
req, err := http.NewRequest("POST", "https://api.github.com/markdown/raw", strings.NewReader(input))
71-
if err != nil {
72-
// handle error
73-
}
74-
75-
req.Header.Set("Content-Type", "text/plain")
76-
req.Header.Set("charset", "utf-8")
77-
req.Header.Set("Authorization", "token " + token)
78-
//
79-
resp, err := client.Do(req)
80-
81-
defer resp.Body.Close()
82-
83-
body, err := ioutil.ReadAll(resp.Body)
84-
if err != nil {
85-
// handle error
86-
}
70+
71+
req, err := http.NewRequest("POST", "https://api.github.com/markdown/raw", strings.NewReader(input))
72+
if err != nil {
73+
// handle error
74+
}
75+
76+
req.Header.Set("Content-Type", "text/plain")
77+
req.Header.Set("charset", "utf-8")
78+
req.Header.Set("Authorization", "token "+token)
79+
//
80+
resp, err := client.Do(req)
81+
82+
defer resp.Body.Close()
83+
84+
body, err := ioutil.ReadAll(resp.Body)
85+
if err != nil {
86+
// handle error
87+
}
8788

8889
w := bufio.NewWriter(out)
89-
n4, err := w.WriteString(s + string(body)) //m.Render()
90-
fmt.Printf("wrote %d bytes\n", n4)
91-
// fmt.Printf("wrote %d bytes\n", n4)
92-
//使用 Flush 来确保所有缓存的操作已写入底层写入器。
93-
w.Flush()
90+
n4, err := w.WriteString(s + string(body)) //m.Render()
91+
fmt.Printf("wrote %d bytes\n", n4)
92+
// fmt.Printf("wrote %d bytes\n", n4)
93+
//使用 Flush 来确保所有缓存的操作已写入底层写入器。
94+
w.Flush()
9495
if err != nil {
9596
fmt.Fprintln(os.Stderr, "Parsing Error", err)
9697
os.Exit(-1)

0 commit comments

Comments
 (0)