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

Fix a bug when parsing a list with line breaks #20

Closed
wants to merge 2 commits into from
Closed

Fix a bug when parsing a list with line breaks #20

wants to merge 2 commits into from

Conversation

d0819
Copy link

@d0819 d0819 commented Apr 10, 2023

Hello👋

I am using tryfabric/mack on Slack and I found a bug that I would like to fix with this PR.

Issue

I have found that the code is not converting lists with line breaks correctly. For example:

1.
Monday
2.
Tuesday
3.
Wednesday

The output of the conversion looks like this:

\n\n

Solution

I have fixed this issue by modifying the parseList() function. The issue was caused by the function returning an empty string when tokens[0] was empty, but the actual content could be in tokens[1].

The tokens array could look like this, with one space and one text:

{
  "type": "list_item",
  "raw": "1.\na\n",
  "task": false,
  "loose": false,
  "text": "\na",
  "tokens": [
    {"type": "space", "raw": "\n"},
    {
      "type": "text",
      "raw": "a",
      "text": "a",
      "tokens": [{"type": "text", "raw": "a", "text": "a"}]
    }
  ]
}

@d0819 d0819 closed this by deleting the head repository Jul 27, 2023
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 this pull request may close these issues.

1 participant