mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
added save to pdf operation/cleanup
This commit is contained in:
parent
84aafe76ab
commit
e03a138aa2
2 changed files with 4 additions and 27 deletions
|
@ -7,7 +7,6 @@
|
|||
import Operation from "../Operation.mjs";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import hljs from "highlight.js";
|
||||
import { jsPDF } from "jspdf";
|
||||
|
||||
/**
|
||||
* Render Markdown operation
|
||||
|
@ -32,12 +31,6 @@ class RenderMarkdown extends Operation {
|
|||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
{
|
||||
name: "Print to PDF",
|
||||
type: "boolean",
|
||||
value: false
|
||||
},
|
||||
|
||||
{
|
||||
name: "Enable syntax highlighting",
|
||||
type: "boolean",
|
||||
|
@ -52,38 +45,24 @@ class RenderMarkdown extends Operation {
|
|||
* @returns {html}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [convertLinks, printto, enableHighlighting] = args,
|
||||
const [convertLinks, enableHighlighting] = args,
|
||||
md = new MarkdownIt({
|
||||
linkify: convertLinks,
|
||||
html: false, // Explicitly disable HTML rendering
|
||||
highlight: function(str, lang) {
|
||||
if (lang && hljs.getLanguage(lang) && enableHighlighting) {
|
||||
try {
|
||||
return hljs.highlight(lang, str).value;
|
||||
|
||||
return hljs.highlight(lang, str).value;
|
||||
} catch (__) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}),
|
||||
rendered = md.render(input);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return `<div style="font-family: var(--primary-font-family)">${rendered}</div>`;
|
||||
}
|
||||
|
||||
|
|
|
@ -543,9 +543,7 @@ class OutputWaiter {
|
|||
if (fileName === null) return;
|
||||
|
||||
const data = await dish.get(Dish.HTML);
|
||||
//const printdata = '<meta name="viewport" content="width=900px, initial-scale=0.1" />'
|
||||
//const realdata = printdata + data
|
||||
console.log(data, "this is our html")
|
||||
//console.log(data, "this is our html")
|
||||
var doc = new jsPDF('p', 'px', 'a4');
|
||||
|
||||
const width = doc.internal.pageSize.getWidth();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue