vscode/extensions/notebook-markdown-extensions/notebook/emoji.ts
Matt Bierner 9464d14f31
Make notebook renderer activate potentially async (#124647)
* Make notebook renderer activate potentially async

- Allow activate to be `async`
- Make `getRenderer` always return a promise instead of the api result directly

* Add comment on why we use async
2021-05-26 09:15:00 -07:00

21 lines
785 B
TypeScript

/*---------------------------------------------------------------------------------------------
* 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';
const emoji = require('markdown-it-emoji');
export async function activate(ctx: {
getRenderer: (id: string) => any
}) {
const markdownItRenderer = await ctx.getRenderer('markdownItRenderer');
if (!markdownItRenderer) {
throw new Error('Could not load markdownItRenderer');
}
markdownItRenderer.extendMarkdownIt((md: markdownIt.MarkdownIt) => {
return md.use(emoji);
});
}