Discussions » Greasy Fork镜像 Feedback

Incorrect Markdown Rendering

§
Posted: 01 Juni 2023
Edited: 01 Juni 2023

There is no tab indent for a. b. (sub-item)

Markdown Example:

  1. Item 1

  2. Item 2

a. Item a

b. Item b

Expected Result:

img

Incorrect Result:

img

Related Example:

https://greasyforks.org/en/scripts/429342-microsoft-update-catalog-auto-highlight-the-version-for-your-os

img

§
Posted: 03 Juni 2023

Greasy Fork镜像 uses redcarpet for rendering Markdown. Markdown is not exactly standardized, so not sure you're gonna get exactly what you want.

§
Posted: 03 Juni 2023
Edited: 03 Juni 2023

Hi Jason,

I am not sure whether it is because the space was trimmed in Greasy Fork镜像 or it is wrongly rendered in redcarpet.

I opened issue in redcarpet GitHub.

The markdown example is

1. Item 1

2. Item 2

   a. Item a

   b. Item b

Reproduction JavaScript:

let params = new FormData();
params.append("text", `1. Item 1\n\n2. Item 2\n\n   a. Item a\n\n   b. Item b`);
params.append("markup", 'markdown');
params.append("url", 'false');
params.append(document.querySelector("meta[name='csrf-param']").getAttribute("content"), document.querySelector("meta[name='csrf-token']").getAttribute("content"));


fetch('https://greasyforks.org/preview-markup', { method: 'POST', mode: 'cors', cache: 'no-cache', credentials: 'same-origin', redirect: 'follow', referrerPolicy: 'no-referrer', body: params })
§
Posted: 03 Juni 2023
Edited: 03 Juni 2023

I have noticed that it should be redcarpet's bug.

Is it possible to use javascript library https://marked.js.org/ instead of redcarpet ?

marked.js has 29.8k stars while redcarpet has just 4.9k stars.

marked.js is much mature and correct in terms of markdown rendering.

I am not familar with ruby, but it looks like it can also directly call the javascript library marked.js like this

§
Posted: 03 Juni 2023
Edited: 03 Juni 2023

If marked.js is used instead of redcarpet, Greasy Fork镜像 just have to send the original markdown to the client browser and client browser do the rendering using marked.js

Here is the correct result by using marked.js

img

§
Posted: 30 Januari 2025

Greasy Fork镜像 uses redcarpet for rendering Markdown. Markdown is not exactly standardized, so not sure you're gonna get exactly what you want.

I have checked that, redcarpet is supporting the nested list with the "lax_spacing" option. The "lax_spacing" is already enabled in "greasyfork/app/helpers/user_text_helper.rb".

Just now, I have noticed that this could be the issue of greasyfork itself not redcarpet.


In the first comment of this thread, I typed with spaces before "a." and "b."

However, when I want to quote the text of the first comment, all spaces are removed.

img


Coding below is for Testing

4-space

  1. Item 1

  2. Item 2

    a. Item a

    b. Item b

3-space

  1. Item 1

  2. Item 2

a. Item a

b. Item b

no-space

  1. Item 1

  2. Item 2

a. Item a

b. Item b

§
Posted: 30 Januari 2025

Before Posting

img

After Posting (Quoting the reply)

img


The markdowns for imaging ("![img](xxxxx)"), "###", "##" are also removed by Greasy Fork镜像.

Post reply

Sign in to post a reply.

长期地址
遇到问题?请前往 GitHub 提 Issues。