dart-lang / markdown

A Dart markdown library

Home Page:https://pub.dev/packages/markdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Single Newline Before URLs Not Resulting in Correct Link Rendering

csondi10 opened this issue · comments

Environment

  • flutter_markdown package version: 0.6.18
  • Dart SDK version: 3.1.5
  • Flutter version: 3.13.9

Description

The flutter_markdown package, which relies on the markdown package for rendering Markdown content, is not recognizing URLs as links when they are preceded by a single newline. This issue appears to be stemming from the markdown package itself, as the same behavior is observed when Markdown content is rendered on the Dart package's live example site.

Expected Behavior

A URL that follows a single newline should be automatically recognized and rendered as a hyperlink.

Actual Behavior

When there is a single newline before a URL, it is not being rendered as a hyperlink.

Steps to Reproduce

  1. Provide the following Markdown content to be parsed and rendered by the markdown package:
    Here is a link, displayed correctly: https://example.com
    Here is a link, displayed wrong:
    https://example.com
    
    Here is another link after an empty line:
    
    https://example.com
  2. View the rendering result either within a flutter_markdown widget or on the Dart package's live example site at https://dart-lang.github.io/markdown/.
  3. Notice that the second URL (with a single newline before it) is not clickable, while the first and third ones are rendered correctly as a hyperlink.

Expected vs Actual

  • Expected Behavior (Correctly rendered as links):

  • Actual Behavior (URL not rendered as a link):

The inconsistency leads to a worse UX in our app. Of course we could resolve it with workarounds but it would be beneficial for the markdown package to align with the behavior seen on platforms like GitHub and other Markdown previewers.

Thank you for your attention to this matter, and I am looking forward to your response and a resolution.