mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Rename options names
This commit is contained in:
parent
28b28e34bb
commit
d9164d2556
6 changed files with 29 additions and 34 deletions
|
|
@ -161,7 +161,7 @@ You can overwrite the substitutions by `extensions.WithTypographicSubstitutions`
|
|||
markdown := goldmark.New(
|
||||
goldmark.WithExtensions(
|
||||
extension.NewTypographer(
|
||||
extension.WithTypographicSubstitutions(extension.TypographerSubstitutions{
|
||||
extension.WithTypographicSubstitutions(extension.TypographicSubstitutions{
|
||||
extension.LeftSingleQuote: []byte("‚"),
|
||||
extension.RightSingleQuote: nil, // nil disables a substitution
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func newDefaultSubstitutions() [][]byte {
|
|||
// SetOption implements SetOptioner.
|
||||
func (b *TypographerConfig) SetOption(name parser.OptionName, value interface{}) {
|
||||
switch name {
|
||||
case TypographicSubstitutions:
|
||||
case optTypographicSubstitutions:
|
||||
b.Substitutions = value.([][]byte)
|
||||
}
|
||||
}
|
||||
|
|
@ -73,19 +73,17 @@ type TypographerOption interface {
|
|||
SetTypographerOption(*TypographerConfig)
|
||||
}
|
||||
|
||||
// TypographicSubstitutions is an otpion name that specify replacement text for
|
||||
// punctuations.
|
||||
const TypographicSubstitutions parser.OptionName = "TypographicSubstitutions"
|
||||
const optTypographicSubstitutions parser.OptionName = "TypographicSubstitutions"
|
||||
|
||||
// TypographerSubstitutions is a list of the substitutions for the Typographer extension.
|
||||
type TypographerSubstitutions map[TypographicPunctuation][]byte
|
||||
// TypographicSubstitutions is a list of the substitutions for the Typographer extension.
|
||||
type TypographicSubstitutions map[TypographicPunctuation][]byte
|
||||
|
||||
type withTypographicSubstitutions struct {
|
||||
value [][]byte
|
||||
}
|
||||
|
||||
func (o *withTypographicSubstitutions) SetParserOption(c *parser.Config) {
|
||||
c.Options[TypographicSubstitutions] = o.value
|
||||
c.Options[optTypographicSubstitutions] = o.value
|
||||
}
|
||||
|
||||
func (o *withTypographicSubstitutions) SetTypographerOption(p *TypographerConfig) {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ type HeadingConfig struct {
|
|||
// SetOption implements SetOptioner.
|
||||
func (b *HeadingConfig) SetOption(name OptionName, value interface{}) {
|
||||
switch name {
|
||||
case AutoHeadingID:
|
||||
case optAutoHeadingID:
|
||||
b.AutoHeadingID = true
|
||||
case Attribute:
|
||||
case optAttribute:
|
||||
b.Attribute = true
|
||||
}
|
||||
}
|
||||
|
|
@ -29,13 +29,13 @@ type HeadingOption interface {
|
|||
}
|
||||
|
||||
// AutoHeadingID is an option name that enables auto IDs for headings.
|
||||
var AutoHeadingID OptionName = "AutoHeadingID"
|
||||
const optAutoHeadingID OptionName = "AutoHeadingID"
|
||||
|
||||
type withAutoHeadingID struct {
|
||||
}
|
||||
|
||||
func (o *withAutoHeadingID) SetParserOption(c *Config) {
|
||||
c.Options[AutoHeadingID] = true
|
||||
c.Options[optAutoHeadingID] = true
|
||||
}
|
||||
|
||||
func (o *withAutoHeadingID) SetHeadingOption(p *HeadingConfig) {
|
||||
|
|
|
|||
|
|
@ -17,25 +17,25 @@ type HTMLConfig struct {
|
|||
// SetOption implements SetOptioner.
|
||||
func (b *HTMLConfig) SetOption(name OptionName, value interface{}) {
|
||||
switch name {
|
||||
case FilterTags:
|
||||
case optFilterTags:
|
||||
b.FilterTags = value.(map[string]bool)
|
||||
}
|
||||
}
|
||||
|
||||
// A HTMLOption interface sets options for the raw HTML parsers.
|
||||
type HTMLOption interface {
|
||||
Option
|
||||
SetHTMLOption(*HTMLConfig)
|
||||
}
|
||||
|
||||
// FilterTags is an otpion name that specify forbidden tag names.
|
||||
const FilterTags OptionName = "FilterTags"
|
||||
const optFilterTags OptionName = "FilterTags"
|
||||
|
||||
type withFilterTags struct {
|
||||
value map[string]bool
|
||||
}
|
||||
|
||||
func (o *withFilterTags) SetParserOption(c *Config) {
|
||||
c.Options[FilterTags] = o.value
|
||||
c.Options[optFilterTags] = o.value
|
||||
}
|
||||
|
||||
func (o *withFilterTags) SetHTMLOption(p *HTMLConfig) {
|
||||
|
|
@ -43,10 +43,7 @@ func (o *withFilterTags) SetHTMLOption(p *HTMLConfig) {
|
|||
}
|
||||
|
||||
// WithFilterTags is a functional otpion that specify forbidden tag names.
|
||||
func WithFilterTags(names ...string) interface {
|
||||
Option
|
||||
HTMLOption
|
||||
} {
|
||||
func WithFilterTags(names ...string) HTMLOption {
|
||||
m := map[string]bool{}
|
||||
for _, name := range names {
|
||||
m[name] = true
|
||||
|
|
|
|||
|
|
@ -382,13 +382,13 @@ type Option interface {
|
|||
type OptionName string
|
||||
|
||||
// Attribute is an option name that spacify attributes of elements.
|
||||
const Attribute OptionName = "Attribute"
|
||||
const optAttribute OptionName = "Attribute"
|
||||
|
||||
type withAttribute struct {
|
||||
}
|
||||
|
||||
func (o *withAttribute) SetParserOption(c *Config) {
|
||||
c.Options[Attribute] = true
|
||||
c.Options[optAttribute] = true
|
||||
}
|
||||
|
||||
// WithAttribute is a functional option that enables custom attributes.
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ func NewConfig() Config {
|
|||
// SetOption implements renderer.NodeRenderer.SetOption.
|
||||
func (c *Config) SetOption(name renderer.OptionName, value interface{}) {
|
||||
switch name {
|
||||
case HardWraps:
|
||||
case optHardWraps:
|
||||
c.HardWraps = value.(bool)
|
||||
case XHTML:
|
||||
case optXHTML:
|
||||
c.XHTML = value.(bool)
|
||||
case Unsafe:
|
||||
case optUnsafe:
|
||||
c.Unsafe = value.(bool)
|
||||
case TextWriter:
|
||||
case optTextWriter:
|
||||
c.Writer = value.(Writer)
|
||||
}
|
||||
}
|
||||
|
|
@ -48,14 +48,14 @@ type Option interface {
|
|||
}
|
||||
|
||||
// TextWriter is an option name used in WithWriter.
|
||||
const TextWriter renderer.OptionName = "Writer"
|
||||
const optTextWriter renderer.OptionName = "Writer"
|
||||
|
||||
type withWriter struct {
|
||||
value Writer
|
||||
}
|
||||
|
||||
func (o *withWriter) SetConfig(c *renderer.Config) {
|
||||
c.Options[TextWriter] = o.value
|
||||
c.Options[optTextWriter] = o.value
|
||||
}
|
||||
|
||||
func (o *withWriter) SetHTMLOption(c *Config) {
|
||||
|
|
@ -72,13 +72,13 @@ func WithWriter(writer Writer) interface {
|
|||
}
|
||||
|
||||
// HardWraps is an option name used in WithHardWraps.
|
||||
const HardWraps renderer.OptionName = "HardWraps"
|
||||
const optHardWraps renderer.OptionName = "HardWraps"
|
||||
|
||||
type withHardWraps struct {
|
||||
}
|
||||
|
||||
func (o *withHardWraps) SetConfig(c *renderer.Config) {
|
||||
c.Options[HardWraps] = true
|
||||
c.Options[optHardWraps] = true
|
||||
}
|
||||
|
||||
func (o *withHardWraps) SetHTMLOption(c *Config) {
|
||||
|
|
@ -95,13 +95,13 @@ func WithHardWraps() interface {
|
|||
}
|
||||
|
||||
// XHTML is an option name used in WithXHTML.
|
||||
const XHTML renderer.OptionName = "XHTML"
|
||||
const optXHTML renderer.OptionName = "XHTML"
|
||||
|
||||
type withXHTML struct {
|
||||
}
|
||||
|
||||
func (o *withXHTML) SetConfig(c *renderer.Config) {
|
||||
c.Options[XHTML] = true
|
||||
c.Options[optXHTML] = true
|
||||
}
|
||||
|
||||
func (o *withXHTML) SetHTMLOption(c *Config) {
|
||||
|
|
@ -118,13 +118,13 @@ func WithXHTML() interface {
|
|||
}
|
||||
|
||||
// Unsafe is an option name used in WithUnsafe.
|
||||
const Unsafe renderer.OptionName = "Unsafe"
|
||||
const optUnsafe renderer.OptionName = "Unsafe"
|
||||
|
||||
type withUnsafe struct {
|
||||
}
|
||||
|
||||
func (o *withUnsafe) SetConfig(c *renderer.Config) {
|
||||
c.Options[Unsafe] = true
|
||||
c.Options[optUnsafe] = true
|
||||
}
|
||||
|
||||
func (o *withUnsafe) SetHTMLOption(c *Config) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue