WIP update deps, sql builder instead of jet
This commit is contained in:
81
vendor/github.com/gomarkdown/markdown/parser/block.go
generated
vendored
81
vendor/github.com/gomarkdown/markdown/parser/block.go
generated
vendored
@@ -951,8 +951,6 @@ func (p *Parser) fencedCodeBlock(data []byte, doRender bool) int {
|
||||
work.WriteByte('\n')
|
||||
|
||||
for {
|
||||
// safe to assume beg < len(data)
|
||||
|
||||
// check for the end of the code block
|
||||
fenceEnd, _ := isFenceLine(data[beg:], nil, marker)
|
||||
if fenceEnd != 0 {
|
||||
@@ -969,48 +967,47 @@ func (p *Parser) fencedCodeBlock(data []byte, doRender bool) int {
|
||||
}
|
||||
|
||||
// verbatim copy to the working buffer
|
||||
if doRender {
|
||||
work.Write(data[beg:end])
|
||||
}
|
||||
work.Write(data[beg:end])
|
||||
beg = end
|
||||
}
|
||||
|
||||
if doRender {
|
||||
codeBlock := &ast.CodeBlock{
|
||||
IsFenced: true,
|
||||
}
|
||||
codeBlock.Content = work.Bytes() // TODO: get rid of temp buffer
|
||||
if !doRender {
|
||||
return beg
|
||||
}
|
||||
codeBlock := &ast.CodeBlock{
|
||||
IsFenced: true,
|
||||
}
|
||||
codeBlock.Content = work.Bytes() // TODO: get rid of temp buffer
|
||||
|
||||
if p.extensions&Mmark == 0 {
|
||||
p.AddBlock(codeBlock)
|
||||
finalizeCodeBlock(codeBlock)
|
||||
return beg
|
||||
}
|
||||
|
||||
// Check for caption and if found make it a figure.
|
||||
if captionContent, id, consumed := p.caption(data[beg:], []byte(captionFigure)); consumed > 0 {
|
||||
figure := &ast.CaptionFigure{}
|
||||
caption := &ast.Caption{}
|
||||
figure.HeadingID = id
|
||||
p.Inline(caption, captionContent)
|
||||
|
||||
p.AddBlock(figure)
|
||||
codeBlock.AsLeaf().Attribute = figure.AsContainer().Attribute
|
||||
p.addChild(codeBlock)
|
||||
finalizeCodeBlock(codeBlock)
|
||||
p.addChild(caption)
|
||||
p.Finalize(figure)
|
||||
|
||||
beg += consumed
|
||||
|
||||
return beg
|
||||
}
|
||||
|
||||
// Still here, normal block
|
||||
if p.extensions&Mmark == 0 {
|
||||
p.AddBlock(codeBlock)
|
||||
finalizeCodeBlock(codeBlock)
|
||||
return beg
|
||||
}
|
||||
|
||||
// Check for caption and if found make it a figure.
|
||||
if captionContent, id, consumed := p.caption(data[beg:], []byte(captionFigure)); consumed > 0 {
|
||||
figure := &ast.CaptionFigure{}
|
||||
caption := &ast.Caption{}
|
||||
figure.HeadingID = id
|
||||
p.Inline(caption, captionContent)
|
||||
|
||||
p.AddBlock(figure)
|
||||
codeBlock.AsLeaf().Attribute = figure.AsContainer().Attribute
|
||||
p.addChild(codeBlock)
|
||||
finalizeCodeBlock(codeBlock)
|
||||
p.addChild(caption)
|
||||
p.Finalize(figure)
|
||||
|
||||
beg += consumed
|
||||
|
||||
return beg
|
||||
}
|
||||
|
||||
// Still here, normal block
|
||||
p.AddBlock(codeBlock)
|
||||
finalizeCodeBlock(codeBlock)
|
||||
|
||||
return beg
|
||||
}
|
||||
|
||||
@@ -1353,6 +1350,7 @@ func finalizeList(list *ast.List) {
|
||||
// Parse a single list item.
|
||||
// Assumes initial prefix is already removed if this is a sublist.
|
||||
func (p *Parser) listItem(data []byte, flags *ast.ListType) int {
|
||||
isDefinitionList := *flags&ast.ListTypeDefinition != 0
|
||||
// keep track of the indentation of the first line
|
||||
itemIndent := 0
|
||||
if data[0] == '\t' {
|
||||
@@ -1385,7 +1383,7 @@ func (p *Parser) listItem(data []byte, flags *ast.ListType) int {
|
||||
}
|
||||
if i == 0 {
|
||||
// if in definition list, set term flag and continue
|
||||
if *flags&ast.ListTypeDefinition != 0 {
|
||||
if isDefinitionList {
|
||||
*flags |= ast.ListTypeTerm
|
||||
} else {
|
||||
return 0
|
||||
@@ -1446,7 +1444,14 @@ gatherlines:
|
||||
|
||||
// If there is a fence line (marking starting of a code block)
|
||||
// without indent do not process it as part of the list.
|
||||
if p.extensions&FencedCode != 0 {
|
||||
//
|
||||
// does not apply for definition lists because it causes infinite
|
||||
// loop if text before defintion term is fenced code block start
|
||||
// marker but not part of actual fenced code block
|
||||
// for defnition lists we're called after parsing fence code blocks
|
||||
// so we kno this cannot be a fenced block
|
||||
// https://github.com/gomarkdown/markdown/issues/326
|
||||
if !isDefinitionList && p.extensions&FencedCode != 0 {
|
||||
fenceLineEnd, _ := isFenceLine(chunk, nil, "")
|
||||
if fenceLineEnd > 0 && indent == 0 {
|
||||
*flags |= ast.ListItemEndOfList
|
||||
|
||||
27
vendor/github.com/gomarkdown/markdown/parser/inline.go
generated
vendored
27
vendor/github.com/gomarkdown/markdown/parser/inline.go
generated
vendored
@@ -271,7 +271,7 @@ func maybeInlineFootnoteOrSuper(p *Parser, data []byte, offset int) (int, ast.No
|
||||
// '[': parse a link or an image or a footnote or a citation
|
||||
func link(p *Parser, data []byte, offset int) (int, ast.Node) {
|
||||
// no links allowed inside regular links, footnote, and deferred footnotes
|
||||
if p.insideLink && (offset > 0 && data[offset-1] == '[' || len(data)-1 > offset && data[offset+1] == '^') {
|
||||
if p.InsideLink && (offset > 0 && data[offset-1] == '[' || len(data)-1 > offset && data[offset+1] == '^') {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
@@ -362,25 +362,27 @@ func link(p *Parser, data []byte, offset int) (int, ast.Node) {
|
||||
linkB := i
|
||||
brace := 0
|
||||
|
||||
var c byte
|
||||
// look for link end: ' " )
|
||||
findlinkend:
|
||||
for i < len(data) {
|
||||
c = data[i]
|
||||
switch {
|
||||
case data[i] == '\\':
|
||||
case c == '\\':
|
||||
i += 2
|
||||
|
||||
case data[i] == '(':
|
||||
case c == '(':
|
||||
brace++
|
||||
i++
|
||||
|
||||
case data[i] == ')':
|
||||
case c == ')':
|
||||
if brace <= 0 {
|
||||
break findlinkend
|
||||
}
|
||||
brace--
|
||||
i++
|
||||
|
||||
case data[i] == '\'' || data[i] == '"':
|
||||
case c == '\'' || c == '"':
|
||||
break findlinkend
|
||||
|
||||
default:
|
||||
@@ -402,14 +404,15 @@ func link(p *Parser, data []byte, offset int) (int, ast.Node) {
|
||||
|
||||
findtitleend:
|
||||
for i < len(data) {
|
||||
c = data[i]
|
||||
switch {
|
||||
case data[i] == '\\':
|
||||
case c == '\\':
|
||||
i++
|
||||
|
||||
case data[i] == data[titleB-1]: // matching title delimiter
|
||||
case c == data[titleB-1]: // matching title delimiter
|
||||
titleEndCharFound = true
|
||||
|
||||
case titleEndCharFound && data[i] == ')':
|
||||
case titleEndCharFound && c == ')':
|
||||
break findtitleend
|
||||
}
|
||||
i++
|
||||
@@ -619,10 +622,10 @@ func link(p *Parser, data []byte, offset int) (int, ast.Node) {
|
||||
} else {
|
||||
// links cannot contain other links, so turn off link parsing
|
||||
// temporarily and recurse
|
||||
insideLink := p.insideLink
|
||||
p.insideLink = true
|
||||
InsideLink := p.InsideLink
|
||||
p.InsideLink = true
|
||||
p.Inline(link, data[1:txtE])
|
||||
p.insideLink = insideLink
|
||||
p.InsideLink = InsideLink
|
||||
}
|
||||
return i, link
|
||||
|
||||
@@ -857,7 +860,7 @@ const shortestPrefix = 6 // len("ftp://"), the shortest of the above
|
||||
|
||||
func maybeAutoLink(p *Parser, data []byte, offset int) (int, ast.Node) {
|
||||
// quick check to rule out most false hits
|
||||
if p.insideLink || len(data) < offset+shortestPrefix {
|
||||
if p.InsideLink || len(data) < offset+shortestPrefix {
|
||||
return 0, nil
|
||||
}
|
||||
for _, prefix := range protocolPrefixes {
|
||||
|
||||
4
vendor/github.com/gomarkdown/markdown/parser/parser.go
generated
vendored
4
vendor/github.com/gomarkdown/markdown/parser/parser.go
generated
vendored
@@ -103,7 +103,7 @@ type Parser struct {
|
||||
inlineCallback [256]InlineParser
|
||||
nesting int
|
||||
maxNesting int
|
||||
insideLink bool
|
||||
InsideLink bool
|
||||
indexCnt int // incremented after every index
|
||||
|
||||
// Footnotes need to be ordered as well as available to quickly check for
|
||||
@@ -143,7 +143,7 @@ func NewWithExtensions(extension Extensions) *Parser {
|
||||
refs: make(map[string]*reference),
|
||||
refsRecord: make(map[string]struct{}),
|
||||
maxNesting: 64,
|
||||
insideLink: false,
|
||||
InsideLink: false,
|
||||
Doc: &ast.Document{},
|
||||
extensions: extension,
|
||||
allClosed: true,
|
||||
|
||||
Reference in New Issue
Block a user