Skip to content

Use markdown-it for rendering markdown#499

Closed
groutr wants to merge 5 commits intojupyterlab:masterfrom
groutr:markdown-it
Closed

Use markdown-it for rendering markdown#499
groutr wants to merge 5 commits intojupyterlab:masterfrom
groutr:markdown-it

Conversation

@groutr
Copy link
Copy Markdown
Contributor

@groutr groutr commented Jul 21, 2016

Markdown typings from https://github.com/rapropos/typed-markdown-it

This PR provides an alternative markdown renderer, markdown-it, intended for easy, side-by-side comparisons with marked.

@jasongrout
Copy link
Copy Markdown
Contributor

huh, it appears the vscode does not use typings for markdown-it: https://github.com/Microsoft/vscode/blob/master/extensions/markdown/src/extension.ts

@jasongrout
Copy link
Copy Markdown
Contributor

You can make the bottom of the markdown-it.d.ts file this to get it working:

declare module "markdown-it" {
  export = MarkdownIt;
}

@groutr
Copy link
Copy Markdown
Contributor Author

groutr commented Jul 21, 2016

@jasongrout Thanks.

@jasongrout
Copy link
Copy Markdown
Contributor

jasongrout commented Jul 21, 2016

I believe what is happening is this:

The original repo had typescript looking for the filename markdown-it.d.ts because the .d.ts file was in the compiler path, i.e., was part of the files that were being compiled already by the compiler. However, in our case, the typings files are not included in the list of files compiled in with the compiler, but instead are explicitly included in the src/typings.d.ts file. It would be hard to switch because tsconfig lacks globbing support in the files parameter (coming in 2.0, see microsoft/TypeScript#8841).

So instead of relying on ts to find a 'markdown-it.d.ts' file, we explicitly declare the module in the file which we are including.

@groutr
Copy link
Copy Markdown
Contributor Author

groutr commented Jul 22, 2016

Turns out we do need to have some delay for updating markdown during model changes. Mathjax rendering is done for every keypress, which can really slow things down a lot.

#445 should help out with reducing redundant renders.


import {
MarkdownWidgetFactory
MarkdownWidgetFactory, MarkdownItWidgetFactory
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! Dueling implementations, I like it!

@jasongrout
Copy link
Copy Markdown
Contributor

Makes sense. I just merged #445.

@groutr
Copy link
Copy Markdown
Contributor Author

groutr commented Jul 22, 2016

The most recent commits allow you to render markdown documents with either marked or markdown-it. This should help with comparing how documents are rendered.
MarkdownWidget = rendered with marked
MarkdownItWidget = rendered with markdown-it

@ellisonbg
Copy link
Copy Markdown
Contributor

What is the status of this PR?

@ellisonbg
Copy link
Copy Markdown
Contributor

Thinking a bit more about how we render markdown in the browser. While I am in favor of using CommonMark, I don't think we should do that only in JupyterLab as it may break notebooks. We would want to change this in both JLab and the classic notebook in a parallel major release. I am going to work on fixing the marked support in JupyterLab for now.

Because of these factors, I am going to close this PR. We can revisit later as we get closer to transitioning to CommonMark in all of our apps.

@ellisonbg ellisonbg closed this Aug 19, 2016
@ellisonbg ellisonbg added this to the 2.0 milestone Aug 19, 2016
@ellisonbg ellisonbg modified the milestones: No action, 2.0 Oct 13, 2016
@ellisonbg ellisonbg changed the title [WIP] markdown-it Use markdown-it for rendering markdown Oct 13, 2016
@lock lock Bot added the status:resolved-locked Closed inactive issues are locked after a while. Please open a new issue for related discussion. label Aug 11, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement pkg:notebook status:resolved-locked Closed inactive issues are locked after a while. Please open a new issue for related discussion. status:Work in Progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants