Skip to content

Commit

Permalink
+test case
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Apr 10, 2024
1 parent 59fe20d commit 9460ed1
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/pandoc.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const assert = require("assert");
const fs = require("fs");
const pandoc = require("../lib/pandoc");
const { PassThrough } = require("stream");

describe("OASIS voc build", function () {
it("Pandoc", function () {
var html = "";
pandoc(
{
stdin: fs.createReadStream(`${__dirname}/test-data/pandoc.md`),
stdout: new PassThrough()
.on("data", function (chunk) {
html += chunk.toString();
})
.on("end", function () {
assert.deepStrictEqual(
html.split(/\r\n|\r|\n/),
fs
.readFileSync(`${__dirname}/test-data/pandoc.html`)
.toString()
.split(/\r\n|\r|\n/),
);
}),
},
{
"-c": "style.css",
"-F": `${__dirname}/../lib/md2html.js`,
"--template": "${__dirname}/../assets/template",
},
);
});
});
54 changes: 54 additions & 0 deletions test/test-data/pandoc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>-</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
/* The extra [class] is a hack that increases specificity enough to
override a similar rule in reveal.js */
ul.task-list[class]{list-style: none;}
ul.task-list li input[type="checkbox"] {
font-size: inherit;
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
</style>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container-lg px-3 my-5 markdown-body">
<table>
<thead>
<tr class="header">
<th>Property</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Status</td>
<td><dl><dt><a href="other.html#Open">Open</a><dd>Not yet finished<dt>Closed<dd>No longer open</dl></td>
</tr>
</tbody>
</table>
</div>
<script type="module">
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll(".mermaid").forEach(function(pre) {
pre.style.width = pre.getClientRects()[0].width + "px";
});
});
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";
mermaid.initialize({"startOnLoad":false});
mermaid.run({nodes: document.querySelectorAll(".mermaid code")});
</script>
</body>
</html>
3 changes: 3 additions & 0 deletions test/test-data/pandoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Property|Description
---|---
Status|<dl><dt>[Open](other.md#Open)<dd>Not yet finished<dt>Closed<dd>No longer open</dl>

0 comments on commit 9460ed1

Please sign in to comment.