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