feat(#137): adds support for md rendering in webview

This commit is contained in:
tdurieux
2022-10-24 08:34:53 +02:00
parent c62b50ffd0
commit 231b2fe0c8
6 changed files with 75 additions and 13 deletions

View File

@@ -5,6 +5,8 @@ import AnonymizedFile from "../AnonymizedFile";
import GitHubDownload from "../source/GitHubDownload";
import AnonymousError from "../AnonymousError";
import { TreeElement } from "../types";
import * as marked from "marked";
import { anonymizeContent, streamToString } from "../anonymize-utils";
const router = express.Router();
@@ -99,7 +101,12 @@ async function webView(req: express.Request, res: express.Response) {
object: f,
});
}
f.send(res);
if ((await f.extension()) == "md") {
const content = await streamToString(await f.anonymizedContent());
res.send(marked.marked(content));
} else {
f.send(res);
}
} catch (error) {
handleError(error, res, req);
}