observablehq / stdlib

The Observable standard library.
https://observablehq.com/@observablehq/standard-library
ISC License
959 stars 83 forks source link

Upgrade Marked (or switch to a different Markdown implementation) #272

Open mootari opened 2 years ago

mootari commented 2 years ago

Given the following Markdown containing a "loose list":

- a
- b
- c

- a
- b
- c

the generated HTML wraps multiple elements in paragraphs:

<ul>
<li>a</li>
<li>b</li>
<li><p>c</p>
</li>
<li><p>a</p>
</li>
<li>b</li>
<li>c</li>
</ul>

resulting in the following appearance: image

Observable currently uses marked 0.3.12. This bug got fixed in marked 0.5.0 (demo, PR).

mootari commented 2 years ago

Aside: I originally intended to have two separate lists. In marked up until version 3.0.0 this can be achieved by separating the lists with two newlines.

From version 3.0.0 and onward marked follows commonmark, which requires a hack to separate the lists.

mbostock commented 2 years ago

We can’t upgrade Marked (used by our md tagged template literal and by extension Markdown cells) until we support standard library versioning. Otherwise we would almost certainly break countless notebooks. Once we have standard library versioning, new notebooks will get a new version of Marked, and old notebooks will be able to opt-in to upgrade.

eagereyes commented 1 year ago

I have a few more weird behaviors…

_Underscore italics_

_Underscore italics with `a_variable_name` embedded_

produces this HTML code (second line ignores the italics):

<p><em>Underscore italics</em></p>
<p>_Underscore italics with <code>a_variable_name</code> embedded_</p>

This works correctly when using asterisks instead of underscores.

This code

Here are escaped backticks \`md\`, and here they are un-escaped inside a code block: `md``` hello

But they work when there's a space: `md`` ` back to normal

produces this output (backticks are sometimes ignored):

<p>Here are escaped backticks `md`, and here they are un-escaped inside a code block: `md``` hello</p>\n<p>But they work when there's a space: <code>md``</code> back to normal</p>

The backtick issues are fixed in the current version, but the underscore confusion seems to persist (but looks a little different). See this test in the Marked playground.

Here's a little notebook with the examples

GordonSmith commented 9 months ago

Another one, which is resolved in newer version of marked:

- [ ] foo
- [X] fooxx

Should be: