mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
feat: added latex generation
This commit is contained in:
31
config/plugins/withLatex/webpack.js
Normal file
31
config/plugins/withLatex/webpack.js
Normal file
@@ -0,0 +1,31 @@
|
||||
require('reflect-metadata');
|
||||
require('@babel/register')({
|
||||
extensions: [".es6", ".es", ".jsx", ".js", ".mjs", ".ts"],
|
||||
});
|
||||
const latex = require("node-latex")
|
||||
var Readable = require('stream').Readable
|
||||
const { generateLatex } = require('../../../src/latex');
|
||||
|
||||
module.exports = function (source) {
|
||||
var callback = this.async();
|
||||
const location = this.resourcePath;
|
||||
generateLatex(source, location)
|
||||
.then((result) => {
|
||||
const chunks = [];
|
||||
const input = new Readable();
|
||||
input.push(result);
|
||||
input.push(null);
|
||||
const latexStream = latex(input);
|
||||
latexStream.on('data', (chunk) => {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
})
|
||||
latexStream.on('finish', () => {
|
||||
const result = Buffer.concat(chunks);
|
||||
callback(null, result);
|
||||
})
|
||||
latexStream.on('error', (err) => {
|
||||
callback(err);
|
||||
})
|
||||
})
|
||||
.catch(callback);
|
||||
}
|
||||
Reference in New Issue
Block a user