-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (38 loc) · 844 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/jessevdk/go-flags"
_ "github.com/wzshiming/winseq" // Windows 虚拟终端序列
)
// CLI utility for converting markdown to a single html file
func main() {
var opts Options
inputs, err := flags.Parse(&opts)
if err != nil {
os.Exit(1)
}
if len(opts.InputFile) > 0 {
inputs = []string{opts.InputFile}
}
if len(inputs) <= 0 {
_, _ = fmt.Fprintln(os.Stderr, "Please specify input Markdown")
os.Exit(1)
}
var files []string
for _, input := range inputs {
f, err := filepath.Glob(input)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
files = append(files, f...)
}
if len(files) <= 0 {
_, _ = fmt.Fprintln(os.Stderr, "File is not found")
os.Exit(1)
}
parser := HTMLParser{Options: opts}
parser.parserMarkdown(files)
}