Merge pull request #73 from mmarkdown/captions-original

Drop "Caption: " in favor of specific caption triggers
This commit is contained in:
Miek Gieben 2018-08-17 19:01:05 +02:00 committed by GitHub
commit 8d1c9c05f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -927,7 +927,7 @@ func (p *Parser) fencedCodeBlock(data []byte, doRender bool) int {
}
// Check for caption and if found make it a figure.
if captionContent, consumed := p.caption(data[beg:]); consumed > 0 {
if captionContent, consumed := p.caption(data[beg:], []byte("Figure: ")); consumed > 0 {
figure := &ast.CaptionFigure{}
caption := &ast.Caption{}
p.Inline(caption, captionContent)
@ -1242,7 +1242,7 @@ func (p *Parser) quote(data []byte) int {
return end
}
if captionContent, consumed := p.caption(data[end:]); consumed > 0 {
if captionContent, consumed := p.caption(data[end:], []byte("Quote: ")); consumed > 0 {
figure := &ast.CaptionFigure{}
caption := &ast.Caption{}
p.Inline(caption, captionContent)

View File

@ -4,11 +4,11 @@ import (
"bytes"
)
func (p *Parser) caption(data []byte) ([]byte, int) {
if !bytes.HasPrefix(data, []byte("Caption: ")) {
func (p *Parser) caption(data, caption []byte) ([]byte, int) {
if !bytes.HasPrefix(data, caption) {
return nil, 0
}
j := len("Caption: ")
j := len(caption)
data = data[j:]
end := p.linesUntilEmpty(data)

4
testdata/mmark.test vendored
View File

@ -21,7 +21,7 @@
~~~ go
println("hi")
~~~
Caption: This *is* a
Figure: This *is* a
caption.
+++
<h1>Test Code Captions</h1>
@ -35,7 +35,7 @@ Caption: This *is* a
# Test Quote Captions
> To be, or not to be
Caption: Shakespeare.
Quote: Shakespeare.
+++
<h1>Test Quote Captions</h1>
<figure>