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

Ordered lists starting with non-1 are not parsed when some content is present before them (micromark 3) #77

Closed
4 tasks done
vadistic opened this issue Jul 23, 2021 · 2 comments
Labels
💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem

Comments

@vadistic
Copy link

vadistic commented Jul 23, 2021

Initial checklist

Affected packages and versions

3.0.0 (via mdast-util-from-markdown 1.0.0)

Please let me know if this issue should be moved to mdast-util-from-markdown, but I think the bug is somewhere in micromark source :)

Link to runnable example

https://codesandbox.io/s/naughty-ptolemy-y62bf?file=/src/index.ts

Steps to reproduce

This is not parsed as list (paragraph before)

Content.

2. Hello
3. world

This is also not parsed as list (empty line before)


2. Hello
3. world

This is parsed as list (when trimmed, start number is correct)

2. Hello
3. world

This is also parsed as list (obviously)

Content 

1. Hello
2. world

Expected behavior

List starting with non-1 numbers are parsed correctly.

Github handles it:

  1. Hello
  2. world

micromark pre-3 also handled it correctly.

Actual behavior

List starting with non-1 numbers are not parsed correctly when some paragraph or even empty line is present before them (in container?) 🤷

Content.

2. Hello
3. world
{
    "type": "root",
    "children": [
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text",
                    "value": "Content.",
                    "position": {
                        "start": {
                            "line": 2,
                            "column": 1,
                            "offset": 1
                        },
                        "end": {
                            "line": 2,
                            "column": 9,
                            "offset": 9
                        }
                    }
                }
            ],
            "position": {
                "start": {
                    "line": 2,
                    "column": 1,
                    "offset": 1
                },
                "end": {
                    "line": 2,
                    "column": 9,
                    "offset": 9
                }
            }
        },
        {
            "type": "paragraph",
            "children": [
                {
                    "type": "text",
                    "value": "2. Hello\n3. world",
                    "position": {
                        "start": {
                            "line": 4,
                            "column": 1,
                            "offset": 11
                        },
                        "end": {
                            "line": 5,
                            "column": 9,
                            "offset": 28
                        }
                    }
                }
            ],
            "position": {
                "start": {
                    "line": 4,
                    "column": 1,
                    "offset": 11
                },
                "end": {
                    "line": 5,
                    "column": 9,
                    "offset": 28
                }
            }
        }
    ],
    "position": {
        "start": {
            "line": 1,
            "column": 1,
            "offset": 0
        },
        "end": {
            "line": 6,
            "column": 1,
            "offset": 29
        }
    }
}

Runtime etc.

I do not think it's build / runtime dependent - it's some construct issue - but it happens both in browser & node - windows & linux.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jul 23, 2021
@vadistic vadistic changed the title Ordered lists starting with non-1 are not parsed when previous content is present in container (micromark 3) Ordered lists starting with non-1 are not parsed when some content is present before them (micromark 3) Jul 23, 2021
@wooorm wooorm closed this as completed in faf5a6c Jul 24, 2021
@wooorm wooorm added the 💪 phase/solved Post is done label Jul 24, 2021
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jul 24, 2021
@wooorm
Copy link
Member

wooorm commented Jul 24, 2021

Great catch! Weird that that wasn’t tested. So many edge cases in markdown!

@wooorm
Copy link
Member

wooorm commented Jul 24, 2021

Released!

@wooorm wooorm added 🐛 type/bug This is a problem 👶 semver/patch This is a backwards-compatible fix labels Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants