Source File
inline.go
Belonging Package
github.com/yuin/goldmark/ast
package ast
import (
textm
)
type BaseInline struct {
BaseNode
}
func ( *BaseInline) () NodeType {
return TypeInline
}
func ( *BaseInline) () bool {
return false
}
func ( *BaseInline) () bool {
panic("can not call with inline nodes.")
}
func ( *BaseInline) ( bool) {
panic("can not call with inline nodes.")
}
func ( *BaseInline) () *textm.Segments {
panic("can not call with inline nodes.")
}
func ( *BaseInline) ( *textm.Segments) {
panic("can not call with inline nodes.")
}
type Text struct {
Segment textm.Segment
flags uint8
}
const (
textSoftLineBreak = 1 << iota
textHardLineBreak
textRaw
textCode
)
func ( uint8) string {
:= []string{}
if &textSoftLineBreak != 0 {
= append(, "SoftLineBreak")
}
if &textHardLineBreak != 0 {
= append(, "HardLineBreak")
}
if &textRaw != 0 {
= append(, "Raw")
}
if &textCode != 0 {
= append(, "Code")
}
return strings.Join(, ", ")
}
func ( *Text) () {
}
func ( *Text) () bool {
return .flags&textSoftLineBreak != 0
}
func ( *Text) ( bool) {
if {
.flags |= textSoftLineBreak
} else {
.flags = .flags &^ textHardLineBreak
}
}
func ( *Text) () bool {
return .flags&textHardLineBreak != 0
}
func ( *Text) ( bool) {
if {
.flags |= textHardLineBreak
} else {
.flags = .flags &^ textHardLineBreak
}
}
func ( *Text) ( Node, []byte) bool {
, := .(*Text)
if ! {
return false
}
if .Segment.Stop != .Segment.Start || .Segment.Padding != 0 || [.Segment.Stop-1] == '\n' || .IsRaw() != .IsRaw() {
return false
}
.Segment.Stop = .Segment.Stop
.SetSoftLineBreak(.SoftLineBreak())
.SetHardLineBreak(.HardLineBreak())
return true
}
var KindText = NewNodeKind("Text")
func () *Text {
return &Text{
BaseInline: BaseInline{},
}
}
func ( textm.Segment) *Text {
return &Text{
BaseInline: BaseInline{},
Segment: ,
}
}
func ( textm.Segment) *Text {
:= &Text{
BaseInline: BaseInline{},
Segment: ,
}
.SetRaw(true)
return
}
func ( Node, textm.Segment) {
:= .LastChild()
, := .(*Text)
if && .Segment.Stop == .Start && !.SoftLineBreak() {
.Segment = .Segment.WithStop(.Stop)
} else {
.AppendChild(, NewTextSegment())
}
}
func ( Node, Node, textm.Segment) {
:= .PreviousSibling()
if , := .(*Text); && .Segment.Stop == .Start && !.SoftLineBreak() {
.Segment = .Segment.WithStop(.Stop)
.RemoveChild(, )
} else {
.ReplaceChild(, , NewTextSegment())
}
}
func ( *String) () {
}
var KindString = NewNodeKind("String")
func ( *String) () NodeKind {
return KindString
}
type CodeSpan struct {
BaseInline
}
func ( *CodeSpan) () {
}
var KindCodeSpan = NewNodeKind("CodeSpan")
func ( *CodeSpan) () NodeKind {
return KindCodeSpan
}
func () *CodeSpan {
return &CodeSpan{
BaseInline: BaseInline{},
}
}
type Emphasis struct {
BaseInline
var KindEmphasis = NewNodeKind("Emphasis")
func ( *Emphasis) () NodeKind {
return KindEmphasis
}
func ( int) *Emphasis {
return &Emphasis{
BaseInline: BaseInline{},
Level: ,
}
}
type baseLink struct {
BaseInline
func ( *baseLink) () {
}
var KindLink = NewNodeKind("Link")
func () *Link {
:= &Link{
baseLink: baseLink{
BaseInline: BaseInline{},
},
}
return
}
var KindImage = NewNodeKind("Image")
func ( *Link) *Image {
:= &Image{
baseLink: baseLink{
BaseInline: BaseInline{},
},
}
.Destination = .Destination
.Title = .Title
for := .FirstChild(); != nil; {
:= .NextSibling()
.RemoveChild(, )
.AppendChild(, )
=
}
return
}
type AutoLinkType int
type AutoLink struct {
func ( *AutoLink) () {}
var KindAutoLink = NewNodeKind("AutoLink")
func ( *AutoLink) () NodeKind {
return KindAutoLink
}
func ( AutoLinkType, *Text) *AutoLink {
return &AutoLink{
BaseInline: BaseInline{},
value: ,
AutoLinkType: ,
}
}
type RawHTML struct {
BaseInline
Segments *textm.Segments
}
func ( *RawHTML) () {}
var KindRawHTML = NewNodeKind("RawHTML")
func ( *RawHTML) () NodeKind {
return KindRawHTML
}
func () *RawHTML {
return &RawHTML{
Segments: textm.NewSegments(),
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |