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

Function emphasis

inline.go:86–129  ·  view source on GitHub ↗

single and double emphasis parsing

(p *Markdown, data []byte, offset int)

Source from the content-addressed store, hash-verified

84
85// single and double emphasis parsing
86func emphasis(p *Markdown, data []byte, offset int) (int, *Node) {
87 data = data[offset:]
88 c := data[0]
89
90 if len(data) > 2 && data[1] != c {
91 // whitespace cannot follow an opening emphasis;
92 // strikethrough only takes two characters '~~'
93 if c == '~' || isspace(data[1]) {
94 return 0, nil
95 }
96 ret, node := helperEmphasis(p, data[1:], c)
97 if ret == 0 {
98 return 0, nil
99 }
100
101 return ret + 1, node
102 }
103
104 if len(data) > 3 && data[1] == c && data[2] != c {
105 if isspace(data[2]) {
106 return 0, nil
107 }
108 ret, node := helperDoubleEmphasis(p, data[2:], c)
109 if ret == 0 {
110 return 0, nil
111 }
112
113 return ret + 2, node
114 }
115
116 if len(data) > 4 && data[1] == c && data[2] == c && data[3] != c {
117 if c == '~' || isspace(data[3]) {
118 return 0, nil
119 }
120 ret, node := helperTripleEmphasis(p, data, 3, c)
121 if ret == 0 {
122 return 0, nil
123 }
124
125 return ret + 3, node
126 }
127
128 return 0, nil
129}
130
131func codeSpan(p *Markdown, data []byte, offset int) (int, *Node) {
132 data = data[offset:]

Callers

nothing calls this directly

Calls 4

isspaceFunction · 0.85
helperEmphasisFunction · 0.85
helperDoubleEmphasisFunction · 0.85
helperTripleEmphasisFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…