rm unused
This commit is contained in:
39
zh/build.go
39
zh/build.go
@@ -1,17 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/a8m/mark"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"bufio"
|
||||
// "net/http"
|
||||
// "github.com/fairlyblank/md2min"
|
||||
"github.com/a8m/mark"
|
||||
|
||||
)
|
||||
|
||||
// 定义一个访问者结构体
|
||||
@@ -71,35 +68,11 @@ func (self *Visitor) md2html(arg map[string]string) error {
|
||||
opts.Smartypants = true
|
||||
opts.Fractions = true
|
||||
// r1 := []rune(s1)
|
||||
m := mark.New(input, opts)
|
||||
// md := md2min.New("none")
|
||||
// err = md.Parse([]byte(input), out)
|
||||
// client := &http.Client{}
|
||||
|
||||
// req, err := http.NewRequest("POST", "https://api.github.com/markdown/raw", strings.NewReader(input))
|
||||
// if err != nil {
|
||||
// handle error
|
||||
// }
|
||||
|
||||
// req.Header.Set("Content-Type", "text/plain")
|
||||
// req.Header.Set("charset", "utf-8")
|
||||
// req.Header.Set("User-Agent", "m2shad0w")
|
||||
//
|
||||
// resp, err := client.Do(req)
|
||||
|
||||
// defer resp.Body.Close()
|
||||
|
||||
// body, err := ioutil.ReadAll(resp.Body)
|
||||
// if err != nil {
|
||||
// handle error
|
||||
// }
|
||||
|
||||
m := mark.New(input, opts
|
||||
w := bufio.NewWriter(out)
|
||||
n4, err := w.WriteString(s + m.Render())
|
||||
fmt.Printf("wrote %d bytes\n", n4)
|
||||
// fmt.Printf("wrote %d bytes\n", n4)
|
||||
//使用 Flush 来确保所有缓存的操作已写入底层写入器。
|
||||
w.Flush()
|
||||
n4, err := w.WriteString(s + m.Render())
|
||||
fmt.Printf("wrote %d bytes\n", n4)
|
||||
w.Flush()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Parsing Error", err)
|
||||
os.Exit(-1)
|
||||
|
||||
@@ -15,7 +15,7 @@ WORKDIR="$(cd $(dirname $0); pwd -P)"
|
||||
#
|
||||
MSG_INSTALL_PANDOC_FIRST='请先安装pandoc,然后再次运行'
|
||||
MSG_SUCCESSFULLY_GENERATED='build-web-application-with-golang.epub 已经建立'
|
||||
MSG_CREATOR='M2shad0w'
|
||||
MSG_CREATOR='Astaxie'
|
||||
MSG_DESCRIPTION='一本开源的Go Web编程书籍'
|
||||
MSG_LANGUAGE='zh-CN'
|
||||
MSG_TITLE='Go Web编程'
|
||||
|
||||
@@ -3,15 +3,16 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"bufio"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 开发者 github token
|
||||
const token = ""
|
||||
|
||||
// 定义一个访问者结构体
|
||||
type Visitor struct{}
|
||||
|
||||
@@ -66,31 +67,31 @@ func (self *Visitor) md2html(arg map[string]string) error {
|
||||
}
|
||||
defer out.Close()
|
||||
client := &http.Client{}
|
||||
|
||||
req, err := http.NewRequest("POST", "https://api.github.com/markdown/raw", strings.NewReader(input))
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "text/plain")
|
||||
req.Header.Set("charset", "utf-8")
|
||||
req.Header.Set("Authorization", "token " + token)
|
||||
//
|
||||
resp, err := client.Do(req)
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", "https://api.github.com/markdown/raw", strings.NewReader(input))
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "text/plain")
|
||||
req.Header.Set("charset", "utf-8")
|
||||
req.Header.Set("Authorization", "token "+token)
|
||||
//
|
||||
resp, err := client.Do(req)
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
// handle error
|
||||
}
|
||||
|
||||
w := bufio.NewWriter(out)
|
||||
n4, err := w.WriteString(s + string(body)) //m.Render()
|
||||
fmt.Printf("wrote %d bytes\n", n4)
|
||||
// fmt.Printf("wrote %d bytes\n", n4)
|
||||
//使用 Flush 来确保所有缓存的操作已写入底层写入器。
|
||||
w.Flush()
|
||||
n4, err := w.WriteString(s + string(body)) //m.Render()
|
||||
fmt.Printf("wrote %d bytes\n", n4)
|
||||
// fmt.Printf("wrote %d bytes\n", n4)
|
||||
//使用 Flush 来确保所有缓存的操作已写入底层写入器。
|
||||
w.Flush()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Parsing Error", err)
|
||||
os.Exit(-1)
|
||||
|
||||
Reference in New Issue
Block a user