★ wanayoo — archive 1999 https://github.com/ipython/ipython/pull/3101/Nouvelle recherche | Portail wanayoo
Skip to content
This repository

use marked / highlight.js instead of pagedown and prettify #3101

Merged
merged 7 commits into from about 1 year ago

3 participants

Min RK Matthias Bussonnier Brian E. Granger
Min RK
Owner
minrk commented

This is an alternative markdown implementation,
which gives us (optionally) a few things:

  • GitHub-flavored markdown (triple-backtick, tables, etc.)
  • html sanitization

We need to think very carefully about whether we want to define the notebook markdown as GHM,
as opposed to vanilla markdown, but even if we turn of GHM support (I hope we don't),
marked's sanitization may still be valuable.

Matthias Bussonnier
Collaborator

That would be really neet, I'm just a little afraid of compatibility with pandoc in nbconvert.
Sure for html we could use node and subprocess, not sure for md -> Tex.

Nice think with highlight callback is we could define other things than highlight like rst environment...or math :-)
Is marked installable with Bower or equivalent ?

Min RK
Owner
minrk commented

Yes, marked is installable with bower / npm / etc.

pandoc (≥ 1.10, I believe, I have 1.11, and I know it doesn't work with 1.9) actually supports both the triple-backtick and GFM table syntax, so I'm not sure there's an issue, other than a minimum version requirement.

Min RK
Owner
minrk commented

One thing we might want to consider is explicitly handling the triple-backtick language spec - as it is now, prettify is still handling the highlighting, and I do not believe that it takes into account the markup supplied by marked (css class of pre tag includes language name), so prettify is still doing autodetection based on content.

Brian E. Granger
Owner

What type of sanitization does this do. The previous markdown library had a pretty decent sanitizer that would allow us to white/black list certain html tags for cleaning. It also make sure that there weren't unclosed tags that would bork the entire page. We were using that sanitizer, but I was planning on enabling it to deal with the security issues we are having in the md cells.

But I am strongly +1 on moving to GFM.

Min RK
Owner
minrk commented

Having looked at it, the marked sanitization isn't particularly useful. basically what it does is prohibit literal HTML, which isn't going to fly. We need to define our sanitization, since it seems like we want to do different things to most sanitizers.

Brian E. Granger
Owner

The code here is really simple and I like it. I would like to play around with it a bit more. But I do think we should try to get prettify properly integrated with the marked syntax highlighting callbacks before merging. Might be trivial:

http://stackoverflow.com/questions/11449837/how-to-let-marked-and-google-code-prettify-work-together

Min RK
Owner
minrk commented

indeed it might, and perhaps we should switch to highlight.js as well.

Brian E. Granger
Owner

Let's have a look at it to see if highlight.js is better supported or has more features. This stuff is pretty simple for us to use, so we should just use the best thing we can.

Brian E. Granger ellisonbg commented on the diff
IPython/frontend/html/notebook/templates/notebook.html
@@ -12,9 +12,6 @@
12 12
 </script>
13 13
 
14 14
 <link rel="stylesheet" href=/old?u=https%3A%2F%2Fgithub.com%2Fipython%2Fipython%2Fpull%2F3101%2F%26quot%3B%7B%7B&y=1999 static_url("components/codemirror/lib/codemirror.css") }}">
15  
-<link rel="stylesheet" href=/old?u=https%3A%2F%2Fgithub.com%2Fipython%2Fipython%2Fpull%2F3101%2F%26quot%3B%7B%7B&y=1999 static_url("css/codemirror-ipython.css") }}">
16  
-
17  
-<link rel="stylesheet" href=/old?u=https%3A%2F%2Fgithub.com%2Fipython%2Fipython%2Fpull%2F3101%2F%26quot%3B%7B%7B&y=1999 static_url("prettify/prettify.css") }}"/>
1
Brian E. Granger Owner
ellisonbg added a note

Get got the prettify css, but missed the js below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Brian E. Granger
Owner

This syntax doesn't seem to work:

https://help.github.com/articles/github-flavored-markdown#newlines

Is this a config setting in marked?

Min RK
Owner
minrk commented

yes, GitHub's annoying newlines is a config setting in marked, and off by default

Brian E. Granger
Owner

Great work, merging!

Brian E. Granger ellisonbg merged commit 2d6f354 into from
Brian E. Granger ellisonbg closed this
Min RK minrk deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.