diff --git a/dist/showdown.js b/dist/showdown.js index eb948b8..1322118 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 05576ac..98d36ba 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 299562e..1cc2ec8 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 863a790..ec1f44c 100644 Binary files a/dist/showdown.min.js.map and b/dist/showdown.min.js.map differ diff --git a/src/subParsers/makehtml/lists.js b/src/subParsers/makehtml/lists.js index 77a86b2..9d34889 100644 --- a/src/subParsers/makehtml/lists.js +++ b/src/subParsers/makehtml/lists.js @@ -87,14 +87,14 @@ showdown.subParser('makehtml.lists', function (text, options, globals) { return '¨A' + wm2; }); - // SPECIAL CASE: an heading followed by a paragraph of text that is not separated by a double newline + // SPECIAL CASE: a heading followed by a paragraph of text that is not separated by a double newline // or/nor indented. ex: // // - # foo // bar is great // // While this does now follow the spec per se, not allowing for this might cause confusion since - // header blocks don't need double newlines after + // header blocks don't need double-newlines after if (/^#+.+\n.+/.test(item)) { item = item.replace(/^(#+.+)$/m, '$1\n'); } @@ -103,7 +103,47 @@ showdown.subParser('makehtml.lists', function (text, options, globals) { // Has a double return (multi paragraph) if (m1 || (item.search(/\n{2,}/) > -1)) { item = showdown.subParser('makehtml.githubCodeBlocks')(item, options, globals); - item = showdown.subParser('makehtml.blockGamut')(item, options, globals); + item = showdown.subParser('makehtml.blockQuotes')(item, options, globals); + item = showdown.subParser('makehtml.headers')(item, options, globals); + item = showdown.subParser('makehtml.lists')(item, options, globals); + item = showdown.subParser('makehtml.codeBlocks')(item, options, globals); + item = showdown.subParser('makehtml.tables')(item, options, globals); + item = showdown.subParser('makehtml.hashHTMLBlocks')(item, options, globals); + //item = showdown.subParser('makehtml.paragraphs')(item, options, globals); + + // TODO: This is a copy of the paragraph parser + // This is a provisory fix for issue #494 + // For a permanente fix we need to rewrite the paragraph parser, passing the unhashify logic outside + // so that we can call the paragraph parser without accidently unashifying previously parsed blocks + + // Strip leading and trailing lines: + item = item.replace(/^\n+/g, ''); + item = item.replace(/\n+$/g, ''); + + var grafs = item.split(/\n{2,}/g), + grafsOut = [], + end = grafs.length; // Wrap

tags + + for (var i = 0; i < end; i++) { + var str = grafs[i]; + // if this is an HTML marker, copy it + if (str.search(/¨([KG])(\d+)\1/g) >= 0) { + grafsOut.push(str); + + // test for presence of characters to prevent empty lines being parsed + // as paragraphs (resulting in undesired extra empty paragraphs) + } else if (str.search(/\S/) >= 0) { + str = showdown.subParser('makehtml.spanGamut')(str, options, globals); + str = str.replace(/^([ \t]*)/g, '

'); + str += '

'; + grafsOut.push(str); + } + } + item = grafsOut.join('\n'); + // Strip leading and trailing lines: + item = item.replace(/^\n+/g, ''); + item = item.replace(/\n+$/g, ''); + } else { // Recursion for sub-lists: diff --git a/src/subParsers/makemarkdown/table.js b/src/subParsers/makemarkdown/table.js index 1fb1f94..d84e64b 100644 --- a/src/subParsers/makemarkdown/table.js +++ b/src/subParsers/makemarkdown/table.js @@ -55,7 +55,7 @@ showdown.subParser('makeMarkdown.table', function (node, globals) { for (ii = 0; ii < tableArray[i].length; ++ii) { if (i === 1) { if (tableArray[i][ii].slice(-1) === ':') { - tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(-1), cellSpacesCount - 1, '-') + ':'; + tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii].slice(0, -1), cellSpacesCount - 1, '-') + ':'; } else { tableArray[i][ii] = showdown.helper.padEnd(tableArray[i][ii], cellSpacesCount, '-'); } diff --git a/test/functional/makehtml/cases/features/underline/fulltext.html b/test/functional/makehtml/cases/features/underline/fulltext.html index 695b562..22fb5e2 100644 --- a/test/functional/makehtml/cases/features/underline/fulltext.html +++ b/test/functional/makehtml/cases/features/underline/fulltext.html @@ -264,14 +264,17 @@ This is a second.
  • Blue

  • Red

    -
    * Green
    Try this code:
    +        
    * Green
     
    -    This is an embedded code block.
    +    Try this code:
     
    -Then this:
    +        This is an embedded code block.
     
    -    More code!
    -
    * Blue + Then this: + + More code! + +* Blue * Red
  • @@ -365,4 +368,4 @@ This is a code block, fenced-style


    -
    \ No newline at end of file +
    diff --git a/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code-2.html b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code-2.html new file mode 100644 index 0000000..032a50b --- /dev/null +++ b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code-2.html @@ -0,0 +1,10 @@ +
    public static void main(String[] args) {
    +
    +    for (int i = 0; i < 10 && true; i++) {
    +    
    +        System.out.println("Hello World");
    +    }
    +
    +    // stuff here is affected as well <>&&%
    +}
    +
    diff --git a/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code-2.md b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code-2.md new file mode 100644 index 0000000..e3f5944 --- /dev/null +++ b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code-2.md @@ -0,0 +1,11 @@ +``` +public static void main(String[] args) { + + for (int i = 0; i < 10 && true; i++) { + + System.out.println("Hello World"); + } + + // stuff here is affected as well <>&&% +} +``` diff --git a/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code.html b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code.html new file mode 100644 index 0000000..95f5bb5 --- /dev/null +++ b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code.html @@ -0,0 +1,13 @@ +
      +
    1. Code block as part of list

      +
      public static void main(String[] args) {
      +
      +    for (int i = 0; i < 10 && true; i++) {
      +    
      +        System.out.println("Hello World");
      +    }
      +
      +    // stuff here is affected as well <>&&%
      +}
      +
    2. +
    diff --git a/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code.md b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code.md new file mode 100644 index 0000000..b93a9fa --- /dev/null +++ b/test/functional/makehtml/cases/issues/#494.enumerated-code-blocks-are-partially-escaped-when-including-empy-lines-between-code.md @@ -0,0 +1,13 @@ +1. Code block as part of list + + ``` + public static void main(String[] args) { + + for (int i = 0; i < 10 && true; i++) { + + System.out.println("Hello World"); + } + + // stuff here is affected as well <>&&% + } + ```