const test = require("ava"); const md = require("markdown-it"); const markdownPrismJsOptions = require("../src/markdownSyntaxHighlightOptions"); test("Test Markdown Highlighter", t => { let mdLib = md(); mdLib.set({ highlight: markdownPrismJsOptions({ alwaysWrapLineHighlights: true }) }); t.is(mdLib.render(`\`\`\`js alert(); \`\`\``).trim(), `
alert();
`); }); test("Test Markdown Highlighter No Line Highlights", t => { let mdLib = md(); mdLib.set({ highlight: markdownPrismJsOptions() }); t.is(mdLib.render(`\`\`\`js alert(); \`\`\``).trim(), `
alert();
`); }); test("Markdown with `preAttributes`", t => { let mdLib = md(); mdLib.set({ highlight: markdownPrismJsOptions({ alwaysWrapLineHighlights: true, preAttributes: { // will override class="language-js" class: ({language}) => "not-a-lang-" + language } }) }); t.is(mdLib.render(`\`\`\`js alert(); \`\`\``).trim(), `
alert();
`); }); test("Test Njk Alias", t => { let mdLib = md(); mdLib.set({ highlight: markdownPrismJsOptions() }); t.is(mdLib.render(`\`\`\`njk {% raw %}hello{% endraw %} \`\`\``).trim(), `
{% raw %}hello{% endraw %}
`); }); test("Test Nunjucks Alias", t => { let mdLib = md(); mdLib.set({ highlight: markdownPrismJsOptions() }); t.is(mdLib.render(`\`\`\`nunjucks {% raw %}hello{% endraw %} \`\`\``).trim(), `
{% raw %}hello{% endraw %}
`); }); // test("Test Markdown Highlighter Block Comment", t => { // let mdLib = md(); // mdLib.set({ // highlight: markdownPrismJsOptions({ alwaysWrapLineHighlights: true }) // }); // t.is(mdLib.render(`\`\`\`js // /* // * this is a string // */ // \`\`\``).trim(), `
/*
* this is a string
*/
`); // }); // TODO this still ain’t working right with the line highlighter. // test("Test Markdown Highlighter GraphQL Example", t => { // let mdLib = md(); // mdLib.set({ // highlight: markdownPrismJsOptions({ alwaysWrapLineHighlights: true }) // }); // t.is(mdLib.render(`\`\`\`js // var schema = buildSchema(\`type Query { // hello: String // }\`); // \`\`\``).trim(), ``); // });