BBob icon indicating copy to clipboard operation
BBob copied to clipboard

Feature request: Add position in the string for each node

Open Maxou44 opened this issue 2 years ago • 1 comments

Thanks for this library, it works well and I didn't found any issue 🚀

It could be nice to add information about each node like the position in the original string and the length of start/end tag (including the separator character, arguments and spaces).

It could be also nice to have the raw inner content of the current tag (if I want to make a [code][/code] tag that don't render anything in it).

For the following string: "example [b=value] my text [/b ] end", we could imagine to add a startTag and endTag with the following informations:

[
  "example",
  " ",
  {
    "tag": "b",
    "attrs": {
      "value": "value"
    },
    startTag: {
      "index": 8,
      "length: 9
    },
    endTag: {
      "index": 26,
      "length: 7
    },
    "content": [
      " ",
      "my",
      " ",
      "text",
      " "
    ]
  },
  " ",
  "end"
]

What do you think?

Maxou44 avatar May 03 '22 20:05 Maxou44

Good idea. It can produce more useful information when error occurs.

JiLiZART avatar May 04 '22 16:05 JiLiZART