jupyter / jupyter_markdown

Documentation and tests related to Jupyter's Markdown syntax
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

Question about spec adherance & our general policy. #3

Open mpacer opened 7 years ago

mpacer commented 7 years ago

Are we going to follow the spec when it comes to raw block html?

for example suppose that the following are markdown cells:

<div>[a link in a block](https://google.com)</div>

<span>[a link in a span](https://google.com)</span>

<div>[a link in a block](https://google.com)</div>
<div>[a link in a block](https://google.com)</div>
<div>[a link in a block](https://google.com)</div>  
<span>[a link in a span](https://google.com)</span>

<div>[a link in a block](https://google.com)</div>
<div>[a link in a block](https://google.com)</div>
<div>[a link in a block](https://google.com)</div>
<span>[a link in a span](https://google.com)</span>

<div>[a link in a block](https://google.com)</div>

<div>[a link in a block](https://google.com)</div>
<div>[a link in a block](https://google.com)</div>

<span>[a link in a span](https://google.com)</span>

<div>[a link in a block](https://google.com)</div>

<div>[a link in a block](https://google.com)</div>

If you look at the resultant html from marked you get something that looks like

<div><a href="https://google.com" target="_blank">a link in a block</a></div>

<p><span><a href="https://google.com" target="_blank">a link in a span</a></span></p>
<div><a href="https://google.com" target="_blank">a link in a block</a></div>

<div><a href="https://google.com" target="_blank">a link in a block</a></div>
<div><a href="https://google.com" target="_blank">a link in a block</a></div>
<span><a href="https://google.com" target="_blank">a link in a span</a></span>

<div><a href="https://google.com" target="_blank">a link in a block</a></div>

<div><a href="https://google.com" target="_blank">a link in a block</a></div>
<div><a href="https://google.com" target="_blank">a link in a block</a></div><br><span><a href="https://google.com" target="_blank">a link in a span</a></span>

<div><a href="https://google.com" target="_blank">a link in a block</a></div>
<div><a href="https://google.com" target="_blank">a link in a block</a></div>
<div><a href="https://google.com" target="_blank">a link in a block</a></div>

<p><span><a href="https://google.com" target="_blank">a link in a span</a></span></p>
<div><a href="https://google.com" target="_blank">a link in a block</a></div>
<div><a href="https://google.com" target="_blank">a link in a block</a></div>

Currently mistune interprets none of these links, it's not too hard to modify the MarkdownWithMath class to include the default options needed in order to enable the first example paragraph to be converted correctly on html export. However, the other cases do not behave correctly. Marked is pretty unique in its tendency to parse all of that with inline html as valid.

This is not the first or the only time that this will come up.

I've figured out at least one way to "fix" this behaviour in mistune (relating to whether block html is presumed to be followed by an empty line), but such a "fix" introduces errors elsewhere.

See babelmark2 on these cases for a comparison of a bunch of examples (though not mistune).

NB: I'm going to crosspost this to nbconvert (but for this paragraph) because I want more people to have a say in this conversation. I wish this repo were not private, since I'd want to start the conversation about our general markdown policy here rather than in either nbconvert or the notebook. But in the meantime, it seems to be the biggest issue for nbconvert.

rgbkrk commented 7 years ago

Whoa, didn't realize this was private. What was private about this?

rgbkrk commented 7 years ago

Oh maybe it was fear of people conflating jupyter markdown being something like R Markdown or .ipymd?

mpacer commented 7 years ago

Perhaps? I wasn't sure. Those seem like good enough reasons?

Though, I feel like a good README would disabuse people of that idea.