Skip to content

Cannot parse [$ 1+1=2][- [link] ] #1892

@takker99

Description

@takker99

Describe the bug

When a formula notation (e.g., [$ 1+1=2]) is followed immediately by a decoration notation with trailing spaces (e.g., [- [link] ]), scrapbox-parser incorrectly recognizes the entire sequence as a single formula node.
Cosense split them into a formula node and a decoration node as follows:
Image

To Reproduce

Given the following code:

parse("[$ 1+1=2][. [link] ]", { hasTitle: false })

Expected Output

[
  {
    indent: 0,
    type: "line",
    nodes: [
      { type: "formula", raw: "[$ 1+1=2]", formula: "1+1=2" },
      {
        type: "decoration",
        raw: "[- [link] ]",
        rawDecos: "-",
        decos: [ "-" ],
        nodes: [
          {
            type: "link",
            raw: "[link]",
            pathType: "relative",
            href: "link",
            content: "",
          },
          { type: "plain", raw: " ", text: " " }
        ]
      }
    ]
  }
]

Actual Output

[
  {
    indent: 0,
    type: "line",
    nodes: [
      {
        type: "formula",
        raw: "[$ 1+1=2][- [link] ]",
        formula: "1+1=2][- [link]"
      }
    ]
  }
]

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