mirror of
https://github.com/status-im/markdown.git
synced 2025-02-20 15:28:05 +00:00
Merge pull request #73 from mmarkdown/captions-original
Drop "Caption: " in favor of specific caption triggers
This commit is contained in:
commit
8d1c9c05f7
@ -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)
|
||||
|
@ -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
4
testdata/mmark.test
vendored
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user