mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
commit
70a5404a11
11 changed files with 23 additions and 23 deletions
|
|
@ -303,11 +303,11 @@ func NewBlockquote() *Blockquote {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A List structr represents a list of Markdown text.
|
// A List struct represents a list of Markdown text.
|
||||||
type List struct {
|
type List struct {
|
||||||
BaseBlock
|
BaseBlock
|
||||||
|
|
||||||
// Marker is a markar character like '-', '+', ')' and '.'.
|
// Marker is a marker character like '-', '+', ')' and '.'.
|
||||||
Marker byte
|
Marker byte
|
||||||
|
|
||||||
// IsTight is a true if this list is a 'tight' list.
|
// IsTight is a true if this list is a 'tight' list.
|
||||||
|
|
@ -364,7 +364,7 @@ func NewList(marker byte) *List {
|
||||||
type ListItem struct {
|
type ListItem struct {
|
||||||
BaseBlock
|
BaseBlock
|
||||||
|
|
||||||
// Offset is an offset potision of this item.
|
// Offset is an offset position of this item.
|
||||||
Offset int
|
Offset int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ func NewText() *Text {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTextSegment returns a new Text node with the given source potision.
|
// NewTextSegment returns a new Text node with the given source position.
|
||||||
func NewTextSegment(v textm.Segment) *Text {
|
func NewTextSegment(v textm.Segment) *Text {
|
||||||
return &Text{
|
return &Text{
|
||||||
BaseInline: BaseInline{},
|
BaseInline: BaseInline{},
|
||||||
|
|
@ -467,7 +467,7 @@ type AutoLink struct {
|
||||||
// Inline implements Inline.Inline.
|
// Inline implements Inline.Inline.
|
||||||
func (n *AutoLink) Inline() {}
|
func (n *AutoLink) Inline() {}
|
||||||
|
|
||||||
// Dump implenets Node.Dump
|
// Dump implements Node.Dump
|
||||||
func (n *AutoLink) Dump(source []byte, level int) {
|
func (n *AutoLink) Dump(source []byte, level int) {
|
||||||
segment := n.value.Segment
|
segment := n.value.Segment
|
||||||
m := map[string]string{
|
m := map[string]string{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ type TaskCheckBox struct {
|
||||||
IsChecked bool
|
IsChecked bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump impelemtns Node.Dump.
|
// Dump implements Node.Dump.
|
||||||
func (n *TaskCheckBox) Dump(source []byte, level int) {
|
func (n *TaskCheckBox) Dump(source []byte, level int) {
|
||||||
m := map[string]string{
|
m := map[string]string{
|
||||||
"Checked": fmt.Sprintf("%v", n.IsChecked),
|
"Checked": fmt.Sprintf("%v", n.IsChecked),
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ func (o *withLinkifyAllowedProtocols) SetLinkifyOption(p *LinkifyConfig) {
|
||||||
p.AllowedProtocols = o.value
|
p.AllowedProtocols = o.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithLinkifyAllowedProtocols is a functional otpion that specify allowed
|
// WithLinkifyAllowedProtocols is a functional option that specify allowed
|
||||||
// protocols in autolinks. Each protocol must end with ':' like
|
// protocols in autolinks. Each protocol must end with ':' like
|
||||||
// 'http:' .
|
// 'http:' .
|
||||||
func WithLinkifyAllowedProtocols(value [][]byte) LinkifyOption {
|
func WithLinkifyAllowedProtocols(value [][]byte) LinkifyOption {
|
||||||
|
|
@ -82,7 +82,7 @@ func (o *withLinkifyURLRegexp) SetLinkifyOption(p *LinkifyConfig) {
|
||||||
p.URLRegexp = o.value
|
p.URLRegexp = o.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithLinkifyURLRegexp is a functional otpion that specify
|
// WithLinkifyURLRegexp is a functional option that specify
|
||||||
// a pattern of the URL including a protocol.
|
// a pattern of the URL including a protocol.
|
||||||
func WithLinkifyURLRegexp(value *regexp.Regexp) LinkifyOption {
|
func WithLinkifyURLRegexp(value *regexp.Regexp) LinkifyOption {
|
||||||
return &withLinkifyURLRegexp{
|
return &withLinkifyURLRegexp{
|
||||||
|
|
@ -90,7 +90,7 @@ func WithLinkifyURLRegexp(value *regexp.Regexp) LinkifyOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithLinkifyWWWRegexp is a functional otpion that specify
|
// WithLinkifyWWWRegexp is a functional option that specify
|
||||||
// a pattern of the URL without a protocol.
|
// a pattern of the URL without a protocol.
|
||||||
// This pattern must start with 'www.' .
|
// This pattern must start with 'www.' .
|
||||||
type withLinkifyWWWRegexp struct {
|
type withLinkifyWWWRegexp struct {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ type tableParagraphTransformer struct {
|
||||||
var defaultTableParagraphTransformer = &tableParagraphTransformer{}
|
var defaultTableParagraphTransformer = &tableParagraphTransformer{}
|
||||||
|
|
||||||
// NewTableParagraphTransformer returns a new ParagraphTransformer
|
// NewTableParagraphTransformer returns a new ParagraphTransformer
|
||||||
// that can transform pargraphs into tables.
|
// that can transform paragraphs into tables.
|
||||||
func NewTableParagraphTransformer() parser.ParagraphTransformer {
|
func NewTableParagraphTransformer() parser.ParagraphTransformer {
|
||||||
return defaultTableParagraphTransformer
|
return defaultTableParagraphTransformer
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,10 +253,10 @@ type typographer struct {
|
||||||
options []TypographerOption
|
options []TypographerOption
|
||||||
}
|
}
|
||||||
|
|
||||||
// Typographer is an extension that repalace punctuations with typographic entities.
|
// Typographer is an extension that replaces punctuations with typographic entities.
|
||||||
var Typographer = &typographer{}
|
var Typographer = &typographer{}
|
||||||
|
|
||||||
// NewTypographer returns a new Entender that repalace punctuations with typographic entities.
|
// NewTypographer returns a new Extender that replaces punctuations with typographic entities.
|
||||||
func NewTypographer(opts ...TypographerOption) goldmark.Extender {
|
func NewTypographer(opts ...TypographerOption) goldmark.Extender {
|
||||||
return &typographer{
|
return &typographer{
|
||||||
options: opts,
|
options: opts,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// A DelimiterProcessor interface provides a set of functions about
|
// A DelimiterProcessor interface provides a set of functions about
|
||||||
// Deliiter nodes.
|
// Delimiter nodes.
|
||||||
type DelimiterProcessor interface {
|
type DelimiterProcessor interface {
|
||||||
// IsDelimiter returns true if given character is a delimiter, otherwise false.
|
// IsDelimiter returns true if given character is a delimiter, otherwise false.
|
||||||
IsDelimiter(byte) bool
|
IsDelimiter(byte) bool
|
||||||
|
|
@ -38,7 +38,7 @@ type Delimiter struct {
|
||||||
// See https://spec.commonmark.org/0.29/#can-open-emphasis for details.
|
// See https://spec.commonmark.org/0.29/#can-open-emphasis for details.
|
||||||
CanClose bool
|
CanClose bool
|
||||||
|
|
||||||
// Length is a remaining length of this delmiter.
|
// Length is a remaining length of this delimiter.
|
||||||
Length int
|
Length int
|
||||||
|
|
||||||
// OriginalLength is a original length of this delimiter.
|
// OriginalLength is a original length of this delimiter.
|
||||||
|
|
|
||||||
|
|
@ -459,7 +459,7 @@ type Parser interface {
|
||||||
// Parse parses the given Markdown text into AST nodes.
|
// Parse parses the given Markdown text into AST nodes.
|
||||||
Parse(reader text.Reader, opts ...ParseOption) ast.Node
|
Parse(reader text.Reader, opts ...ParseOption) ast.Node
|
||||||
|
|
||||||
// AddOption adds the given option to thie parser.
|
// AddOption adds the given option to this parser.
|
||||||
AddOptions(...Option)
|
AddOptions(...Option)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,7 +505,7 @@ type BlockParser interface {
|
||||||
// Close will be called when the parser returns Close.
|
// Close will be called when the parser returns Close.
|
||||||
Close(node ast.Node, reader text.Reader, pc Context)
|
Close(node ast.Node, reader text.Reader, pc Context)
|
||||||
|
|
||||||
// CanInterruptParagraph returns true if the parser can interrupt pargraphs,
|
// CanInterruptParagraph returns true if the parser can interrupt paragraphs,
|
||||||
// otherwise false.
|
// otherwise false.
|
||||||
CanInterruptParagraph() bool
|
CanInterruptParagraph() bool
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -660,13 +660,13 @@ func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Writer interface wirtes textual contents to a writer.
|
// A Writer interface writes textual contents to a writer.
|
||||||
type Writer interface {
|
type Writer interface {
|
||||||
// Write writes the given source to writer with resolving references and unescaping
|
// Write writes the given source to writer with resolving references and unescaping
|
||||||
// backslash escaped characters.
|
// backslash escaped characters.
|
||||||
Write(writer util.BufWriter, source []byte)
|
Write(writer util.BufWriter, source []byte)
|
||||||
|
|
||||||
// RawWrite wirtes the given source to writer without resolving references and
|
// RawWrite writes the given source to writer without resolving references and
|
||||||
// unescaping backslash escaped characters.
|
// unescaping backslash escaped characters.
|
||||||
RawWrite(writer util.BufWriter, source []byte)
|
RawWrite(writer util.BufWriter, source []byte)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
var space = []byte(" ")
|
var space = []byte(" ")
|
||||||
|
|
||||||
// A Segment struct holds information about source potisions.
|
// A Segment struct holds information about source positions.
|
||||||
type Segment struct {
|
type Segment struct {
|
||||||
// Start is a start position of the segment.
|
// Start is a start position of the segment.
|
||||||
Start int
|
Start int
|
||||||
|
|
@ -197,7 +197,7 @@ func (s *Segments) Sliced(lo, hi int) []Segment {
|
||||||
return s.values[lo:hi]
|
return s.values[lo:hi]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear delete all element of the collction.
|
// Clear delete all element of the collection.
|
||||||
func (s *Segments) Clear() {
|
func (s *Segments) Clear() {
|
||||||
s.values = nil
|
s.values = nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ func (b *CopyOnWriteBuffer) IsCopied() bool {
|
||||||
return b.copied
|
return b.copied
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEscapedPunctuation returns true if caracter at a given index i
|
// IsEscapedPunctuation returns true if character at a given index i
|
||||||
// is an escaped punctuation, otherwise false.
|
// is an escaped punctuation, otherwise false.
|
||||||
func IsEscapedPunctuation(source []byte, i int) bool {
|
func IsEscapedPunctuation(source []byte, i int) bool {
|
||||||
return source[i] == '\\' && i < len(source)-1 && IsPunct(source[i+1])
|
return source[i] == '\\' && i < len(source)-1 && IsPunct(source[i+1])
|
||||||
|
|
@ -229,7 +229,7 @@ func IndentWidth(bs []byte, currentPos int) (width, pos int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FirstNonSpacePosition returns a potisoin line that is a first nonspace
|
// FirstNonSpacePosition returns a position line that is a first nonspace
|
||||||
// character.
|
// character.
|
||||||
func FirstNonSpacePosition(bs []byte) int {
|
func FirstNonSpacePosition(bs []byte) int {
|
||||||
i := 0
|
i := 0
|
||||||
|
|
@ -589,7 +589,7 @@ var htmlSpace = []byte("%20")
|
||||||
// 2. resolve numeric references
|
// 2. resolve numeric references
|
||||||
// 3. resolve entity references
|
// 3. resolve entity references
|
||||||
//
|
//
|
||||||
// URL encoded values (%xx) are keeped as is.
|
// URL encoded values (%xx) are kept as is.
|
||||||
func URLEscape(v []byte, resolveReference bool) []byte {
|
func URLEscape(v []byte, resolveReference bool) []byte {
|
||||||
if resolveReference {
|
if resolveReference {
|
||||||
v = UnescapePunctuations(v)
|
v = UnescapePunctuations(v)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue