Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown mode highlighting isn't CommonMark compliant #21

Closed
b-kelly opened this issue Mar 15, 2021 · 8 comments · Fixed by #176
Closed

Markdown mode highlighting isn't CommonMark compliant #21

b-kelly opened this issue Mar 15, 2021 · 8 comments · Fixed by #176
Assignees
Labels
bug Something isn't working mode - markdown Affects the editor's markdown input mode
Milestone

Comments

@b-kelly
Copy link
Collaborator

b-kelly commented Mar 15, 2021

Umbrella issue to track multiple bugs.

Reported on Meta.SE in the following posts:

@b-kelly b-kelly added the bug Something isn't working label Mar 15, 2021
@Glorfindel83
Copy link

Probably related bug when editing https://meta.stackexchange.com/a/363991/295232:
Screenshot 2021-05-03 at 15 04 02

@b-kelly
Copy link
Collaborator Author

b-kelly commented May 3, 2021

@Glorfindel83 Agreed, that looks related to me and is likely due to the mixing of * (emphasis) and ** (strong emphasis). We use highlight.js as the backing syntax highlighter, which uses regex to detect syntax. My guess is that the regex is not perfect in this scenario and is causing this issue.

Without committing to a specific timeline here (stay tuned), this is relatively high on our priority list to address.

@adunndevster
Copy link

@b-kelly - I've submitted a fix for this issue into the highlight.js. Maybe you can help promote the PR?

It was SUPER simple. Really the parser was just being over vigilant in trying to match the ending characters for bold/italics.

highlightjs/highlight.js#3456

@b-kelly b-kelly added this to the Beta 2 milestone Apr 20, 2022
@V2Blast
Copy link

V2Blast commented May 31, 2022

I just encountered that bold-and-italics problem myself (well, I noticed it a while ago; I just didn't figure out the source of the problem until now). I also noticed something else: If the bolded-and-italicized text occurs within a blockquote, then the rest of the text from that point onwards is also displayed as if it’s grayed-out (i.e. as if it were part of a blockquote), as well as bolded and italicized.

(Another issue with the Stacks editor’s inline preview/"highlighting" in Markdown mode that doesn't seem to have been mentioned above: It behaves as if the syntax for italics/bold formatting works across multiple lines (e.g. with the opening * being on one line and the closing * being on a different line) – even though that's not how the post will actually be rendered when the post is saved.

@yellis
Copy link
Contributor

yellis commented Jun 29, 2022

@b-kelly given that highlightjs/highlight.js#3457 was merged into hljs, is this resolved now (at least in part)? Is stacks editor up to date with hljs?

@b-kelly
Copy link
Collaborator Author

b-kelly commented Jun 29, 2022

Stacks-Editor should be up-to-date with hljs (check package.json for exact version). This issue however still needs a ton of work, likely involving a massive amount of upstream changes or switching to a different highlighting approach entirely (for markdown mode, not the rich-text or baked post).

@yellis
Copy link
Contributor

yellis commented Jun 29, 2022

@b-kelly is it possible to fully define the project somewhere and to potentially break down the work needed into smaller bits?

@yellis
Copy link
Contributor

yellis commented Jul 17, 2022

@b-kelly I just added:

Hopefully will also be addressed in your suggested approach.

If either isn't included here, we should split off into separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mode - markdown Affects the editor's markdown input mode
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants