MichaelHatherly / CommonMark.jl

A CommonMark-compliant Markdown parser for Julia.
Other
84 stars 11 forks source link

[Bug?] CommonMark Markdown Table cells are not CommonMark leaf blocks #66

Open schlichtanders opened 8 months ago

schlichtanders commented 8 months ago

better example

it turned out the actual confusion is better grasped by different examples see https://github.com/MichaelHatherly/CommonMark.jl/issues/66#issuecomment-1804258948

original example

given the following text

html_str = "<bond def=\"mu\" unique_id=\"zOnak3/Y4WZl\"><input type='range' min='1' max='5' value='3'/><script>const input_el = currentScript.previousElementSibling; const output_el = currentScript.nextElementSibling; const displays = [\"-3\", \"-1\", \"0\", \"1\", \"3\"]; input_el.addEventListener(\"input\", () => {output_el.value = displays[input_el.valueAsNumber - 1]})</script><output style=' font-family: system-ui; font-size: 15px; margin-left: 3px; transform: translateY(-4px); display: inline-block;'>0</output></bond>"

it works perfectly in HTML, but CommonMark exchanges symbols such that the script does no longer work

"<p><bond def=\"mu\" unique_id=\"zOnak3/Y4WZl\"><input type='range' min='1' max='5' value='3'/><script>const input_el = currentScript.previousElementSibling; const output_el = currentScript.nextElementSibling; const displays = [&quot;-3&quot;, &quot;-1&quot;, &quot;0&quot;, &quot;1&quot;, &quot;3&quot;]; input_el.addEventListener(&quot;input&quot;, () =&gt; {output_el.value = displays[input_el.valueAsNumber - 1]});</script><output style=' font-family: system-ui; font-size: 15px; margin-left: 3px; transform: translateY(-4px); display: inline-block;'>0</output></bond></p> "

EDIT: the above does not parse because the html tag <bond> is non-standard. It is confusing example. Better look at https://github.com/MichaelHatherly/CommonMark.jl/issues/66#issuecomment-1804258948

I am using the following parser

import CommonMark
parser = CommonMark.Parser()
CommonMark.enable!(parser, CommonMark.DollarMathRule())
CommonMark.enable!(parser, CommonMark.TableRule())
parser(html_str)

Motivation

I am using CommonMark to create Pluto interface for Python. There the most intuitive way for interpolation is to interpolate valid html text into the plain markdown string. Hence it would be really really great, if Githubissues.

  • Githubissues is a development platform for aggregating issues.