mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 15:25:01 -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 Operation from "../Operation.mjs";
|
||||||
import MarkdownIt from "markdown-it";
|
import MarkdownIt from "markdown-it";
|
||||||
import hljs from "highlight.js";
|
import hljs from "highlight.js";
|
||||||
import { jsPDF } from "jspdf";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render Markdown operation
|
* Render Markdown operation
|
||||||
|
@ -32,12 +31,6 @@ class RenderMarkdown extends Operation {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
value: false
|
value: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Print to PDF",
|
|
||||||
type: "boolean",
|
|
||||||
value: false
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "Enable syntax highlighting",
|
name: "Enable syntax highlighting",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
@ -52,7 +45,7 @@ class RenderMarkdown extends Operation {
|
||||||
* @returns {html}
|
* @returns {html}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [convertLinks, printto, enableHighlighting] = args,
|
const [convertLinks, enableHighlighting] = args,
|
||||||
md = new MarkdownIt({
|
md = new MarkdownIt({
|
||||||
linkify: convertLinks,
|
linkify: convertLinks,
|
||||||
html: false, // Explicitly disable HTML rendering
|
html: false, // Explicitly disable HTML rendering
|
||||||
|
@ -60,30 +53,16 @@ class RenderMarkdown extends Operation {
|
||||||
if (lang && hljs.getLanguage(lang) && enableHighlighting) {
|
if (lang && hljs.getLanguage(lang) && enableHighlighting) {
|
||||||
try {
|
try {
|
||||||
return hljs.highlight(lang, str).value;
|
return hljs.highlight(lang, str).value;
|
||||||
|
|
||||||
} catch (__) {
|
} catch (__) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
rendered = md.render(input);
|
rendered = md.render(input);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return `<div style="font-family: var(--primary-font-family)">${rendered}</div>`;
|
return `<div style="font-family: var(--primary-font-family)">${rendered}</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,9 +543,7 @@ class OutputWaiter {
|
||||||
if (fileName === null) return;
|
if (fileName === null) return;
|
||||||
|
|
||||||
const data = await dish.get(Dish.HTML);
|
const data = await dish.get(Dish.HTML);
|
||||||
//const printdata = '<meta name="viewport" content="width=900px, initial-scale=0.1" />'
|
//console.log(data, "this is our html")
|
||||||
//const realdata = printdata + data
|
|
||||||
console.log(data, "this is our html")
|
|
||||||
var doc = new jsPDF('p', 'px', 'a4');
|
var doc = new jsPDF('p', 'px', 'a4');
|
||||||
|
|
||||||
const width = doc.internal.pageSize.getWidth();
|
const width = doc.internal.pageSize.getWidth();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue