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

Merged
merged 7 commits into from May 2, 2013

Conversation

Projects
None yet
3 participants
Owner

minrk commented Mar 28, 2013

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.

Owner

Carreau commented Mar 28, 2013

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 ?

Owner

minrk commented Mar 28, 2013

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.

Owner

minrk commented Mar 31, 2013

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.

Owner

ellisonbg commented Apr 13, 2013

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.

Owner

minrk commented Apr 13, 2013

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.

Owner

ellisonbg commented Apr 26, 2013

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

Owner

minrk commented Apr 26, 2013

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

Owner

ellisonbg commented Apr 26, 2013

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.

@@ -12,9 +12,6 @@
</script>
<link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
-<link rel="stylesheet" href="{{ static_url("css/codemirror-ipython.css") }}">
-
-<link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
@ellisonbg

ellisonbg May 2, 2013

Owner

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

Owner

ellisonbg commented May 2, 2013

This syntax doesn't seem to work:

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

Is this a config setting in marked?

Owner

minrk commented May 2, 2013

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

Owner

ellisonbg commented May 2, 2013

Great work, merging!

ellisonbg added a commit that referenced this pull request May 2, 2013

Merge pull request #3101 from minrk/marked
use marked / highlight.js instead of pagedown and prettify

@ellisonbg ellisonbg merged commit 2d6f354 into ipython:master May 2, 2013

1 check passed

default The Travis build passed
Details

@minrk minrk deleted the minrk:marked branch Mar 31, 2014

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014

Merge pull request #3101 from minrk/marked
use marked / highlight.js instead of pagedown and prettify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment