mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-08 01:46:28 +01:00
cleanup
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Asset, Bundler } from "../../bundler";
|
||||
import { Observable } from "../../observable";
|
||||
import { createEjs } from "../ejs";
|
||||
import { latexToPdf } from "./utils";
|
||||
import { Asset, Bundler } from '../../bundler';
|
||||
import { Observable } from '../../observable';
|
||||
import { createEjs } from '../ejs';
|
||||
import { latexToPdf } from './utils';
|
||||
|
||||
type LatexOptions = {
|
||||
path: string;
|
||||
@@ -23,7 +23,11 @@ const createLatex = ({ template, data, path, bundler }: LatexOptions) => {
|
||||
};
|
||||
return asset;
|
||||
});
|
||||
return bundler.register(`${path}.pdf`, pdf);
|
||||
const url = bundler.register(`${path}.pdf`, pdf);
|
||||
return {
|
||||
url,
|
||||
item: pdf,
|
||||
};
|
||||
};
|
||||
|
||||
export { createLatex };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import latex from "node-latex";
|
||||
import { Readable } from "stream";
|
||||
import latex from 'node-latex';
|
||||
import { Readable } from 'stream';
|
||||
|
||||
const latexToPdf = (doc: string) =>
|
||||
new Promise<Buffer>((resolve, reject) => {
|
||||
@@ -8,14 +8,14 @@ const latexToPdf = (doc: string) =>
|
||||
input.push(doc);
|
||||
input.push(null);
|
||||
const latexStream = latex(input);
|
||||
latexStream.on("data", (chunk) => {
|
||||
latexStream.on('data', (chunk) => {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
});
|
||||
latexStream.on("finish", () => {
|
||||
latexStream.on('finish', () => {
|
||||
const result = Buffer.concat(chunks);
|
||||
resolve(result);
|
||||
});
|
||||
latexStream.on("error", (err) => {
|
||||
latexStream.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user