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

invalid AST range on ListItem #18

Open
azu opened this issue May 23, 2021 · 0 comments · May be fixed by #19
Open

invalid AST range on ListItem #18

azu opened this issue May 23, 2021 · 0 comments · May be fixed by #19

Comments

@azu
Copy link
Contributor

azu commented May 23, 2021

* A
** A**Fail**
* B
** A**Fail**

to be

{
        "type": "Document",
        "children": [
            {
                "type": "List",
                "children": [
                    {
                        "type": "ListItem",
                        "children": [
                            {
                                "type": "Paragraph",
                                "children": [
                                    {
                                        "type": "Str",
                                        "value": "A",
                                        "loc": {
                                            "start": {
                                                "line": 1,
                                                "column": 2
                                            },
                                            "end": {
                                                "line": 1,
                                                "column": 3
                                            }
                                        },
                                        "range": [
                                            2,
                                            3
                                        ],
                                        "raw": "A"
                                    }
                                ],
                                "loc": {
                                    "start": {
                                        "line": 1,
                                        "column": 2
                                    },
                                    "end": {
                                        "line": 1,
                                        "column": 3
                                    }
                                },
                                "range": [
                                    2,
                                    3
                                ],
                                "raw": "A"
                            },
                            {
                                "type": "List",
                                "children": [
                                    {
                                        "type": "ListItem",
                                        "children": [
                                            {
                                                "type": "Paragraph",
                                                "children": [
                                                    {
                                                        "type": "Str",
                                                        "value": "A**Fail**",
                                                        "loc": {
                                                            "start": {
                                                                "line": 2,
                                                                "column": 3
                                                            },
                                                            "end": {
                                                                "line": 2,
                                                                "column": 12
                                                            }
                                                        },
                                                        "range": [
                                                            7,
                                                            16
                                                        ],
                                                        "raw": "A**Fail**"
                                                    }
                                                ],
                                                "loc": {
                                                    "start": {
                                                        "line": 2,
                                                        "column": 3
                                                    },
                                                    "end": {
                                                        "line": 2,
                                                        "column": 12
                                                    }
                                                },
                                                "range": [
                                                    7,
                                                    16
                                                ],
                                                "raw": "A**Fail**"
                                            }
                                        ],
                                        "raw": "",
                                        "loc": {
                                            "start": {
                                                "line": 2,
                                                "column": 3
                                            },
                                            "end": {
                                                "line": 2,
                                                "column": 12
                                            }
                                        },
                                        "range": [
                                            7,
                                            16
                                        ]
                                    }
                                ],
                                "raw": "",
                                "loc": {
                                    "start": {
                                        "line": 2,
                                        "column": 3
                                    },
                                    "end": {
                                        "line": 2,
                                        "column": 12
                                    }
                                },
                                "range": [
                                    7,
                                    16
                                ]
                            }
                        ],
                        "raw": "",
                        "loc": {
                            "start": {
                                "line": 1,
                                "column": 2
                            },
                            "end": {
                                "line": 2,
                                "column": 12
                            }
                        },
                        "range": [
                            2,
                            16
                        ]
                    },
                    {
                        "type": "ListItem",
                        "children": [
                            {
                                "type": "Paragraph",
                                "children": [
                                    {
                                        "type": "Str",
                                        "value": "B",
                                        "loc": {
                                            "start": {
                                                "line": 3,
                                                "column": 2
                                            },
                                            "end": {
                                                "line": 3,
                                                "column": 3
                                            }
                                        },
                                        "range": [
                                            19,
                                            20
                                        ],
                                        "raw": "B"
                                    }
                                ],
                                "loc": {
                                    "start": {
                                        "line": 3,
                                        "column": 2
                                    },
                                    "end": {
                                        "line": 3,
                                        "column": 3
                                    }
                                },
                                "range": [
                                    19,
                                    20
                                ],
                                "raw": "B"
                            },
                            {
                                "type": "List",
                                "children": [
                                    {
                                        "type": "ListItem",
                                        "children": [
                                            {
                                                "type": "Paragraph",
                                                "children": [
                                                    {
                                                        "type": "Str",
                                                        "value": "A**Fail**",
                                                        "loc": {
                                                            "start": {
                                                                "line": 2,
                                                                "column": 3
                                                            },
                                                            "end": {
                                                                "line": 2,
                                                                "column": 12
                                                            }
                                                        },
                                                        "range": [
                                                            7,
                                                            16
                                                        ],
                                                        "raw": "A**Fail**"
                                                    }
                                                ],
                                                "loc": {
                                                    "start": {
                                                        "line": 2,
                                                        "column": 3
                                                    },
                                                    "end": {
                                                        "line": 2,
                                                        "column": 12
                                                    }
                                                },
                                                "range": [
                                                    7,
                                                    16
                                                ],
                                                "raw": "A**Fail**"
                                            }
                                        ],
                                        "raw": "",
                                        "loc": {
                                            "start": {
                                                "line": 2,
                                                "column": 3
                                            },
                                            "end": {
                                                "line": 2,
                                                "column": 12
                                            }
                                        },
                                        "range": [
                                            7,
                                            16
                                        ]
                                    }
                                ],
                                "raw": "",
                                "loc": {
                                    "start": {
                                        "line": 2,
                                        "column": 3
                                    },
                                    "end": {
                                        "line": 2,
                                        "column": 12
                                    }
                                },
                                "range": [
                                    7,
                                    16
                                ]
                            }
                        ],
                        "raw": "",
                        "loc": {
                            "start": {
                                "line": 3,
                                "column": 2
                            },
                            "end": {
                                "line": 2,
                                "column": 12
                            }
                        },
                        "range": [
                            19,  // <= range[0] > range[1] that is invalid range
                            16
                        ]
                    }
                ],
                "raw": "",
                "loc": {
                    "start": {
                        "line": 1,
                        "column": 2
                    },
                    "end": {
                        "line": 2,
                        "column": 12
                    }
                },
                "range": [
                    2,
                    16
                ]
            }
        ],
        "loc": {
            "start": {
                "line": 1,
                "column": 2
            },
            "end": {
                "line": 2,
                "column": 12
            }
        },
        "range": [
            2,
            16
        ],
        "raw": "* A\n** A**Fail**\n* B\n** A**Fail**"
    }

This node range is invalid.

                        "range": [
                            19,  // <= range[0] > range[1] that is invalid range
                            16
                        ]

I noticed the children is not sorted in sometimes.
children[0] is after of children[children.length - 1].

locAndRangeFrom(children) {

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