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

flavored-markdown lists don't properly handle CRLF line terminators #1987

Closed
DersJ opened this issue Nov 7, 2022 · 1 comment
Closed

flavored-markdown lists don't properly handle CRLF line terminators #1987

DersJ opened this issue Nov 7, 2022 · 1 comment

Comments

@DersJ
Copy link
Contributor

DersJ commented Nov 7, 2022

Background knowledge
Unix and DOS based systems use different line terminators:

  • Unix: \n (newline)
  • DOS: \r\n (carriage-return line-feed, CRLF)

Describe the bug

The regex used to identify markdown lists doesn't properly handle /r/n line terminations, causing unintended behavior in our flavored-markdown.

To Reproduce
I found this issue while working on Vantage Console in-product help, which utilizes Covalent markdown-navigator & flavored-markdown.

We want to display relative and external links within help .md files. However, the links in some files are not rendering as intended. (See screenshot below).

Screen Shot 2022-11-07 at 3 04 02 PM

In other cases, both relative and external links are working fine:
Screen Shot 2022-11-07 at 3 37 02 PM

The difference is caused by the line termination on these two files. The improper, first screenshot has only \n unix-style line terminators, while the properly displayed API guide has \r\n.

Looking at the code, the intention is for flavored-markdown to identify markdown lists and convert them to the cfm-list component. But, the cfm-list only displays the raw list item content; It doesn't identify and convert links to <a> tags.

When processing a markdown file with CRLF line termination, the regex used to identify markdown lists doesn't return any matches, so flavored-markdown doesn't convert markdown lists to the custom cfm-list component. Those links are rendered properly with the vanilla showdown link styling.

Screen Shot 2022-11-07 at 3 33 07 PM

Expected behavior
flavored-markdown should accept markdown with either unix or dos style line termination, and should render links in lists properly

Suggested fix
Remove the cfm list entirely, and just use the default list built into showdown. Then all line termination styles will be properly rendered.

Alternatively, we could update the regex to match both \n and \r\n, and add logic to convert md links to <a> tags in the cfm-list component. This requires significantly more engineering effort.

@owilliams320 @jeremysmartt is there a reason to keep the cfm-list component? Or can we remove and use the default showdown styling?

@DersJ
Copy link
Contributor Author

DersJ commented Nov 7, 2022

This is fixed under #1984

@DersJ DersJ closed this as completed Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant