1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-12 03:34:12 +02:00

start of revision control

This commit is contained in:
Pomax
2015-12-20 15:19:50 -08:00
commit 2e0a7c68d5
77 changed files with 29859 additions and 0 deletions

36
lib/pre-loader.js Normal file
View File

@@ -0,0 +1,36 @@
/**
* <pre> should preserve newlines. Damnit, JSX
*/
var op = "<pre>";
var ed = "</pre>";
function hasTokens(input) {
return input.indexOf(op) + input.indexOf(ed) >= 0;
}
function fixPreBlocks(source) {
// we can't do this with regexp, unfortunately.
var from = 0, curr, term;
var newsource = "", pre;
for(curr = source.indexOf(op, from); curr !== -1; from = term + ed.length, curr = source.indexOf(op, from)) {
newsource += source.substring(from, curr);
term = source.indexOf(ed, from);
if(term === -1) {
// that's a problem...
throw new Error("improperly closed LaTeX encountered!");
}
pre = source.substring(curr, term + ed.length);
pre = pre.replace(/\n/g,"{'\\n'}");
newsource += pre;
}
return newsource + source.substring(from);
}
module.exports = function(source) {
this.cacheable();
if (!hasTokens(source)) return source;
return fixPreBlocks(source);
};