mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-24 09:13:07 +02:00
image size are build time
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
var sha1 = require("sha1");
|
||||
var fs = require("fs");
|
||||
var imagesize = require('image-size');
|
||||
|
||||
var execSync = require("child_process").execSync;
|
||||
|
||||
@@ -36,7 +37,6 @@ function escapeBlockLaTeX(source) {
|
||||
var hash = sha1(latex);
|
||||
var filename = "images/latex/" + hash + ".svg";
|
||||
var destination = __dirname + "/../" + filename;
|
||||
var rewrite = '<img className="LaTeX SVG" src="' + filename + '"/>';
|
||||
|
||||
// And only generate if the file doesn't already exist, of course.
|
||||
if (!fs.existsSync(destination)) {
|
||||
@@ -45,6 +45,11 @@ function escapeBlockLaTeX(source) {
|
||||
execSync(cmd);
|
||||
}
|
||||
|
||||
// make sure we hardcode the size of this LaTeX SVG image, because we absolutely
|
||||
// do not want the page to resize in any possible noticable way if we can help it.
|
||||
var img = imagesize(filename);
|
||||
var rewrite = `<img className="LaTeX SVG" src="${filename}" style={{width:"${img.width}ex", height:"${img.height}ex"}} />`;
|
||||
|
||||
newsource += rewrite;
|
||||
}
|
||||
return newsource + source.substring(from);
|
||||
|
Reference in New Issue
Block a user