mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
remove md-it dependency, added undefined check to attachments
This commit is contained in:
parent
ff31f6b577
commit
63142212a1
|
@ -87,7 +87,6 @@
|
|||
"dependencies": {
|
||||
"@enonic/fnv-plus": "^1.3.0",
|
||||
"detect-indent": "^6.0.0",
|
||||
"markdown-it": "^12.3.2",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -22,14 +22,16 @@ export async function activate(ctx: RendererContext<void>) {
|
|||
md.renderer.rules.image = (tokens: MarkdownItToken[], idx: number, options, env, self) => {
|
||||
const token = tokens[idx];
|
||||
const src = token.attrGet('src');
|
||||
const attachments: Record<string, Record<string, string>> = (env.outputItem.metadata as any).custom.attachments;
|
||||
if (attachments) {
|
||||
if (src) {
|
||||
const [attachmentKey, attachmentVal] = Object.entries(attachments[src.replace('attachment:', '')])[0];
|
||||
const b64Markdown = 'data:' + attachmentKey + ';base64,' + attachmentVal;
|
||||
token.attrSet('src', b64Markdown);
|
||||
}
|
||||
// if (env.outputItem.metadata?.custom?.attachments) {
|
||||
// const attachments: Record<string, Record<string, string>> = (env.outputItem.metadata as any).custom.attachments;
|
||||
const attachments: Record<string, Record<string, string>> = env.outputItem.metadata?.custom?.attachments;
|
||||
if (attachments && src) {
|
||||
const [attachmentKey, attachmentVal] = Object.entries(attachments[src.replace('attachment:', '')])[0];
|
||||
const b64Markdown = 'data:' + attachmentKey + ';base64,' + attachmentVal;
|
||||
token.attrSet('src', b64Markdown);
|
||||
}
|
||||
// }
|
||||
//
|
||||
|
||||
if (original) {
|
||||
return original(tokens, idx, options, env, self);
|
||||
|
|
Loading…
Reference in a new issue