Merge pull request #74 from mmarkdown/multiple-fixes

Multiple fixes
This commit is contained in:
Miek Gieben 2018-08-18 09:34:39 +02:00 committed by GitHub
commit a7d8778cf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 7 deletions

View File

@ -34,11 +34,11 @@ func (p *Parser) terminateAside(data []byte, beg, end int) bool {
return p.asidePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0
}
// parse a blockquote fragment
// parse a aside fragment
func (p *Parser) aside(data []byte) int {
block := p.addBlock(&ast.Aside{})
var raw bytes.Buffer
beg, end := 0, 0
// identical to quote
for beg < len(data) {
end = beg
// Step over whole lines, collecting them. While doing that, check for
@ -65,6 +65,8 @@ func (p *Parser) aside(data []byte) int {
raw.Write(data[beg:end])
beg = end
}
block := p.addBlock(&ast.Aside{})
p.block(raw.Bytes())
p.finalize(block)
return end

View File

@ -1004,7 +1004,7 @@ func (p *Parser) table(data []byte) int {
i = skipCharN(data, i, '\n', 1)
p.tableRow(data[rowStart:i], columns, false)
}
if captionContent, consumed := p.caption(data[i:]); consumed > 0 {
if captionContent, consumed := p.caption(data[i:], []byte("Table: ")); consumed > 0 {
caption := &ast.Caption{}
p.Inline(caption, captionContent)

View File

@ -203,7 +203,7 @@ func canNodeContain(n ast.Node, v ast.Node) bool {
switch n.(type) {
case *ast.List:
return isListItem(v)
case *ast.Document, *ast.BlockQuote, *ast.ListItem:
case *ast.Document, *ast.BlockQuote, *ast.Aside, *ast.ListItem:
return !isListItem(v)
case *ast.Table:
switch v.(type) {

15
testdata/mmark.test vendored
View File

@ -95,14 +95,14 @@ code
Look at (#basics)
+++
<h1>Cross ref</h1>
+++
<p>Look at <a href="#basics"></a></p>
+++
Name | Age
--------|------
Bob | 27
Alice | 23
Caption: Look at this table!
Table: Look at this table!
+++
<figure>
<table>
@ -126,4 +126,13 @@ Caption: Look at this table!
</tbody>
</table>
<figcaption>Look at this table!</figcaption>
</figure>
</figure>
+++
# Aside
A> This is an aside
+++
<h1>Aside</h1>
<aside>
<p>This is an aside</p>
</aside>