mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 18:24:52 -06:00
FIX: [quote] without params was failing.
This commit is contained in:
parent
f565766b1e
commit
1783089d64
@ -6,19 +6,24 @@ Discourse.Dialect.replaceBlock({
|
||||
stop: '[/quote]',
|
||||
emitter: function(blockContents, matches, options) {
|
||||
|
||||
var paramsString = matches[1].replace(/\"/g, ''),
|
||||
params = {'class': 'quote'},
|
||||
paramsSplit = paramsString.split(/\, */),
|
||||
username = paramsSplit[0];
|
||||
var params = {'class': 'quote'},
|
||||
username;
|
||||
|
||||
paramsSplit.forEach(function(p,i) {
|
||||
if (i > 0) {
|
||||
var assignment = p.split(':');
|
||||
if (assignment[0] && assignment[1]) {
|
||||
params['data-' + assignment[0]] = assignment[1].trim();
|
||||
if (matches[1]) {
|
||||
var paramsString = matches[1].replace(/\"/g, ''),
|
||||
paramsSplit = paramsString.split(/\, */);
|
||||
|
||||
username = paramsSplit[0];
|
||||
|
||||
paramsSplit.forEach(function(p,i) {
|
||||
if (i > 0) {
|
||||
var assignment = p.split(':');
|
||||
if (assignment[0] && assignment[1]) {
|
||||
params['data-' + assignment[0]] = assignment[1].trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var avatarImg;
|
||||
if (options.lookupAvatarByPostNumber) {
|
||||
@ -41,11 +46,15 @@ Discourse.Dialect.replaceBlock({
|
||||
});
|
||||
}
|
||||
|
||||
if (!username) {
|
||||
return ['p', ['aside', params, contents ]];
|
||||
}
|
||||
|
||||
return ['p', ['aside', params,
|
||||
['div', {'class': 'title'},
|
||||
['div', {'class': 'quote-controls'}],
|
||||
avatarImg ? ['__RAW', avatarImg] : "",
|
||||
I18n.t('user.said', {username: username})
|
||||
username ? I18n.t('user.said', {username: username}) : ""
|
||||
],
|
||||
contents
|
||||
]];
|
||||
|
@ -74,6 +74,11 @@ test("quotes", function() {
|
||||
formatQuote("this is <not> a bug",
|
||||
"[quote=\"eviltrout, post:1, topic:2\"]\nthis is <not> a bug\n[/quote]\n\n",
|
||||
"it escapes the contents of the quote");
|
||||
|
||||
format("[quote]test[/quote]",
|
||||
"<aside class=\"quote\"><blockquote><p>test</p></blockquote></aside>",
|
||||
"it supports quotes without params");
|
||||
|
||||
});
|
||||
|
||||
test("quote formatting", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user