Skip to content

Commit

Permalink
Correctly escape code blocks. Fixes #316
Browse files Browse the repository at this point in the history
  • Loading branch information
jakearchibald committed Jun 17, 2020
1 parent f8238cc commit 4dfb4d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/markdown-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* limitations under the License.
*/
import { Renderer } from 'marked';
import { escape } from 'marked/src/helpers';
import Prism from 'prismjs';

export function createRenderer() {
Expand All @@ -24,7 +25,9 @@ export function createRenderer() {
}
if (!infostring || infostring.length <= 0) {
return `
<pre class="language-text"><code class="language-text">${code}</code></pre>`;
<pre class="language-text"><code class="language-text">${escape(
code,
)}</code></pre>`;
}
if (!(infostring in Prism.languages)) {
throw Error(`Unsupported language "${infostring}"`);
Expand Down
5 changes: 2 additions & 3 deletions tests/non-js-resources/subtests/service-worker/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ body {

**index.html**

```
<!DOCTYPE html>
```html
<!DOCTYPE html> …
```

**sw.js**
Expand Down

0 comments on commit 4dfb4d2

Please sign in to comment.