MCPcopy
hub / github.com/russross/blackfriday / inline

Method inline

inline.go:49–83  ·  view source on GitHub ↗

Functions to parse text within a block Each function returns the number of chars taken care of data is the complete block being rendered offset is the number of valid chars before the current cursor

(currBlock *Node, data []byte)

Source from the content-addressed store, hash-verified

47// offset is the number of valid chars before the current cursor
48
49func (p *Markdown) inline(currBlock *Node, data []byte) {
50 // handlers might call us recursively: enforce a maximum depth
51 if p.nesting >= p.maxNesting || len(data) == 0 {
52 return
53 }
54 p.nesting++
55 beg, end := 0, 0
56 for end < len(data) {
57 handler := p.inlineCallback[data[end]]
58 if handler != nil {
59 if consumed, node := handler(p, data, end); consumed == 0 {
60 // No action from the callback.
61 end++
62 } else {
63 // Copy inactive chars into the output.
64 currBlock.AppendChild(text(data[beg:end]))
65 if node != nil {
66 currBlock.AppendChild(node)
67 }
68 // Skip past whatever the callback used.
69 beg = end + consumed
70 end = beg
71 }
72 } else {
73 end++
74 }
75 }
76 if beg < len(data) {
77 if data[end-1] == '\n' {
78 end--
79 }
80 currBlock.AppendChild(text(data[beg:end]))
81 }
82 p.nesting--
83}
84
85// single and double emphasis parsing
86func emphasis(p *Markdown, data []byte, offset int) (int, *Node) {

Callers 6

ParseMethod · 0.95
parseRefsToASTMethod · 0.95
linkFunction · 0.80
helperEmphasisFunction · 0.80
helperDoubleEmphasisFunction · 0.80
helperTripleEmphasisFunction · 0.80

Calls 2

textFunction · 0.85
AppendChildMethod · 0.80

Tested by

no test coverage detected