Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
await mume.init();
const engine = new mume.MarkdownEngine({
filePath: "./docs/fullbook.md",
config: {
previewTheme: "github-light.css",
// revealjsTheme: "white.css"
codeBlockTheme: "default.css",
breakOnSingleNewLine: false,
printBackground: true,
enableScriptExecution: true, // <= for running code chunks
},
});
// html export
// await engine.htmlExport({ offline: false, runAllCodeChunks: true });
// console.log("Should be done.");
// chrome (puppeteer) export
async function main() {
await mume.init();
const engine = new mume.MarkdownEngine({
filePath: "./docs/fullbook.md",
config: {
previewTheme: "github-light.css",
// revealjsTheme: "white.css"
codeBlockTheme: "default.css",
breakOnSingleNewLine: false,
printBackground: true,
enableScriptExecution: true, // <= for running code chunks
},
});
// html export
// await engine.htmlExport({ offline: false, runAllCodeChunks: true });
// console.log("Should be done.");
public constructor(private context: vscode.ExtensionContext) {
this.config = MarkdownPreviewEnhancedConfig.getCurrentConfig();
mume
.init() // init markdown-preview-enhanced
.then(() => {
mume.onDidChangeConfigFile(this.refreshAllPreviews.bind(this));
MarkdownEngine.onModifySource(this.modifySource.bind(this));
const extensionVersion = require(path.resolve(
this.context.extensionPath,
"./package.json",
))["version"];
if (extensionVersion !== mume.configs.config["vscode_mpe_version"]) {
mume.utility.updateExtensionConfig({
vscode_mpe_version: extensionVersion,
});
}
});
}
function clickTagA(uri, href) {
href = decodeURIComponent(href);
href = href.replace(/^vscode\-resource:\/\/\//, "file:///");
if (
[".pdf", ".xls", ".xlsx", ".doc", ".ppt", ".docx", ".pptx"].indexOf(
path.extname(href),
) >= 0
) {
utility.openFile(href);
} else if (href.match(/^file\:\/\/\//)) {
// openFilePath = href.slice(8) # remove protocol
let openFilePath = utility.addFileProtocol(
href.replace(/(\s*)[\#\?](.+)$/, ""),
); // remove #anchor and ?params...
openFilePath = decodeURI(openFilePath);
vscode.commands.executeCommand(
"vscode.open",
vscode.Uri.parse(openFilePath),
vscode.ViewColumn.One,
);
} else {
utility.openFile(href);
}
}
) >= 0
) {
utility.openFile(href);
} else if (href.match(/^file\:\/\/\//)) {
// openFilePath = href.slice(8) # remove protocol
let openFilePath = utility.addFileProtocol(
href.replace(/(\s*)[\#\?](.+)$/, ""),
); // remove #anchor and ?params...
openFilePath = decodeURI(openFilePath);
vscode.commands.executeCommand(
"vscode.open",
vscode.Uri.parse(openFilePath),
vscode.ViewColumn.One,
);
} else {
utility.openFile(href);
}
}
const hint = `![Uploading ${imageFileName}… (${uid})]()`;
const curPos = editor.selection.active;
editor.edit((textEditorEdit) => {
textEditorEdit.insert(curPos, hint);
});
const config = vscode.workspace.getConfiguration(
"markdown-preview-enhanced",
);
const AccessKey = config.get("AccessKey") || "";
const SecretKey = config.get("SecretKey") || "";
const Bucket = config.get("Bucket") || "";
const Domain = config.get("Domain") || "";
utility
.uploadImage(imageFilePath, {
method: imageUploader,
qiniu: { AccessKey, SecretKey, Bucket, Domain },
})
.then((url) => {
setUploadedImageURL(imageFileName, url, editor, hint, curPos);
})
.catch((error) => {
vscode.window.showErrorMessage(error.toString());
});
});
}
function openMathJaxConfig() {
const mathjaxConfigFilePath = utility.addFileProtocol(
path.resolve(utility.extensionConfigDirectoryPath, "./mathjax_config.js"),
);
vscode.commands.executeCommand(
"vscode.open",
vscode.Uri.parse(mathjaxConfigFilePath),
);
}
function openKaTeXConfig() {
const katexConfigFilePath = utility.addFileProtocol(
path.resolve(utility.extensionConfigDirectoryPath, "./katex_config.js"),
);
vscode.commands.executeCommand(
"vscode.open",
vscode.Uri.parse(katexConfigFilePath),
);
}
function extendParser() {
const parserConfigPath = utility.addFileProtocol(
path.resolve(utility.extensionConfigDirectoryPath, "./parser.js"),
);
vscode.commands.executeCommand(
"vscode.open",
vscode.Uri.parse(parserConfigPath),
);
}
function openMermaidConfig() {
const mermaidConfigFilePath = utility.addFileProtocol(
path.resolve(utility.extensionConfigDirectoryPath, "./mermaid_config.js"),
);
vscode.commands.executeCommand(
"vscode.open",
vscode.Uri.parse(mermaidConfigFilePath),
);
}