Source File
code_span.go
Belonging Package
github.com/yuin/goldmark/parser
package parser
import (
)
type codeSpanParser struct {
}
var defaultCodeSpanParser = &codeSpanParser{}
func () InlineParser {
return defaultCodeSpanParser
}
func ( *codeSpanParser) () []byte {
return []byte{'`'}
}
func ( *codeSpanParser) ( ast.Node, text.Reader, Context) ast.Node {
, := .PeekLine()
:= 0
for ; < len() && [] == '`'; ++ {
}
.Advance()
, := .Position()
:= ast.NewCodeSpan()
for {
, := .PeekLine()
if == nil {
.SetPosition(, )
return ast.NewTextSegment(.WithStop(.Start + ))
}
for := 0; < len(); ++ {
:= []
if == '`' {
:=
for ; < len() && [] == '`'; ++ {
}
:= -
if == && ( >= len() || [] != '`') {
= .WithStop(.Start + - )
if !.IsEmpty() {
.AppendChild(, ast.NewRawTextSegment())
}
.Advance()
goto
}
}
}
if !util.IsBlank() {
.AppendChild(, ast.NewRawTextSegment())
}
.AdvanceLine()
}
:
:= .FirstChild().(*ast.Text).Segment
:= true
if !(!.IsEmpty() && .Source()[.Start] == ' ') {
= false
}
= .LastChild().(*ast.Text).Segment
if !(!.IsEmpty() && .Source()[.Stop-1] == ' ') {
= false
}
if {
:= .FirstChild().(*ast.Text)
:= .Segment
.Segment = .WithStart(.Start + 1)
= .LastChild().(*ast.Text)
= .LastChild().(*ast.Text).Segment
.Segment = .WithStop(.Stop - 1)
}
}
return
![]() |
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. |