PrairieLearn / PrairieLearn

Online problem-driving learning system
http://prairielearn.readthedocs.io/
Other
356 stars 322 forks source link

Markdown support is missing/incomplete #4231

Open firasm opened 3 years ago

firasm commented 3 years ago

I'm using this issue to track all markdown rendering issues.

Headings

This works:

<markdown>
<h1>This is a heading</h1>

# This is also a heading
</markdown>

But this, does not work as expected (extra indent):

<markdown>
    <h1>This is a heading</h1>

# This is also a heading
</markdown>

Similarly, this question from the sample course doesn't show the # Hello, World rendered, but it does when you add a line break after opening the <markdown> tag.

screen_shot_2022-08-03_at_12 12 59_pm_720

Oddly, the behaviour isn't consistent as this simple example does work:

<markdown>
# This is also a heading
</markdown>
screen_shot_2022-08-03_at_12 15 07_pm

Table

I'm not sure if this is a CSS/formatting issue, but if in a question.html I write something like this:

<markdown>
| $\LaTeX$ | Use   | 
| ---------| ----- |
| $\mu_s$  | mu_s  | 
| $\mu_k$  | mu_k  |
| $g$      | g     |
| $\theta$ | theta |
</markdown>

It renders as:

Screen Shot 2021-05-18 at 9 39 48 PM

It should instead render as a table with lines, rows, etc..:

$\LaTeX$ Use
$\mu_s$ mu_s
$\mu_k$ mu_k
$g$ g
$\theta$ theta
echuber2 commented 2 years ago

On the Illinois server, the sample course question at issue is: https://www.prairielearn.org/pl/course/108/question/4111573/preview

pl_markdown_header_bug

firasm commented 2 years ago

Thanks @echuber2 , I'll update to the US server since it's more general.

jonatanschroeder commented 4 weeks ago

Similarly, this question from the sample course doesn't show the # Hello, World rendered, but it does when you add a line break after opening the tag.

From what I could gather, the issue here is that there is a comment in the second line of the file that includes a <markdown> tag. https://github.com/PrairieLearn/PrairieLearn/blob/ee607c24e6461abe4abd4edb6a017292f9461da1/exampleCourse/questions/element/markdown/question.html#L2

This tag (not the one in line 5) is the one that starts the actual markdown processing, so the heading is actually inside an "HTML" tag (the "pl-question-panel"), which causes it to not render markdown until the next line break. I'm reviewing this in #10539.

But this, does not work as expected (extra indent):

<markdown>
    <h1>This is a heading</h1>

# This is also a heading
</markdown>

This is not valid markdown. The 4 extra spaces in the beginning mean that this is a code block.

Table issue: there is indeed no default formatting for tables. You can format it with CSS or by using HTML instead.

firasm commented 4 weeks ago

Ah good catch!

Re: tables - I agree, 3 years ago I thought tables were part of commonmark but they are indeed not.

Thanks for working on updating the markdown library!