Closed Alteras1 closed 4 months ago
Latest commit: 3af485abd2aedac0f264933fdd5f0074dea5330e
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Good work! I will check it later 👍
All looks good for me! 👍
Adds start and end position of the start/end of tag nodes. This gives developers more control in debugging issues. This also allows developers to perform manual string manipulation beyond the limitations of the parser.
will parse to:
An example of string manipulation usage
```js const str = '[font=Source Sans 3]text[/font]' ``` parses to: ```js [ { tag: 'bar', attrs: { 3: "3", "Source": "Source" "Sans": "Sans" }, content: [text'], start: { from: 0, to: 19, }, end: { from: 23, to: 29, }, }, ]; ``` Since quotes was not used and there is a single integer by itself, recovering the original full single value would be impossible without using string manipulation. ```js const isSingleValue = (attrs) => { const keys = Object.keys(attrs).join(" "); const vals = Object.values(attrs).join(" "); return keys === vals; } font: (node) => { let value = ''; if (Object.values(node.attrs).length > 1 && isSingleValue(node.attrs)) { value = str.substring(node.start.from + 5, node.start.to - 1).trim(); // value = "Source Sans 3" } ... } ```Improves accuracy of row/col error reporting. Now targets the start of the relevant token instead of the end.
Closes #134
Edit: Update description to reflect simpler language