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

Method htmlFindEnd

block.go:487–520  ·  view source on GitHub ↗
(tag string, data []byte)

Source from the content-addressed store, hash-verified

485}
486
487func (p *Markdown) htmlFindEnd(tag string, data []byte) int {
488 // assume data[0] == '<' && data[1] == '/' already tested
489 if tag == "hr" {
490 return 2
491 }
492 // check if tag is a match
493 closetag := []byte("</" + tag + ">")
494 if !bytes.HasPrefix(data, closetag) {
495 return 0
496 }
497 i := len(closetag)
498
499 // check that the rest of the line is blank
500 skip := 0
501 if skip = p.isEmpty(data[i:]); skip == 0 {
502 return 0
503 }
504 i += skip
505 skip = 0
506
507 if i >= len(data) {
508 return i
509 }
510
511 if p.extensions&LaxHTMLBlocks != 0 {
512 return i
513 }
514 if skip = p.isEmpty(data[i:]); skip == 0 {
515 // following line must be blank
516 return 0
517 }
518
519 return i + skip
520}
521
522func (*Markdown) isEmpty(data []byte) int {
523 // it is okay to call isEmpty on an empty buffer

Callers 1

htmlMethod · 0.95

Calls 1

isEmptyMethod · 0.95

Tested by

no test coverage detected