mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Add extended markdown notebook renderer sample
This demonstrates how one notebook renderer can extend another one
This commit is contained in:
23
notebook-extend-markdown-renderer-sample/src/emoji.ts
Normal file
23
notebook-extend-markdown-renderer-sample/src/emoji.ts
Normal 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, {});
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user