Add extended markdown notebook renderer sample

This demonstrates how one notebook renderer can extend another one
This commit is contained in:
Matt Bierner
2022-06-27 17:06:11 -07:00
parent adde897872
commit 30e22b38ce
13 changed files with 4788 additions and 2 deletions

View File

@ -0,0 +1,23 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type * as MarkdownIt from 'markdown-it';
import type { RendererContext } from 'vscode-notebook-renderer';
interface MarkdownItRenderer {
extendMarkdownIt(fn: (md: MarkdownIt) => void): void;
}
export async function activate(ctx: RendererContext<void>) {
const markdownItRenderer = await ctx.getRenderer('markdownItRenderer') as MarkdownItRenderer | undefined;
if (!markdownItRenderer) {
throw new Error('Could not load markdownItRenderer');
}
const emoji = require('markdown-it-emoji');
markdownItRenderer.extendMarkdownIt((md: MarkdownIt) => {
return md.use(emoji, {});
})
}