Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore customizing the markdown renderer for notebooks #106701

Closed
mjbvz opened this issue Sep 15, 2020 · 4 comments · Fixed by #115191
Closed

Explore customizing the markdown renderer for notebooks #106701

mjbvz opened this issue Sep 15, 2020 · 4 comments · Fixed by #115191
Assignees
Labels
api insiders-released Patch has been released in VS Code Insiders markdown Markdown support issues notebook
Milestone

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Sep 15, 2020

Explores letting extensions customize the markdown rendering used in notebooks

@mjbvz mjbvz added markdown Markdown support issues notebook labels Sep 15, 2020
@mjbvz mjbvz added this to the September 2020 milestone Sep 15, 2020
@mjbvz mjbvz self-assigned this Sep 15, 2020
@mjbvz mjbvz modified the milestones: September 2020, October 2020 Sep 28, 2020
@mjbvz mjbvz modified the milestones: October 2020, November 2020 Oct 26, 2020
@mjbvz mjbvz added the feature-request Request for new features or functionality label Nov 3, 2020
@mjbvz

This comment has been minimized.

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jan 23, 2021

Update on our current plans:

You can test out the new extensible markdown support by setting "notebook.experimental.useMarkdownRenderer": true

Fully replacing the markdown renderer

The new notebookMarkdownRenderer contribution point lets an extension contribute its own markdown render fore notebook cells. This contribution is very similar to an output renderer contribution. The contributed renderer code is run inside the backlayer webview and the rendered markdown is also shown in this webview instead of in the main editor dom like our built-in markdown support

For now, we will restrict this API to our internal extensions. We already have an extension that replaces the notebook's markdown renderer with markdown-it, which we believe is extensible enough for most common notebook uses. In the future, we may open this API to let external extensions use their own markdown engine too.

Extending the markdown renderer

Extensions can contribute extensions to the new markdown-it based markdown renderer. Example use cases include adding support for math and emoji in markdown.

These markdown extensions also come in through the notebookMarkdownRenderer contribution point. They also contribute scripts that are run inside the webview. However rather than replacing the markdown renderer, they instead call the extendMarkdownIt global function and are given an instance of markdown-it which they can extend.

For now, we plan on including a simple markdown-it math extension in VS Code. In the future, math support may instead come from an external extension, such as Python or even a dedicated math extension.

TODO

Short term

  • Improve markdown cell drag and drop
  • Make sure links in markdown cells are handled properly
  • Investigate accessibility for markdown cells
  • Make sure new markdown cells don't cause other regressions
  • Use markdown-it as the default renderer for notebooks

Longer term

  • Move math support out of VS Code (either to python or another extension)
  • Create markdown notebook extensions for other features, such as emoji
    • Should these be part of our existing markdown-preview extensions?
  • Figure out how a notebook tells us which markdown features should/shouldn't be enabled
  • Remove our in-editor rendering once it is no longer needed

/cc @rebornix @kieferrm

@rchiodo
Copy link
Contributor

rchiodo commented Feb 2, 2021

Math support might be possible with one of these?
https://www.npmjs.com/package/markdown-it-latex
https://www.npmjs.com/package/markdown-it-texmath

@mjbvz
Copy link
Collaborator Author

mjbvz commented Feb 11, 2021

Merged initial API point. Will continue working on this with #116393

@mjbvz mjbvz added api and removed feature-request Request for new features or functionality labels Feb 23, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api insiders-released Patch has been released in VS Code Insiders markdown Markdown support issues notebook
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@mjbvz @rchiodo and others