-
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
Showing
8 changed files
with
196 additions
and
19 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Alerts | ||
|
||
Note | ||
Highlights information that users should take into account, even when | ||
skimming. | ||
Tip | ||
Optional information to help a user be more successful. | ||
Important | ||
Crucial information necessary for users to succeed. | ||
Warning | ||
Critical content demanding immediate user attention due to potential risks. | ||
Caution | ||
Negative potential consequences of an action. |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Heading | ||
|
||
list1 | ||
list2 | ||
list3 |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Example | ||
|
||
Shopping list | ||
|
||
Vegetables | ||
Fruits | ||
Fish | ||
tofu |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Block math: | ||
Inline math: |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Normal list | ||
done | ||
not done |
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,12 +1,14 @@ | ||
import { assertEquals, assertStringIncludes } from "@std/assert"; | ||
import { DOMParser } from "https://deno.land/x/[email protected]/deno-dom-wasm.ts"; | ||
import { render, Renderer } from "../mod.ts"; | ||
import { render, Renderer, strip } from "../mod.ts"; | ||
|
||
Deno.test("Basic markdown", async () => { | ||
const markdown = await Deno.readTextFile("./test/fixtures/basic.md"); | ||
const expected = await Deno.readTextFile("./test/fixtures/basic.html"); | ||
const expectedHTML = await Deno.readTextFile("./test/fixtures/basic.html"); | ||
const expectedStrip = await Deno.readTextFile("./test/fixtures/basic.strip"); | ||
const html = render(markdown); | ||
assertEquals(html, expected); | ||
assertEquals(html, expectedHTML); | ||
assertEquals(strip(markdown), expectedStrip); | ||
|
||
const document = new DOMParser().parseFromString(html, "text/html"); | ||
assertEquals(document?.querySelector("h1")?.textContent, "Heading"); | ||
|
@@ -16,8 +18,11 @@ Deno.test("Basic markdown", async () => { | |
Deno.test("Math rendering", async () => { | ||
const math = await Deno.readTextFile("./test/fixtures/math.md"); | ||
const expected = await Deno.readTextFile("./test/fixtures/math.html"); | ||
const expectedStrip = await Deno.readTextFile("./test/fixtures/math.strip"); | ||
const html = render(math, { allowMath: true }); | ||
assertEquals(html, expected); | ||
assertEquals(strip(math), expectedStrip); | ||
|
||
const document = new DOMParser().parseFromString(html, "text/html"); | ||
assertEquals( | ||
document?.querySelector(".katex-mathml")?.textContent, | ||
|
@@ -101,9 +106,13 @@ Deno.test( | |
"alerts rendering", | ||
async () => { | ||
const markdown = await Deno.readTextFile("./test/fixtures/alerts.md"); | ||
const expected = await Deno.readTextFile("./test/fixtures/alerts.html"); | ||
const expectedHTML = await Deno.readTextFile("./test/fixtures/alerts.html"); | ||
const expectedStrip = await Deno.readTextFile( | ||
"./test/fixtures/alerts.strip", | ||
); | ||
const html = render(markdown); | ||
assertEquals(html, expected); | ||
assertEquals(html, expectedHTML); | ||
assertEquals(strip(html), expectedStrip); | ||
}, | ||
); | ||
|
||
|
@@ -349,12 +358,16 @@ Deno.test("details, summary, and del", () => { | |
</details> | ||
`; | ||
const expected = Deno.readTextFileSync( | ||
const expectedHTML = Deno.readTextFileSync( | ||
"./test/fixtures/detailsSummaryDel.html", | ||
); | ||
const expectedStrip = Deno.readTextFileSync( | ||
"./test/fixtures/detailsSummaryDel.strip", | ||
); | ||
|
||
const html = render(markdown); | ||
assertEquals(html, expected); | ||
assertEquals(html, expectedHTML); | ||
assertEquals(strip(markdown), expectedStrip); | ||
}); | ||
|
||
Deno.test("del tag test", () => { | ||
|
@@ -363,6 +376,7 @@ Deno.test("del tag test", () => { | |
|
||
const html = render(markdown); | ||
assertEquals(html, result); | ||
assertEquals(strip(markdown), "tofu\n"); | ||
}); | ||
|
||
Deno.test("h1 test", () => { | ||
|
@@ -372,6 +386,7 @@ Deno.test("h1 test", () => { | |
|
||
const html = render(markdown); | ||
assertEquals(html, result); | ||
assertEquals(strip(markdown), "Hello\n"); | ||
}); | ||
|
||
Deno.test("svg test", () => { | ||
|
@@ -380,16 +395,19 @@ Deno.test("svg test", () => { | |
|
||
const html = render(markdown); | ||
assertEquals(html, result); | ||
assertEquals(strip(markdown), "\n"); | ||
}); | ||
|
||
Deno.test("task list", () => { | ||
const markdown = `- Normal list | ||
- [x] done | ||
- [ ] not done`; | ||
const expected = Deno.readTextFileSync("./test/fixtures/taskList.html"); | ||
const expectedHTML = Deno.readTextFileSync("./test/fixtures/taskList.html"); | ||
const expectedStrip = Deno.readTextFileSync("./test/fixtures/taskList.strip"); | ||
|
||
const html = render(markdown); | ||
assertEquals(html, expected); | ||
assertEquals(html, expectedHTML); | ||
assertEquals(strip(markdown), expectedStrip); | ||
}); | ||
|
||
Deno.test("anchor test raw", () => { | ||
|