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

prefer marked to pandoc for markdown2html #4655

Merged
merged 5 commits into from Jan 26, 2014
Merged

Conversation

minrk
Copy link
Member

@minrk minrk commented Dec 6, 2013

If node is installed, the exact same code will be used to render markdown2html as the live notebook.
Installing marked with npm is not required.


def markdown2html(source):
def markdown2html_marked(source, encoding='utf-8'):
"""Convert a markdown string to HTML via pandoc"""
Copy link
Member

Choose a reason for hiding this comment

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

via marked...

@Carreau
Copy link
Member

Carreau commented Dec 7, 2013

1 comment, still, we used to use python-markdown and removed it for uniformly using pandoc. Not that I am opposed to using marked. But it feel like a step forward for a step back.

@ahmadia
Copy link
Contributor

ahmadia commented Dec 7, 2013

@Carreau - The difference here is that Python Markdown was independent of the parser that was used to present web pages. I think this might be a step sideways.

@minrk
Copy link
Member Author

minrk commented Dec 7, 2013

But it feel[s] like a step forward for a step back.

It certainly is. We have a few choices:

  1. use python-markdown for HTML output
    • + Python dependency
    • - doesn't support the same markdown features (gfm, tables, etc.) as live or pandoc
  2. use pandoc
    • + same reader for markdown all over nbconvert
    • + supports all the same extended markdown as marked (gfm, tables, etc.), and more
    • - but it still parses things a bit differently, especially wrt math / latex, empty lines
  3. use marked
    • + same renderer as live notebook
    • - have to extract/re-add math around it, like we do in js (incorrectly, atm)
    • - depends on node

Honestly, none of these are awesome. In some respects, bringing pandoc up to snuff via either plugins or patches is the most appealing. I think python-markdown is a no-go, with too many unsupported behaviors, unless we want to turn off the extensions in marked.

@ahmadia
Copy link
Contributor

ahmadia commented Dec 7, 2013

  • doesn't support the same markdown features (gfm, tables, etc.) as live or pandoc

I think it supports these via extensions. See this post for an explanation of how to get GFM. I think I've seen something similar for getting MathJax working as well. My biggest concern is that two different code paths will ultimately be untenable, and that we'll either need Python in the browser via a tool like Native Client, or we'll have to live with more Javascript at the command line. Pandoc is an awesome tool, but I don't see it in the browser any time soon.

@takluyver
Copy link
Member

There's a list of extensions for python-markdown here. It includes tables and github style code blocks. Does that get us close to what's supported in the browser?

There are also third party extensions, which include some math/latex tools.

@minrk
Copy link
Member Author

minrk commented Dec 7, 2013

  • We cannot avoid using pandoc (for outputs other than HTML)
  • We cannot avoid using marked (browser-side)

So I am not thrilled about the idea of have at least three markdown implementations to contend with, but it's worth considering if the right extensions can be brought to bear. Right now, I would consider python-markdown the least desirable of the three options.

@damianavila
Copy link
Member

three markdown implementations

😳

if the right extensions can be brought to bear

and with extensions... 😒

Maybe to much cost?

@ellisonbg
Copy link
Member

Just based on principle, I would rather use the same Markdown parser in both the live notebook and nbconvert, even if there are things it doesn't do correctly. Installing node is not too much more painful than pandoc - but we should definitely fall back on pandoc. All that to say, I am probably +1 on using marked in nbconvert. Extra bonus points if we could figure out how to call our own math add/remove code from node for nbconvert.

better consistency with live notebook
required for reusing mathjaxutils in node
where navigator is undefined
now uses the exact same code as the live notebook
@minrk
Copy link
Member Author

minrk commented Jan 14, 2014

This now should use the full code, including mathjaxutils, that we use in the live notebook. Also, it uses our marked, not node's, so the only dependency should be node itself.

@ahmadia
Copy link
Contributor

ahmadia commented Jan 14, 2014

Awesome. Let me know if I can help verify/test this.

@damianavila
Copy link
Member

Travis is 😢, jeje...

@minrk
Copy link
Member Author

minrk commented Jan 15, 2014

tests passing

@minrk
Copy link
Member Author

minrk commented Jan 24, 2014

Merging soon, unless objections.

@damianavila
Copy link
Member

OK, I read it again... it seems ready for me 👍

@ghost ghost assigned jdfreder Jan 26, 2014
minrk added a commit that referenced this pull request Jan 26, 2014
prefer marked to pandoc for markdown2html
@minrk minrk merged commit 07dbfbc into ipython:master Jan 26, 2014
@minrk minrk deleted the marked-nbconvert branch January 26, 2014 23:58
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
prefer marked to pandoc for markdown2html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants