diff --git a/dist/showdown.js b/dist/showdown.js index 03620b4..0433f6b 100644 Binary files a/dist/showdown.js and b/dist/showdown.js differ diff --git a/dist/showdown.js.map b/dist/showdown.js.map index 515d2f7..a58c717 100644 Binary files a/dist/showdown.js.map and b/dist/showdown.js.map differ diff --git a/dist/showdown.min.js b/dist/showdown.min.js index b7394f5..327c987 100644 Binary files a/dist/showdown.min.js and b/dist/showdown.min.js differ diff --git a/dist/showdown.min.js.map b/dist/showdown.min.js.map index f36df2a..b40c72f 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/converter.js b/src/converter.js index 55ecb44..e2dfc27 100644 --- a/src/converter.js +++ b/src/converter.js @@ -6,12 +6,7 @@ * Showdown Converter class * @class * @param {object} [converterOptions] - * @returns { - * {makeHtml: Function}, - * {setOption: Function}, - * {getOption: Function}, - * {getOptions: Function} - * } + * @returns {Converter} */ showdown.Converter = function (converterOptions) { 'use strict'; diff --git a/src/subParsers/blockGamut.js b/src/subParsers/blockGamut.js index e2c24a6..200266f 100644 --- a/src/subParsers/blockGamut.js +++ b/src/subParsers/blockGamut.js @@ -5,6 +5,9 @@ showdown.subParser('blockGamut', function (text, options, globals) { 'use strict'; + // we parse blockquotes first so that we can have headings and hrs + // inside blockquotes + text = showdown.subParser('blockQuotes')(text, options, globals); text = showdown.subParser('headers')(text, options, globals); // Do Horizontal Rules: @@ -13,10 +16,9 @@ showdown.subParser('blockGamut', function (text, options, globals) { text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm, key); text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, key); - text = showdown.subParser('tables')(text, options, globals); text = showdown.subParser('lists')(text, options, globals); text = showdown.subParser('codeBlocks')(text, options, globals); - text = showdown.subParser('blockQuotes')(text, options, globals); + text = showdown.subParser('tables')(text, options, globals); // We already ran _HashHTMLBlocks() before, in Markdown(), but that // was to escape raw HTML in the original Markdown source. This time, diff --git a/src/subParsers/blockQuotes.js b/src/subParsers/blockQuotes.js index 4b1782f..257e068 100644 --- a/src/subParsers/blockQuotes.js +++ b/src/subParsers/blockQuotes.js @@ -14,7 +14,7 @@ showdown.subParser('blockQuotes', function (text, options, globals) { /gm, function(){...}); */ - text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) { + text = text.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function (wholeMatch, m1) { var bq = m1; // attacklab: hack around Konqueror 3.5.4 bug: @@ -25,6 +25,7 @@ showdown.subParser('blockQuotes', function (text, options, globals) { bq = bq.replace(/~0/g, ''); bq = bq.replace(/^[ \t]+$/gm, ''); // trim whitespace-only lines + bq = showdown.subParser('githubCodeBlocks')(bq, options, globals); bq = showdown.subParser('blockGamut')(bq, options, globals); // recurse bq = bq.replace(/(^|\n)/g, '$1 '); diff --git a/src/subParsers/lists.js b/src/subParsers/lists.js index 1a4f43d..63b98d7 100644 --- a/src/subParsers/lists.js +++ b/src/subParsers/lists.js @@ -8,6 +8,7 @@ showdown.subParser('lists', function (text, options, globals) { * Process the contents of a single ordered or unordered list, splitting it * into individual list items. * @param {string} listStr + * @param {boolean} trimTrailing * @returns {string} */ function processListItems (listStr, trimTrailing) { @@ -95,6 +96,7 @@ showdown.subParser('lists', function (text, options, globals) { * Check and parse consecutive lists (better fix for issue #142) * @param {string} list * @param {string} listType + * @param {boolean} trimTrailing * @returns {string} */ function parseConsecutiveLists(list, listType, trimTrailing) { diff --git a/test/cases/blockquote-followed-by-code.html b/test/cases/blockquote-followed-by-code.html new file mode 100644 index 0000000..a37d0e0 --- /dev/null +++ b/test/cases/blockquote-followed-by-code.html @@ -0,0 +1,9 @@ +
+

a blockquote with a 4 space indented line (not code)

+
+

sep

+
+

a blockquote

+
+
with some code after
+
diff --git a/test/cases/blockquote-followed-by-code.md b/test/cases/blockquote-followed-by-code.md new file mode 100644 index 0000000..b0426b7 --- /dev/null +++ b/test/cases/blockquote-followed-by-code.md @@ -0,0 +1,8 @@ +> a blockquote + with a 4 space indented line (not code) + +sep + +> a blockquote + + with some code after diff --git a/test/cases/blockquote-inside-code.html b/test/cases/blockquote-inside-code.html new file mode 100644 index 0000000..d0c40b5 --- /dev/null +++ b/test/cases/blockquote-inside-code.html @@ -0,0 +1,8 @@ +
> this is a pseudo blockquote
+    > inside a code block
+
+ +

foo

+
> this is another bq
+    inside code
+
diff --git a/test/cases/blockquote-inside-code.md b/test/cases/blockquote-inside-code.md new file mode 100644 index 0000000..eeb225a --- /dev/null +++ b/test/cases/blockquote-inside-code.md @@ -0,0 +1,7 @@ + > this is a pseudo blockquote + > inside a code block + +foo + + > this is another bq + inside code diff --git a/test/cases/github-style-codeblock-inside-quote.html b/test/cases/github-style-codeblock-inside-quote.html new file mode 100644 index 0000000..85fa51c --- /dev/null +++ b/test/cases/github-style-codeblock-inside-quote.html @@ -0,0 +1,15 @@ +
+

Define a function in javascript:

+ +
function MyFunc(a) {
+  var s = '`';
+  }
+
+ +
+

And some nested quote

+ +
<div>HTML!</div>
+
+
+
diff --git a/test/cases/github-style-codeblock-inside-quote.md b/test/cases/github-style-codeblock-inside-quote.md new file mode 100644 index 0000000..23c4714 --- /dev/null +++ b/test/cases/github-style-codeblock-inside-quote.md @@ -0,0 +1,13 @@ +> Define a function in javascript: +> +> ``` +> function MyFunc(a) { +> var s = '`'; +> } +> ``` +> +>> And some nested quote +>> +>> ```html +>>
HTML!
+>> ``` diff --git a/test/features/tables/table-inside-codeblock.html b/test/features/tables/table-inside-codeblock.html new file mode 100644 index 0000000..ced23c6 --- /dev/null +++ b/test/features/tables/table-inside-codeblock.html @@ -0,0 +1,8 @@ +

some text

+ +
| Tables        | Are           | Cool  |
+| ------------- |:-------------:| -----:|
+| **col 3 is**  | right-aligned | $1600 |
+| col 2 is      | *centered*    |   $12 |
+| zebra stripes | ~~are neat~~  |    $1 |
+
diff --git a/test/features/tables/table-inside-codeblock.md b/test/features/tables/table-inside-codeblock.md new file mode 100644 index 0000000..6b82cdc --- /dev/null +++ b/test/features/tables/table-inside-codeblock.md @@ -0,0 +1,8 @@ +some text + + + | Tables | Are | Cool | + | ------------- |:-------------:| -----:| + | **col 3 is** | right-aligned | $1600 | + | col 2 is | *centered* | $12 | + | zebra stripes | ~~are neat~~ | $1 | diff --git a/test/issues/#191.blockquote-followed-by-an-heading.html b/test/issues/#191.blockquote-followed-by-an-heading.html new file mode 100644 index 0000000..b594288 --- /dev/null +++ b/test/issues/#191.blockquote-followed-by-an-heading.html @@ -0,0 +1,4 @@ +
+

a blockquote

+

followed by an heading

+
\ No newline at end of file diff --git a/test/issues/#191.blockquote-followed-by-an-heading.md b/test/issues/#191.blockquote-followed-by-an-heading.md new file mode 100644 index 0000000..f60ccb8 --- /dev/null +++ b/test/issues/#191.blockquote-followed-by-an-heading.md @@ -0,0 +1,2 @@ +> a blockquote +# followed by an heading