FIX: Allow proper escaping of bold and italics markdown, even when

nested.
This commit is contained in:
Robin Ward
2014-09-22 16:51:48 -04:00
parent 19bdf7be90
commit 537e6b193d
3 changed files with 37 additions and 5 deletions

View File

@@ -21,7 +21,6 @@ test("basic cooking", function() {
cooked("__bold__", "<p><strong>bold</strong></p>", "it bolds text.");
cooked("*trout*", "<p><em>trout</em></p>", "it italicizes text.");
cooked("_trout_", "<p><em>trout</em></p>", "it italicizes text.");
cooked("*this is italic **with some bold** inside*", "<p><em>this is italic <strong>with some bold</strong> inside</em></p>", "it handles nested bold in italics");
cooked("***hello***", "<p><strong><em>hello</em></strong></p>", "it can do bold and italics at once.");
cooked("word_with_underscores", "<p>word_with_underscores</p>", "it doesn't do intraword italics");
cooked("common/_special_font_face.html.erb", "<p>common/_special_font_face.html.erb</p>", "it doesn't intraword with a slash");
@@ -30,6 +29,10 @@ test("basic cooking", function() {
cooked("brussel sproutes are *awful*.", "<p>brussel sproutes are <em>awful</em>.</p>", "it doesn't swallow periods.");
});
test("Nested bold and italics", function() {
cooked("*this is italic **with some bold** inside*", "<p><em>this is italic <strong>with some bold</strong> inside</em></p>", "it handles nested bold in italics");
});
test("Traditional Line Breaks", function() {
var input = "1\n2\n3";
cooked(input, "<p>1<br/>2<br/>3</p>", "automatically handles trivial newlines");
@@ -145,7 +148,7 @@ test("Links", function() {
cooked("[Link](http://www.example.com) (with an outer \"description\")",
"<p><a href=\"http://www.example.com\">Link</a> (with an outer \"description\")</p>",
"it doesn't consume closing parens as part of the url")
"it doesn't consume closing parens as part of the url");
});
test("simple quotes", function() {
@@ -276,6 +279,11 @@ test("bold and italics", function() {
cooked("**你hello**", "<p><strong>你hello</strong></p>", "allows bolded chinese");
});
test("Escaping", function() {
cooked("*\\*laughs\\**", "<p><em>*laughs*</em></p>", "allows escaping strong");
cooked("*\\_laughs\\_*", "<p><em>_laughs_</em></p>", "allows escaping em");
});
test("New Lines", function() {
// Note: This behavior was discussed and we determined it does not make sense to do this
// unless you're using traditional line breaks