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

message-parser: markdown link parsing is wrong #1131

Open
paviad opened this issue Aug 12, 2023 · 3 comments · May be fixed by #1132
Open

message-parser: markdown link parsing is wrong #1131

paviad opened this issue Aug 12, 2023 · 3 comments · May be fixed by #1132

Comments

@paviad
Copy link

paviad commented Aug 12, 2023

Description

Markdown parsing of links is wrong.

Steps to reproduce

This markdown source: [Title 1] bla bla [Title 2](https://foo.com/title2) should conver to the following html:

<p>[Title 1] bla bla <a href="https://foo.com/title2">Title 2</a>

But is actually converted to:

<p> <a href="https://foo.com/title2">Title 1] bla bla [Title 2</a>

This is the test that (if added to packages/message-parser/tests/link.test.ts) would fail:

  [
    '[Title 1] bla bla [Title 2](https://foo.com/title2)',
    [paragraph([
      plain('[Title 1] bla bla '),
      link('https://foo.com/title2',[plain('Title 2')])
    ])]
  ]

And this would be the failure diff:

      Array [
        Object {
          "type": "PARAGRAPH",
          "value": Array [
            Object {
    -         "type": "PLAIN_TEXT",
    -         "value": "[Title 1] bla bla ",
    -       },
    -       Object {
              "type": "LINK",
              "value": Object {
                "label": Array [
                  Object {
                    "type": "PLAIN_TEXT",
    -               "value": "Title 2",
    +               "value": "Title 1] bla bla [Title 2",
                  },
                ],
                "src": Object {
                  "type": "PLAIN_TEXT",
                  "value": "https://foo.com/title2",

Insert an image/gif

@paviad paviad changed the title <Component Name>: <Short description> markdown link parsing is wrong Aug 12, 2023
@paviad paviad changed the title markdown link parsing is wrong message-parser: markdown link parsing is wrong Aug 12, 2023
@paviad
Copy link
Author

paviad commented Aug 12, 2023

There are many other things this grammar based parsing gets wrong...

@paviad
Copy link
Author

paviad commented Aug 13, 2023

git bisect yields this commit 19690db as the first bad commit

@paviad
Copy link
Author

paviad commented Aug 13, 2023

It turns out that in an attempt to accommodate these cases:

  • the [Jira [Task] parentheses not working](rocket.chat)
  • [Jira [Task] parentheses not working](rocket.chat)

this commit broke the other case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant