mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-30 16:04:36 -04:00
FIX: Blockquotes prefixed by spaces
This commit is contained in:
parent
c99cf64d70
commit
380a6c9e9d
3 changed files with 31 additions and 1 deletions
app/assets/javascripts
test/javascripts/components
|
@ -23,3 +23,20 @@ replaceMarkdown('**', 'strong');
|
||||||
replaceMarkdown('__', 'strong');
|
replaceMarkdown('__', 'strong');
|
||||||
replaceMarkdown('*', 'em');
|
replaceMarkdown('*', 'em');
|
||||||
replaceMarkdown('_', 'em');
|
replaceMarkdown('_', 'em');
|
||||||
|
|
||||||
|
|
||||||
|
// There's a weird issue with the markdown parser where it won't process simple blockquotes
|
||||||
|
// when they are prefixed with spaces. This fixes it.
|
||||||
|
Discourse.Dialect.on("register", function(event) {
|
||||||
|
var dialect = event.dialect,
|
||||||
|
MD = event.MD;
|
||||||
|
|
||||||
|
dialect.block["fix_simple_quotes"] = function(block, next) {
|
||||||
|
var m = /^ +(\>[\s\S]*)/.exec(block);
|
||||||
|
if (m && m[1] && m[1].length) {
|
||||||
|
next.unshift(MD.mk_block(m[1]));
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
* We fixed a bug where references can be created directly following a list.
|
* We fixed a bug where references can be created directly following a list.
|
||||||
|
|
||||||
|
* Fix to blockquote to handle spaces in front and when nested.
|
||||||
|
|
||||||
* Note the name BetterMarkdown doesn't mean it's *better* than markdown-js, it refers
|
* Note the name BetterMarkdown doesn't mean it's *better* than markdown-js, it refers
|
||||||
to it being better than our previous markdown parser!
|
to it being better than our previous markdown parser!
|
||||||
|
|
||||||
|
@ -750,7 +752,7 @@ Markdown.dialects.Gruber = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip off the leading "> " and re-process as a block.
|
// Strip off the leading "> " and re-process as a block.
|
||||||
var input = block.replace( /^> ?/gm, "" ),
|
var input = block.replace( /^> */gm, "" ),
|
||||||
old_tree = this.tree,
|
old_tree = this.tree,
|
||||||
processedBlock = this.toTree( input, [ "blockquote" ] ),
|
processedBlock = this.toTree( input, [ "blockquote" ] ),
|
||||||
attr = extract_attr( processedBlock );
|
attr = extract_attr( processedBlock );
|
||||||
|
|
|
@ -109,6 +109,17 @@ test("Links", function() {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("simple quotes", function() {
|
||||||
|
cooked("> nice!", "<blockquote><p>nice!</p></blockquote>", "it supports simple quotes");
|
||||||
|
cooked(" > nice!", "<blockquote><p>nice!</p></blockquote>", "it allows quotes with preceeding spaces");
|
||||||
|
cooked("> level 1\n> > level 2",
|
||||||
|
"<blockquote><p>level 1</p><blockquote><p>level 2</p></blockquote></blockquote>",
|
||||||
|
"it allows nesting of blockquotes");
|
||||||
|
cooked("> level 1\n> > level 2",
|
||||||
|
"<blockquote><p>level 1</p><blockquote><p>level 2</p></blockquote></blockquote>",
|
||||||
|
"it allows nesting of blockquotes with spaces");
|
||||||
|
});
|
||||||
|
|
||||||
test("Quotes", function() {
|
test("Quotes", function() {
|
||||||
|
|
||||||
cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n[/quote]",
|
cookedOptions("[quote=\"eviltrout, post: 1\"]\na quote\n\nsecond line\n[/quote]",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue