Skip to content

Commit

Permalink
* [bug] the markdown plugin can not render highlight codes for marked…
Browse files Browse the repository at this point in the history
….setOptions(highlight)
  • Loading branch information
snowyu committed Nov 11, 2015
1 parent 6952931 commit 16ebf2a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugin/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

if( typeof hljs !== 'undefined' ) {
marked.setOptions({
highlight: function( lang, code ) {
return hljs.highlightAuto( lang, code ).value;
highlight: function( code, lang ) {
return hljs.highlightAuto( code, [lang] ).value;
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions test/simple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Slide 1.1

```js
var a = 1;
```

## Slide 1.2


## Slide 2
36 changes: 36 additions & 0 deletions test/test-markdown-external.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">

<title>reveal.js - Test Markdown</title>

<link rel="stylesheet" href="../css/reveal.css">
<link rel="stylesheet" href="qunit-1.12.0.css">
</head>

<body style="overflow: auto;">

<div id="qunit"></div>
<div id="qunit-fixture"></div>

<div class="reveal" style="display: none;">

<div class="slides">
<section data-markdown="simple.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n"></section>
</div>

</div>

<script src="../lib/js/head.min.js"></script>
<script src="../js/reveal.js"></script>
<script src="../plugin/highlight/highlight.js"></script>
<script src="../plugin/markdown/marked.js"></script>
<script src="../plugin/markdown/markdown.js"></script>
<script src="qunit-1.12.0.js"></script>

<script src="test-markdown-external.js"></script>

</body>
</html>
19 changes: 19 additions & 0 deletions test/test-markdown-external.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


Reveal.addEventListener( 'ready', function() {

QUnit.module( 'Markdown' );

test( 'Vertical separator', function() {
strictEqual( document.querySelectorAll( '.reveal .slides>section>section' ).length, 2, 'found two slides' );
});
test( 'language highlighter', function() {
strictEqual( document.querySelectorAll( '.hljs-keyword' ).length, 1, 'got rendered highlight tag.' );
strictEqual( document.querySelector( '.hljs-keyword' ).innerHTML, 'var', 'the same keyword: var.' );
});


} );

Reveal.initialize();

0 comments on commit 16ebf2a

Please sign in to comment.