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

Method htmlHr

block.go:442–473  ·  view source on GitHub ↗

HR, which is the only self-closing block tag considered

(data []byte, doRender bool)

Source from the content-addressed store, hash-verified

440
441// HR, which is the only self-closing block tag considered
442func (p *Markdown) htmlHr(data []byte, doRender bool) int {
443 if len(data) < 4 {
444 return 0
445 }
446 if data[0] != '<' || (data[1] != 'h' && data[1] != 'H') || (data[2] != 'r' && data[2] != 'R') {
447 return 0
448 }
449 if data[3] != ' ' && data[3] != '/' && data[3] != '>' {
450 // not an <hr> tag after all; at least not a valid one
451 return 0
452 }
453 i := 3
454 for i < len(data) && data[i] != '>' && data[i] != '\n' {
455 i++
456 }
457 if i < len(data) && data[i] == '>' {
458 i++
459 if j := p.isEmpty(data[i:]); j > 0 {
460 size := i + j
461 if doRender {
462 // trim newlines
463 end := size
464 for end > 0 && data[end-1] == '\n' {
465 end--
466 }
467 finalizeHTMLBlock(p.addBlock(HTMLBlock, data[:end]))
468 }
469 return size
470 }
471 }
472 return 0
473}
474
475func (p *Markdown) htmlFindTag(data []byte) (string, bool) {
476 i := 0

Callers 1

htmlMethod · 0.95

Calls 3

isEmptyMethod · 0.95
addBlockMethod · 0.95
finalizeHTMLBlockFunction · 0.85

Tested by

no test coverage detected