-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a41d36
commit cd98fec
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { DOMParser } from "https://deno.land/x/[email protected]/deno-dom-wasm.ts"; | ||
import { render } from "../mod.ts"; | ||
import { render, Renderer } from "../mod.ts"; | ||
|
||
Deno.test("Basic markdown", async () => { | ||
const markdown = await Deno.readTextFile("./test/fixtures/basic.md"); | ||
|
@@ -79,3 +79,20 @@ Deno.test( | |
assertEquals(html, expected); | ||
}, | ||
); | ||
|
||
Deno.test( | ||
"custom renderer", | ||
() => { | ||
const markdown = `# hello world`; | ||
const expected = `<h1 id="custom-renderer">hello world</h1>`; | ||
|
||
class CustomRenderer extends Renderer { | ||
heading(text: string, level: 1 | 2 | 3 | 4 | 5 | 6): string { | ||
return `<h${level} id="custom-renderer">${text}</h${level}>`; | ||
} | ||
} | ||
|
||
const html = render(markdown, { renderer: new CustomRenderer({}) }); | ||
assertEquals(html, expected); | ||
}, | ||
); |