mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-11 11:15:24 +03:00
Fix atom.ui.markdown
issue with rendering of HTML in code blocks
This commit is contained in:
parent
62a35bccad
commit
18e0da8baa
@ -1,3 +1,4 @@
|
||||
const dedent = require('dedent');
|
||||
|
||||
describe("Renders Markdown", () => {
|
||||
describe("properly when given no opts", () => {
|
||||
@ -7,6 +8,26 @@ describe("Renders Markdown", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it(`escapes HTML in code blocks properly`, () => {
|
||||
let input = dedent`
|
||||
Lorem ipsum dolor.
|
||||
|
||||
\`\`\`html
|
||||
<p>sit amet</p>
|
||||
\`\`\`
|
||||
`
|
||||
|
||||
let expected = dedent`
|
||||
<p>Lorem ipsum dolor.</p>
|
||||
<pre><code class="language-html"><p>sit amet</p>
|
||||
</code></pre>
|
||||
`
|
||||
|
||||
expect(
|
||||
atom.ui.markdown.render(input).trim()
|
||||
).toBe(expected);
|
||||
})
|
||||
|
||||
describe("transforms links correctly", () => {
|
||||
it("makes no changes to a fqdn link", () => {
|
||||
expect(atom.ui.markdown.render("[Hello World](https://github.com)"))
|
||||
|
@ -249,8 +249,8 @@ function renderMarkdown(content, givenOpts = {}) {
|
||||
|
||||
// Here we can add some simple additions that make code highlighting possible later on,
|
||||
// but doesn't actually preform any code highlighting.
|
||||
md.options.highlight = function(str, lang) {
|
||||
return `<pre><code class="language-${lang}">${str}</code></pre>`;
|
||||
md.options.highlight = function (str, lang) {
|
||||
return `<pre><code class="language-${lang}">${md.utils.escapeHtml(str)}</code></pre>`;
|
||||
};
|
||||
|
||||
// Process disables
|
||||
|
Loading…
Reference in New Issue
Block a user