Markdown filter: failing existing test + code block newline problem #268

Closed
wants to merge 2 commits into
from

2 participants

@RubenVerborgh

The Markdown filter test fails with Discount 2.1.0 because of newline differences.
Since it is difficult (and not functionally interesting) to try to reconcile the newline differences across different Markdown engines, I suggest to make the test newline-invariant.

Below is the failing test.

filters.test.js test :markdown filter: AssertionError: "<h1>foo</h1>\n\n<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n" == "<h1>foo</h1>\n\n<ul><li>bar</li><li>baz</li></ul>"
    at /Users/ruben/Desktop/jade/test/filters.test.js:56:16
    at next (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:769:25)
    at runSuite (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:787:6)
    at check (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:648:16)
    at runFile (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:652:10)
    at Array.forEach (native)
    at runFiles (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:629:13)
    at run (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:598:5)
    at Object.<anonymous> (/Users/ruben/Library/Tools/node/lib/node/.npm/expresso/0.6.4/package/bin/expresso:851:13)
    at Module._compile (module.js:423:26)


   Failures: 1
@RubenVerborgh

Another problem is that markdown code blocks newlines are broken.

Input

:markdown
  y
      {
        x
          x
      }

Expected output

<p>y</p>
<pre><code>{
  x
    x
}
</code></pre>

Actual output

<p>y</p>
<pre><code>{
  x
    x

}
</code></pre>

Note the extra newline above the closing bracket. Since this is a pre block, this extra newline will show up in the output.

The problem is that Jade surrounds each indentation block by newlines. Since the second x starts a new indentation level, two newlines are written (one for each x).

The solution I'm proposing (which is far from ideal) is a distinct "filter" lexer mode in which filter contents are respected literally, and where a succession of outdents is interpreted as one large outdent. See current implementation, which passes all tests.

@RubenVerborgh RubenVerborgh reopened this Jul 15, 2011
@RubenVerborgh

I also saw it's not just a problem of the Markdown filter; it also occurs when I try to add the same piece of code right into Jade code.

@tj
tj commented Jun 17, 2012

This issue has been inactive for over 2 months so I'm closing it. If you think it's still an issue re-open. - tjbot

@tj tj closed this Jun 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment