FIX: inline [code] not handled properly
The text a [code]test[/code] Would eat up the `test` text cause translation from inline to block for replace rule was not properly handled
This commit is contained in:
parent
c7a0ced656
commit
a0cd54750c
|
@ -242,7 +242,14 @@ function applyBBCode(state, startLine, endLine, silent, md) {
|
|||
state.lineMax = nextLine;
|
||||
|
||||
if (rule.replace) {
|
||||
let content = state.src.slice(state.bMarks[startLine+1], state.eMarks[nextLine-1]);
|
||||
let content;
|
||||
|
||||
if (startLine === nextLine) {
|
||||
content = state.src.slice(start + info.length, closeTag.start);
|
||||
} else {
|
||||
content = state.src.slice(state.bMarks[startLine+1], state.eMarks[nextLine-1]);
|
||||
}
|
||||
|
||||
if (!rule.replace.call(this, state, info, content)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -980,6 +980,14 @@ HTML
|
|||
expect(PrettyText.cook("a[i]b[/i]c")).to eq('<p>a<span class="bbcode-i">b</span>c</p>')
|
||||
end
|
||||
|
||||
it "can handle bbcode after a newline" do
|
||||
# this is not 100% ideal cause we get an extra p here, but this is pretty rare
|
||||
expect(PrettyText.cook("a\n[code]code[/code]")).to eq("<p>a</p>\n<pre><code class=\"lang-auto\">code</code></pre>")
|
||||
|
||||
# this is fine
|
||||
expect(PrettyText.cook("a\na[code]code[/code]")).to eq("<p>a<br>\na<code>code</code></p>")
|
||||
end
|
||||
|
||||
it "can onebox local topics" do
|
||||
op = Fabricate(:post)
|
||||
reply = Fabricate(:post, topic_id: op.topic_id)
|
||||
|
|
Loading…
Reference in New Issue