Skip to content

Inconsistent parse result for number list with non-plain text #1753

@fabon-f

Description

@fabon-f

Describe the bug

A parse result for number list with non-plain text is inconsistent to one with plain text.

 1. foo
 2. [* bar]
 3. `baz`

Scrapbox text above will be parsed as below:

[
  {
    indent: 1,
    type: "line",
    nodes: [
      {
        type: "numberList",
        raw: "1. foo",
        rawNumber: "1",
        number: 1,
        nodes: [ [Object] ]
      }
    ]
  },
  {
    indent: 1,
    type: "line",
    nodes: [
      {
        type: "numberList",
        raw: "2. ",
        rawNumber: "2",
        number: 2,
        nodes: [] // no child nodes!
      },
      {
        type: "decoration",
        raw: "[* bar]",
        // etc.
      }
    ]
  },
  {
    indent: 1,
    type: "line",
    nodes: [
      {
        type: "numberList",
        raw: "3. ",
        rawNumber: "3",
        number: 3,
        nodes: [] // no child nodes!
      },
      { type: "code", raw: "`baz`", text: "baz" }
    ]
  }
]

2nd and 3rd numberList node doesn't have child nodes, while 1st has.

To Reproduce
Steps to reproduce the behavior:

console.log(parse(
  ` 1. foo
 2. [* bar]
 3. \`baz\``,
  { hasTitle: false },
));

Expected behavior
All numberList node have appropriate children nodes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions