rename Extensions → Options
This commit is contained in:
parent
99ba8c18fe
commit
91a38d3048
@ -10,13 +10,15 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
var opt markdown.Options
|
||||
flag.BoolVar(&opt.Notes, "notes", false, "turn on footnote syntax")
|
||||
flag.BoolVar(&opt.Smart, "smart", false, "turn on smart quotes, dashes, and ellipses")
|
||||
flag.BoolVar(&opt.Dlists, "dlists", false, "support definitions lists")
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: %s [FILE]\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
optNotes := flag.Bool("notes", false, "turn on footnote syntax")
|
||||
optSmart := flag.Bool("smart", false, "turn on smart quotes, dashes, and ellipses")
|
||||
optDlists := flag.Bool("dlists", false, "support definitions lists")
|
||||
flag.Parse()
|
||||
|
||||
r := os.Stdin
|
||||
@ -29,16 +31,10 @@ func main() {
|
||||
r = f
|
||||
}
|
||||
|
||||
e := markdown.Extensions{
|
||||
Notes: *optNotes,
|
||||
Smart: *optSmart,
|
||||
Dlists: *optDlists,
|
||||
}
|
||||
|
||||
startPProf()
|
||||
defer stopPProf()
|
||||
|
||||
doc := markdown.Parse(r, e)
|
||||
doc := markdown.Parse(r, opt)
|
||||
w := bufio.NewWriter(os.Stdout)
|
||||
doc.WriteHtml(w)
|
||||
w.Flush()
|
||||
|
2
doc.go
2
doc.go
@ -12,7 +12,7 @@ Usage example:
|
||||
)
|
||||
|
||||
func main() {
|
||||
doc := md.Parse(os.Stdin, md.Extensions{Smart: true})
|
||||
doc := md.Parse(os.Stdin, md.Options{Smart: true})
|
||||
|
||||
w := bufio.NewWriter(os.Stdout)
|
||||
doc.WriteHtml(w)
|
||||
|
10
markdown.go
10
markdown.go
@ -26,8 +26,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Markdown Extensions:
|
||||
type Extensions struct {
|
||||
// Markdown Options:
|
||||
type Options struct {
|
||||
Smart bool
|
||||
Notes bool
|
||||
FilterHTML bool
|
||||
@ -36,9 +36,9 @@ type Extensions struct {
|
||||
}
|
||||
|
||||
// Parse converts a Markdown document into a tree for later output processing.
|
||||
func Parse(r io.Reader, ext Extensions) *Doc {
|
||||
func Parse(r io.Reader, opt Options) *Doc {
|
||||
d := new(Doc)
|
||||
d.extension = ext
|
||||
d.extension = opt
|
||||
|
||||
d.parser = new(yyParser)
|
||||
d.parser.Doc = d
|
||||
@ -47,7 +47,7 @@ func Parse(r io.Reader, ext Extensions) *Doc {
|
||||
s := preformat(r)
|
||||
|
||||
d.parseRule(ruleReferences, s)
|
||||
if ext.Notes {
|
||||
if opt.Notes {
|
||||
d.parseRule(ruleNotes, s)
|
||||
}
|
||||
raw := d.parseMarkdown(s)
|
||||
|
@ -92,7 +92,7 @@ const (
|
||||
|
||||
type Doc struct {
|
||||
parser *yyParser
|
||||
extension Extensions
|
||||
extension Options
|
||||
|
||||
tree *element /* Results of parse. */
|
||||
references *element /* List of link references found. */
|
||||
|
@ -92,7 +92,7 @@ const (
|
||||
|
||||
type Doc struct {
|
||||
parser *yyParser
|
||||
extension Extensions
|
||||
extension Options
|
||||
|
||||
tree *element /* Results of parse. */
|
||||
references *element /* List of link references found. */
|
||||
|
Loading…
Reference in New Issue
Block a user