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

Method parseRefsToAST

markdown.go:421–458  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

419}
420
421func (p *Markdown) parseRefsToAST() {
422 if p.extensions&Footnotes == 0 || len(p.notes) == 0 {
423 return
424 }
425 p.tip = p.doc
426 block := p.addBlock(List, nil)
427 block.IsFootnotesList = true
428 block.ListFlags = ListTypeOrdered
429 flags := ListItemBeginningOfList
430 // Note: this loop is intentionally explicit, not range-form. This is
431 // because the body of the loop will append nested footnotes to p.notes and
432 // we need to process those late additions. Range form would only walk over
433 // the fixed initial set.
434 for i := 0; i < len(p.notes); i++ {
435 ref := p.notes[i]
436 p.addExistingChild(ref.footnote, 0)
437 block := ref.footnote
438 block.ListFlags = flags | ListTypeOrdered
439 block.RefLink = ref.link
440 if ref.hasBlock {
441 flags |= ListItemContainsBlock
442 p.block(ref.title)
443 } else {
444 p.inline(block, ref.title)
445 }
446 flags &^= ListItemBeginningOfList | ListItemContainsBlock
447 }
448 above := block.Parent
449 finalizeList(block)
450 p.tip = above
451 block.Walk(func(node *Node, entering bool) WalkStatus {
452 if node.Type == Paragraph || node.Type == Heading {
453 p.inline(node, node.content)
454 node.content = nil
455 }
456 return GoToNext
457 })
458}
459
460//
461// Link references

Callers 1

ParseMethod · 0.95

Calls 6

addBlockMethod · 0.95
addExistingChildMethod · 0.95
blockMethod · 0.95
inlineMethod · 0.95
finalizeListFunction · 0.85
WalkMethod · 0.80

Tested by

no test coverage detected