-
Notifications
You must be signed in to change notification settings - Fork 17
/
initex.js
145 lines (123 loc) · 4.9 KB
/
initex.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var fs = require('fs');
var library = require('./library');
var binary = fs.readFileSync('tex-async.wasm');
var code = new WebAssembly.Module(binary);
var pages = 2500;
var memory = new WebAssembly.Memory({initial: pages, maximum: pages});
library.setInput("*latex.ltx\n\\dump\n\n",
function() {
});
library.setMemory(memory.buffer);
var wasm = new WebAssembly.Instance(code, { library: library,
env: { memory: memory } } );
const wasmExports = wasm.exports;
library.setWasmExports( wasmExports );
wasm.exports.main();
let preamble = "\\documentclass{article}\n\\usepackage{nopageno}\n\\def\\pgfsysdriver{pgfsys-ximera.def}\\usepackage{tikz}\n\\usepackage[paperheight=100in,paperwidth=8.5in]{geometry}\n";
preamble = "\\documentclass{article}\n\\usepackage{nopageno}\n\\def\\pgfsysdriver{pgfsys-ximera.def}\\usepackage{tikz}\n";
//preamble = "";
//preamble = "\\documentclass[margin=0pt]{standalone}\n\\def\\pgfsysdriver{pgfsys-ximera.def}\\usepackage{tikz}\n";
//preamble = "\\RequirePackage[makeroom]{cancel}\n\\RequirePackage{url}\n\\RequirePackage[table]{xcolor}\n\\RequirePackage{tikz}\n\\RequirePackage{pgfplots}\n\\usepgfplotslibrary{groupplots}\n\\usetikzlibrary{calc}\n\\RequirePackage{fancyvrb}\n\\RequirePackage{forloop}\n\\RequirePackage{amssymb}\n\\RequirePackage{amsmath}\n\\RequirePackage{amsthm}\n\\RequirePackage{xifthen}\n\\RequirePackage{multido}\n\\RequirePackage{listings}\n\\RequirePackage{comment}\n\\RequirePackage{gettitlestring}\n\\RequirePackage{nameref}\n\\RequirePackage{epstopdf}";
//preamble = "\\RequirePackage[makeroom]{cancel}\n\\RequirePackage{url}\n\\RequirePackage[table]{xcolor}\n\\RequirePackage{tikz}\n\\RequirePackage{pgfplots}\n\\usepgfplotslibrary{groupplots}\n\\usetikzlibrary{calc}\n\\RequirePackage{fancyvrb}\n\\RequirePackage{forloop}\n\\RequirePackage{amssymb}\n\\RequirePackage{amsmath}\n\\RequirePackage{amsthm}\n\\RequirePackage{xifthen}\n\\RequirePackage{multido}\n\\RequirePackage{listings}\n\\RequirePackage{comment}\n\\RequirePackage{gettitlestring}\n\\RequirePackage{nameref}\n\\RequirePackage{epstopdf}";
//preamble = "\\def\\pgfsysdriver{pgfsys-ximera.def}\\RequirePackage[makeroom]{cancel}\n\\RequirePackage{url}\n\\RequirePackage[table]{xcolor}\n\\RequirePackage{tikz}\n\\RequirePackage{pgfplots}\n\\usepgfplotslibrary{groupplots}\n\\usetikzlibrary{calc}\n\\RequirePackage{fancyvrb}\n\\RequirePackage{forloop}\n\\RequirePackage{amssymb}\n\\RequirePackage{amsmath}\n\\RequirePackage{amsthm}\n\\RequirePackage{xifthen}\n\\RequirePackage{multido}\n\\RequirePackage{comment}\n\\RequirePackage{gettitlestring}\n\\RequirePackage{nameref}\n\\RequirePackage{pgffor}\n\\RequirePackage{array}\n\\RequirePackage{tkz-euclide}\n\\RequirePackage{tikz-cd}\n";
libraries = [
"calc",
"positioning",
"fit",
"backgrounds",
"trees",
"arrows",
"shapes",
"shapes.geometric",
"shapes.misc",
"shapes.symbols",
"shapes.arrows",
"shapes.callouts",
"shapes.multipart",
"decorations.text",
"3d",
"angles",
"babel",
"decorations.markings",
"decorations.shapes",
"intersections",
"patterns",
"quotes",
"shadows",
"fadings",
"through",
"pgfplots.groupplots"
]
let tikzlibraries = libraries.map( (library) => `\\usetikzlibrary{${library}}` ).join('')
packages = [
"listings",
"lstmisc",
"everyhook",
"svn-prov",
"etoolbox",
"xcolor",
"url",
"fancyvrb",
"keyval",
"tkz-euclide",
"tikz",
"tikz-cd",
"pgf",
"pgfrcs",
"pgffor",
"pgfkeys",
"pgfplots",
"forloop",
"ifthen",
"environ",
"trimspaces",
"amssymb",
"amsfonts",
"amsmath",
"amstext",
"amsgen",
"amsbsy",
"amsopn",
"amsthm",
"xifthen",
"calc",
"ifmtarg",
"multido",
"comment",
"gettitlestring",
"kvoptions",
"ltxcmds",
"kvsetkeys",
"nameref",
"refcount",
"infwarerr",
"fontenc",
"hyperref",
"iftex",
"pdftexcmds",
"kvdefinekeys",
"pdfescape",
"hycolor",
"letltxmacro",
"auxhook",
"intcalc",
"etexcmds",
"bitset",
"bigintcalc",
"atbegshi-ltx",
"rerunfilecheck",
"ifvtex"
]
preamble = "\\def\\pgfsysdriver{pgfsys-ximera.def}\\PassOptionsToPackage{dvisvgm}{graphicx}\\PassOptionsToPackage{hypertex}{hyperref}\\RequirePackage{expl3}\\RequirePackage[makeroom]{cancel}" + packages.map( (package) => `\\RequirePackage{${package}}` ).join('') + tikzlibraries + "\\PassOptionsToClass{web}{ximera}\\let\\abovecaptionskip=\\relax\\let\\belowcaptionskip=\\relax\\let\\maketitle=\\relax\n";
preamble = preamble + "\\documentclass{ximera}\\renewcommand{\\documentclass}[2][]{}\\snapshot\n";
library.setMemory(memory.buffer);
library.setInput("\n&latex\n" + preamble + "\n\n\n",
function() {
var buffer = new Uint8Array( memory.buffer );
fs.writeFileSync('core.dump', buffer);
process.exit();
});
var wasm = new WebAssembly.Instance(code, { library: library,
env: { memory: memory } } );
console.log( wasm.exports );
wasm.exports.main();