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

Method block

block.go:37–198  ·  view source on GitHub ↗

Parse block-level data. Note: this function and many that it calls assume that the input buffer ends with a newline.

(data []byte)

Source from the content-addressed store, hash-verified

35// Note: this function and many that it calls assume that
36// the input buffer ends with a newline.
37func (p *Markdown) block(data []byte) {
38 // this is called recursively: enforce a maximum depth
39 if p.nesting >= p.maxNesting {
40 return
41 }
42 p.nesting++
43
44 // parse out one block-level construct at a time
45 for len(data) > 0 {
46 // prefixed heading:
47 //
48 // # Heading 1
49 // ## Heading 2
50 // ...
51 // ###### Heading 6
52 if p.isPrefixHeading(data) {
53 data = data[p.prefixHeading(data):]
54 continue
55 }
56
57 // block of preformatted HTML:
58 //
59 // <div>
60 // ...
61 // </div>
62 if data[0] == '<' {
63 if i := p.html(data, true); i > 0 {
64 data = data[i:]
65 continue
66 }
67 }
68
69 // title block
70 //
71 // % stuff
72 // % more stuff
73 // % even more stuff
74 if p.extensions&Titleblock != 0 {
75 if data[0] == '%' {
76 if i := p.titleBlock(data, true); i > 0 {
77 data = data[i:]
78 continue
79 }
80 }
81 }
82
83 // blank lines. note: returns the # of bytes to skip
84 if i := p.isEmpty(data); i > 0 {
85 data = data[i:]
86 continue
87 }
88
89 // indented code block:
90 //
91 // func max(a, b int) int {
92 // if a > b {
93 // return a
94 // }

Callers 4

ParseMethod · 0.95
parseRefsToASTMethod · 0.95
quoteMethod · 0.95
listItemMethod · 0.95

Calls 15

isPrefixHeadingMethod · 0.95
prefixHeadingMethod · 0.95
htmlMethod · 0.95
titleBlockMethod · 0.95
isEmptyMethod · 0.95
codePrefixMethod · 0.95
codeMethod · 0.95
fencedCodeBlockMethod · 0.95
isHRuleMethod · 0.95
addBlockMethod · 0.95
quotePrefixMethod · 0.95
quoteMethod · 0.95

Tested by

no test coverage detected