summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown')
-rw-r--r--vendor/github.com/gomarkdown/markdown/README.md12
-rw-r--r--vendor/github.com/gomarkdown/markdown/ast/node.go1
-rw-r--r--vendor/github.com/gomarkdown/markdown/html/renderer.go3
-rw-r--r--vendor/github.com/gomarkdown/markdown/parser/block.go31
4 files changed, 44 insertions, 3 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/README.md b/vendor/github.com/gomarkdown/markdown/README.md
index 095db307..a40c7a94 100644
--- a/vendor/github.com/gomarkdown/markdown/README.md
+++ b/vendor/github.com/gomarkdown/markdown/README.md
@@ -207,6 +207,18 @@ implements the following extensions:
Total | 50
```
+ A cell spanning multiple columns (colspan) is supported, just repeat the pipe symbol:
+
+ ```
+ Name | Age
+ --------|------
+ Bob ||
+ Alice | 23
+ ========|======
+ Total | 23
+ ```
+
+
- **Fenced code blocks**. In addition to the normal 4-space
indentation to mark code blocks, you can explicitly mark them
and supply a language (to make syntax highlighting simple). Just
diff --git a/vendor/github.com/gomarkdown/markdown/ast/node.go b/vendor/github.com/gomarkdown/markdown/ast/node.go
index 9d2422af..7881f6e7 100644
--- a/vendor/github.com/gomarkdown/markdown/ast/node.go
+++ b/vendor/github.com/gomarkdown/markdown/ast/node.go
@@ -340,6 +340,7 @@ type TableCell struct {
IsHeader bool // This tells if it's under the header row
Align CellAlignFlags // This holds the value for align attribute
+ ColSpan int // How many columns to span
}
// TableHeader represents markdown table head node
diff --git a/vendor/github.com/gomarkdown/markdown/html/renderer.go b/vendor/github.com/gomarkdown/markdown/html/renderer.go
index 6c56ac12..c57d7eb6 100644
--- a/vendor/github.com/gomarkdown/markdown/html/renderer.go
+++ b/vendor/github.com/gomarkdown/markdown/html/renderer.go
@@ -952,6 +952,9 @@ func (r *Renderer) TableCell(w io.Writer, tableCell *ast.TableCell, entering boo
if align != "" {
attrs = append(attrs, fmt.Sprintf(`align="%s"`, align))
}
+ if colspan := tableCell.ColSpan; colspan > 0 {
+ attrs = append(attrs, fmt.Sprintf(`colspan="%d"`, colspan))
+ }
if ast.GetPrevNode(tableCell) == nil {
r.CR(w)
}
diff --git a/vendor/github.com/gomarkdown/markdown/parser/block.go b/vendor/github.com/gomarkdown/markdown/parser/block.go
index 5ef55e98..cec667b5 100644
--- a/vendor/github.com/gomarkdown/markdown/parser/block.go
+++ b/vendor/github.com/gomarkdown/markdown/parser/block.go
@@ -1204,7 +1204,9 @@ func (p *Parser) tableRow(data []byte, columns []ast.CellAlignFlags, header bool
}
n := len(data)
+ colspans := 0 // keep track of total colspan in this row.
for col = 0; col < len(columns) && i < n; col++ {
+ colspan := 0
for i < n && data[i] == ' ' {
i++
}
@@ -1218,7 +1220,15 @@ func (p *Parser) tableRow(data []byte, columns []ast.CellAlignFlags, header bool
cellEnd := i
// skip the end-of-cell marker, possibly taking us past end of buffer
- i++
+ // each _extra_ | means a colspan
+ for data[i] == '|' && !isBackslashEscaped(data, i) {
+ i++
+ colspan++
+ }
+ // only colspan > 1 make sense.
+ if colspan < 2 {
+ colspan = 0
+ }
for cellEnd > cellStart && cellEnd-1 < n && data[cellEnd-1] == ' ' {
cellEnd--
@@ -1227,9 +1237,19 @@ func (p *Parser) tableRow(data []byte, columns []ast.CellAlignFlags, header bool
block := &ast.TableCell{
IsHeader: header,
Align: columns[col],
+ ColSpan: colspan,
}
block.Content = data[cellStart:cellEnd]
- p.addBlock(block)
+ if cellStart == cellEnd && colspans > 0 {
+ // an empty cell that we should ignore, it exists because of colspan
+ colspans--
+ } else {
+ p.addBlock(block)
+ }
+
+ if colspan > 0 {
+ colspans += colspan - 1
+ }
}
// pad it out with empty columns to get the right number
@@ -1247,7 +1267,12 @@ func (p *Parser) tableRow(data []byte, columns []ast.CellAlignFlags, header bool
// tableFooter parses the (optional) table footer.
func (p *Parser) tableFooter(data []byte) bool {
colCount := 1
- for i := 0; i < len(data) && data[i] != '\n'; i++ {
+ i := 0
+ n := len(data)
+ for i < 3 && i < n && data[i] == ' ' { // ignore up to 3 spaces
+ i++
+ }
+ for ; i < n && data[i] != '\n'; i++ {
if data[i] == '|' && !isBackslashEscaped(data, i) {
colCount++
continue