Update godeps for etcd 3.0.4
This commit is contained in:
193
vendor/github.com/russross/blackfriday/block.go
generated
vendored
193
vendor/github.com/russross/blackfriday/block.go
generated
vendored
@@ -166,6 +166,21 @@ func (p *parser) block(out *bytes.Buffer, data []byte) {
|
||||
continue
|
||||
}
|
||||
|
||||
// definition lists:
|
||||
//
|
||||
// Term 1
|
||||
// : Definition a
|
||||
// : Definition b
|
||||
//
|
||||
// Term 2
|
||||
// : Definition c
|
||||
if p.flags&EXTENSION_DEFINITION_LISTS != 0 {
|
||||
if p.dliPrefix(data) > 0 {
|
||||
data = data[p.list(out, data, LIST_TYPE_DEFINITION):]
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// anything else must look like a normal paragraph
|
||||
// note: this finds underlined headers, too
|
||||
data = data[p.paragraph(out, data):]
|
||||
@@ -196,11 +211,8 @@ func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int {
|
||||
for level < 6 && data[level] == '#' {
|
||||
level++
|
||||
}
|
||||
i, end := 0, 0
|
||||
for i = level; data[i] == ' '; i++ {
|
||||
}
|
||||
for end = i; data[end] != '\n'; end++ {
|
||||
}
|
||||
i := skipChar(data, level, ' ')
|
||||
end := skipUntilChar(data, i, '\n')
|
||||
skip := end
|
||||
id := ""
|
||||
if p.flags&EXTENSION_HEADER_IDS != 0 {
|
||||
@@ -221,6 +233,9 @@ func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int {
|
||||
}
|
||||
}
|
||||
for end > 0 && data[end-1] == '#' {
|
||||
if isBackslashEscaped(data, end-1) {
|
||||
break
|
||||
}
|
||||
end--
|
||||
}
|
||||
for end > 0 && data[end-1] == ' ' {
|
||||
@@ -242,13 +257,8 @@ func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int {
|
||||
func (p *parser) isUnderlinedHeader(data []byte) int {
|
||||
// test of level 1 header
|
||||
if data[0] == '=' {
|
||||
i := 1
|
||||
for data[i] == '=' {
|
||||
i++
|
||||
}
|
||||
for data[i] == ' ' {
|
||||
i++
|
||||
}
|
||||
i := skipChar(data, 1, '=')
|
||||
i = skipChar(data, i, ' ')
|
||||
if data[i] == '\n' {
|
||||
return 1
|
||||
} else {
|
||||
@@ -258,13 +268,8 @@ func (p *parser) isUnderlinedHeader(data []byte) int {
|
||||
|
||||
// test of level 2 header
|
||||
if data[0] == '-' {
|
||||
i := 1
|
||||
for data[i] == '-' {
|
||||
i++
|
||||
}
|
||||
for data[i] == ' ' {
|
||||
i++
|
||||
}
|
||||
i := skipChar(data, 1, '-')
|
||||
i = skipChar(data, i, ' ')
|
||||
if data[i] == '\n' {
|
||||
return 2
|
||||
} else {
|
||||
@@ -394,23 +399,7 @@ func (p *parser) html(out *bytes.Buffer, data []byte, doRender bool) int {
|
||||
|
||||
// HTML comment, lax form
|
||||
func (p *parser) htmlComment(out *bytes.Buffer, data []byte, doRender bool) int {
|
||||
if data[0] != '<' || data[1] != '!' || data[2] != '-' || data[3] != '-' {
|
||||
return 0
|
||||
}
|
||||
|
||||
i := 5
|
||||
|
||||
// scan for an end-of-comment marker, across lines if necessary
|
||||
for i < len(data) && !(data[i-2] == '-' && data[i-1] == '-' && data[i] == '>') {
|
||||
i++
|
||||
}
|
||||
i++
|
||||
|
||||
// no end-of-comment marker
|
||||
if i >= len(data) {
|
||||
return 0
|
||||
}
|
||||
|
||||
i := p.inlineHtmlComment(out, data)
|
||||
// needs to end with a blank line
|
||||
if j := p.isEmpty(data[i:]); j > 0 {
|
||||
size := i + j
|
||||
@@ -424,7 +413,6 @@ func (p *parser) htmlComment(out *bytes.Buffer, data []byte, doRender bool) int
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -468,7 +456,7 @@ func (p *parser) htmlFindTag(data []byte) (string, bool) {
|
||||
i++
|
||||
}
|
||||
key := string(data[:i])
|
||||
if blockTags[key] {
|
||||
if _, ok := blockTags[key]; ok {
|
||||
return key, true
|
||||
}
|
||||
return "", false
|
||||
@@ -593,10 +581,7 @@ func (p *parser) isFencedCode(data []byte, syntax **string, oldmarker string) (s
|
||||
|
||||
if syntax != nil {
|
||||
syn := 0
|
||||
|
||||
for i < len(data) && data[i] == ' ' {
|
||||
i++
|
||||
}
|
||||
i = skipChar(data, i, ' ')
|
||||
|
||||
if i >= len(data) {
|
||||
return
|
||||
@@ -640,9 +625,7 @@ func (p *parser) isFencedCode(data []byte, syntax **string, oldmarker string) (s
|
||||
*syntax = &language
|
||||
}
|
||||
|
||||
for i < len(data) && data[i] == ' ' {
|
||||
i++
|
||||
}
|
||||
i = skipChar(data, i, ' ')
|
||||
if i >= len(data) || data[i] != '\n' {
|
||||
return
|
||||
}
|
||||
@@ -671,11 +654,7 @@ func (p *parser) fencedCode(out *bytes.Buffer, data []byte, doRender bool) int {
|
||||
}
|
||||
|
||||
// copy the current line
|
||||
end := beg
|
||||
for end < len(data) && data[end] != '\n' {
|
||||
end++
|
||||
}
|
||||
end++
|
||||
end := skipUntilChar(data, beg, '\n') + 1
|
||||
|
||||
// did we reach the end of the buffer without a closing marker?
|
||||
if end >= len(data) {
|
||||
@@ -733,7 +712,7 @@ func (p *parser) table(out *bytes.Buffer, data []byte) int {
|
||||
return i
|
||||
}
|
||||
|
||||
// check if the specified position is preceeded by an odd number of backslashes
|
||||
// check if the specified position is preceded by an odd number of backslashes
|
||||
func isBackslashEscaped(data []byte, i int) bool {
|
||||
backslashes := 0
|
||||
for i-backslashes-1 >= 0 && data[i-backslashes-1] == '\\' {
|
||||
@@ -778,9 +757,7 @@ func (p *parser) tableHeader(out *bytes.Buffer, data []byte) (size int, columns
|
||||
if data[i] == '|' && !isBackslashEscaped(data, i) {
|
||||
i++
|
||||
}
|
||||
for data[i] == ' ' {
|
||||
i++
|
||||
}
|
||||
i = skipChar(data, i, ' ')
|
||||
|
||||
// each column header is of form: / *:?-+:? *|/ with # dashes + # colons >= 3
|
||||
// and trailing | optional on last column
|
||||
@@ -914,13 +891,35 @@ func (p *parser) quotePrefix(data []byte) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// blockquote ends with at least one blank line
|
||||
// followed by something without a blockquote prefix
|
||||
func (p *parser) terminateBlockquote(data []byte, beg, end int) bool {
|
||||
if p.isEmpty(data[beg:]) <= 0 {
|
||||
return false
|
||||
}
|
||||
if end >= len(data) {
|
||||
return true
|
||||
}
|
||||
return p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0
|
||||
}
|
||||
|
||||
// parse a blockquote fragment
|
||||
func (p *parser) quote(out *bytes.Buffer, data []byte) int {
|
||||
var raw bytes.Buffer
|
||||
beg, end := 0, 0
|
||||
for beg < len(data) {
|
||||
end = beg
|
||||
// Step over whole lines, collecting them. While doing that, check for
|
||||
// fenced code and if one's found, incorporate it altogether,
|
||||
// irregardless of any contents inside it
|
||||
for data[end] != '\n' {
|
||||
if p.flags&EXTENSION_FENCED_CODE != 0 {
|
||||
if i := p.fencedCode(out, data[end:], false); i > 0 {
|
||||
// -1 to compensate for the extra end++ after the loop:
|
||||
end += i - 1
|
||||
break
|
||||
}
|
||||
}
|
||||
end++
|
||||
}
|
||||
end++
|
||||
@@ -928,11 +927,7 @@ func (p *parser) quote(out *bytes.Buffer, data []byte) int {
|
||||
if pre := p.quotePrefix(data[beg:]); pre > 0 {
|
||||
// skip the prefix
|
||||
beg += pre
|
||||
} else if p.isEmpty(data[beg:]) > 0 &&
|
||||
(end >= len(data) ||
|
||||
(p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0)) {
|
||||
// blockquote ends with at least one blank line
|
||||
// followed by something without a blockquote prefix
|
||||
} else if p.terminateBlockquote(data, beg, end) {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -1039,6 +1034,20 @@ func (p *parser) oliPrefix(data []byte) int {
|
||||
return i + 2
|
||||
}
|
||||
|
||||
// returns definition list item prefix
|
||||
func (p *parser) dliPrefix(data []byte) int {
|
||||
i := 0
|
||||
|
||||
// need a : followed by a spaces
|
||||
if data[i] != ':' || data[i+1] != ' ' {
|
||||
return 0
|
||||
}
|
||||
for data[i] == ' ' {
|
||||
i++
|
||||
}
|
||||
return i + 2
|
||||
}
|
||||
|
||||
// parse ordered or unordered list block
|
||||
func (p *parser) list(out *bytes.Buffer, data []byte, flags int) int {
|
||||
i := 0
|
||||
@@ -1074,7 +1083,19 @@ func (p *parser) listItem(out *bytes.Buffer, data []byte, flags *int) int {
|
||||
i = p.oliPrefix(data)
|
||||
}
|
||||
if i == 0 {
|
||||
return 0
|
||||
i = p.dliPrefix(data)
|
||||
// reset definition term flag
|
||||
if i > 0 {
|
||||
*flags &= ^LIST_TYPE_TERM
|
||||
}
|
||||
}
|
||||
if i == 0 {
|
||||
// if in defnition list, set term flag and continue
|
||||
if *flags&LIST_TYPE_DEFINITION != 0 {
|
||||
*flags |= LIST_TYPE_TERM
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// skip leading whitespace on first line
|
||||
@@ -1084,7 +1105,7 @@ func (p *parser) listItem(out *bytes.Buffer, data []byte, flags *int) int {
|
||||
|
||||
// find the end of the line
|
||||
line := i
|
||||
for data[i-1] != '\n' {
|
||||
for i > 0 && data[i-1] != '\n' {
|
||||
i++
|
||||
}
|
||||
|
||||
@@ -1128,7 +1149,8 @@ gatherlines:
|
||||
switch {
|
||||
// is this a nested list item?
|
||||
case (p.uliPrefix(chunk) > 0 && !p.isHRule(chunk)) ||
|
||||
p.oliPrefix(chunk) > 0:
|
||||
p.oliPrefix(chunk) > 0 ||
|
||||
p.dliPrefix(chunk) > 0:
|
||||
|
||||
if containsBlankLine {
|
||||
*flags |= LIST_ITEM_CONTAINS_BLOCK
|
||||
@@ -1140,7 +1162,7 @@ gatherlines:
|
||||
break gatherlines
|
||||
}
|
||||
|
||||
// is this the first item in the the nested list?
|
||||
// is this the first item in the nested list?
|
||||
if sublist == 0 {
|
||||
sublist = raw.Len()
|
||||
}
|
||||
@@ -1159,7 +1181,21 @@ gatherlines:
|
||||
// of this item if it is indented 4 spaces
|
||||
// (regardless of the indentation of the beginning of the item)
|
||||
case containsBlankLine && indent < 4:
|
||||
*flags |= LIST_ITEM_END_OF_LIST
|
||||
if *flags&LIST_TYPE_DEFINITION != 0 && i < len(data)-1 {
|
||||
// is the next item still a part of this list?
|
||||
next := i
|
||||
for data[next] != '\n' {
|
||||
next++
|
||||
}
|
||||
for next < len(data)-1 && data[next] == '\n' {
|
||||
next++
|
||||
}
|
||||
if i < len(data)-1 && data[i] != ':' && data[next] != ':' {
|
||||
*flags |= LIST_ITEM_END_OF_LIST
|
||||
}
|
||||
} else {
|
||||
*flags |= LIST_ITEM_END_OF_LIST
|
||||
}
|
||||
break gatherlines
|
||||
|
||||
// a blank line means this should be parsed as a block
|
||||
@@ -1173,6 +1209,7 @@ gatherlines:
|
||||
if containsBlankLine {
|
||||
containsBlankLine = false
|
||||
raw.WriteByte('\n')
|
||||
|
||||
}
|
||||
|
||||
// add the line into the working buffer without prefix
|
||||
@@ -1185,8 +1222,8 @@ gatherlines:
|
||||
|
||||
// render the contents of the list item
|
||||
var cooked bytes.Buffer
|
||||
if *flags&LIST_ITEM_CONTAINS_BLOCK != 0 {
|
||||
// intermediate render of block li
|
||||
if *flags&LIST_ITEM_CONTAINS_BLOCK != 0 && *flags&LIST_TYPE_TERM == 0 {
|
||||
// intermediate render of block item, except for definition term
|
||||
if sublist > 0 {
|
||||
p.block(&cooked, rawBytes[:sublist])
|
||||
p.block(&cooked, rawBytes[sublist:])
|
||||
@@ -1194,7 +1231,7 @@ gatherlines:
|
||||
p.block(&cooked, rawBytes)
|
||||
}
|
||||
} else {
|
||||
// intermediate render of inline li
|
||||
// intermediate render of inline item
|
||||
if sublist > 0 {
|
||||
p.inline(&cooked, rawBytes[:sublist])
|
||||
p.block(&cooked, rawBytes[sublist:])
|
||||
@@ -1258,6 +1295,13 @@ func (p *parser) paragraph(out *bytes.Buffer, data []byte) int {
|
||||
|
||||
// did we find a blank line marking the end of the paragraph?
|
||||
if n := p.isEmpty(current); n > 0 {
|
||||
// did this blank line followed by a definition list item?
|
||||
if p.flags&EXTENSION_DEFINITION_LISTS != 0 {
|
||||
if i < len(data)-1 && data[i+1] == ':' {
|
||||
return p.list(out, data[prev:], LIST_TYPE_DEFINITION)
|
||||
}
|
||||
}
|
||||
|
||||
p.renderParagraph(out, data[:i])
|
||||
return i + n
|
||||
}
|
||||
@@ -1316,6 +1360,21 @@ func (p *parser) paragraph(out *bytes.Buffer, data []byte) int {
|
||||
return i
|
||||
}
|
||||
|
||||
// if there's a fenced code block, paragraph is over
|
||||
if p.flags&EXTENSION_FENCED_CODE != 0 {
|
||||
if p.fencedCode(out, current, false) > 0 {
|
||||
p.renderParagraph(out, data[:i])
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
// if there's a definition list item, prev line is a definition term
|
||||
if p.flags&EXTENSION_DEFINITION_LISTS != 0 {
|
||||
if p.dliPrefix(current) != 0 {
|
||||
return p.list(out, data[prev:], LIST_TYPE_DEFINITION)
|
||||
}
|
||||
}
|
||||
|
||||
// if there's a list after this, paragraph is over
|
||||
if p.flags&EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK != 0 {
|
||||
if p.uliPrefix(current) != 0 ||
|
||||
|
||||
Reference in New Issue
Block a user