forked from kisonecat/dvi2html
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdvi2html.js
executable file
·46 lines (42 loc) · 1.19 KB
/
dvi2html.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
import fs from 'fs';
import { Writable } from 'stream';
import { dvi2html } from './dist/index.js';
const filename = process.argv[2];
const stream = fs.createReadStream(filename, { highWaterMark: 256 });
let svg = '';
const myWritable = new Writable({
write(chunk, _encoding, callback) {
svg += chunk.toString();
callback();
}
});
(async () => {
await dvi2html(stream, myWritable);
fs.writeFileSync(
filename.replace(/\.dvi$/, '.html'),
`<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DVI2HTML Testing ${filename.replace(/\.dvi$/, '')}</title>
<link rel="stylesheet" href="fonts.css">
<style>
.svg-container {
margin: 10px auto;
width: -moz-fit-content;
width: fit-content;
height: -moz-fit-content;
height: fit-content;
}
.svg-container svg { overflow: visible; }
</style>
</head>
<body>
<div class="svg-container">${svg}</div>
</body>
</html>
`
);
})();