FIX: allow bbcode to be unquoted for default
This commit is contained in:
parent
04eac9f14a
commit
4da98cdcfe
|
@ -11,7 +11,7 @@ function trailingSpaceOnly(src, start, max) {
|
|||
return true;
|
||||
}
|
||||
|
||||
const ATTR_REGEX = /((([a-z0-9]*)\s*)=)(["“”'].*["“”']|\S+)/ig;
|
||||
const ATTR_REGEX = /^\s*=(.+)$|((([a-z0-9]*)\s*)=)(["“”'].*["“”']|\S+)/ig;
|
||||
|
||||
// parse a tag [test a=1 b=2] to a data structure
|
||||
// {tag: "test", attrs={a: "1", b: "2"}
|
||||
|
@ -76,12 +76,13 @@ export function parseBBCodeTag(src, start, max, multiline) {
|
|||
let match, key, val;
|
||||
|
||||
while(match = ATTR_REGEX.exec(raw)) {
|
||||
key = match[3];
|
||||
if (key === '') {
|
||||
if (match[1]) {
|
||||
key = '_default';
|
||||
} else {
|
||||
key = match[4];
|
||||
}
|
||||
|
||||
val = match[4];
|
||||
val = match[1] || match[5];
|
||||
|
||||
if (val) {
|
||||
val = val.trim();
|
||||
|
|
|
@ -47,7 +47,29 @@ describe PrettyText do
|
|||
expect(cook("[quote=\"EvilTrout, post:2, topic:#{topic.id}\"]\nddd\n[/quote]", topic_id: 1)).to eq(n(expected))
|
||||
end
|
||||
|
||||
it "indifferent about curlies" do
|
||||
it "indifferent about missing quotations" do
|
||||
md = <<~MD
|
||||
[quote=#{user.username}, post:123, topic:456, full:true]
|
||||
|
||||
ddd
|
||||
|
||||
[/quote]
|
||||
MD
|
||||
html = <<~HTML
|
||||
<aside class="quote" data-post="123" data-topic="456" data-full="true">
|
||||
<div class="title">
|
||||
<div class="quote-controls"></div>
|
||||
<img alt width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div>
|
||||
<blockquote>
|
||||
<p>ddd</p>
|
||||
</blockquote>
|
||||
</aside>
|
||||
HTML
|
||||
|
||||
expect(PrettyText.cook(md)).to eq(html.strip)
|
||||
end
|
||||
|
||||
it "indifferent about curlies and no curlies" do
|
||||
md = <<~MD
|
||||
[quote=“#{user.username}, post:123, topic:456, full:true”]
|
||||
|
||||
|
|
Loading…
Reference in New Issue