syntax-tree / hast-util-raw

utility to reparse a hast tree
https://unifiedjs.com
MIT License
11 stars 4 forks source link

Issues with HTML entities parsing #15

Closed danielepolencic closed 2 years ago

danielepolencic commented 2 years ago

Initial checklist

Affected packages and versions

test with 7.2.0 and 6.0.2

Link to runnable example

No response

Steps to reproduce

import { raw } from "hast-util-raw"

const root = raw({
  type: 'root',
  children: [
    {
      type: 'element',
      tagName: 'span',
      children: [
        {
          type: 'raw',
          value: '/api/v1/&lt;resource-type-name&gt;/&lt;resource-name&gt;', <-- this
        },
      ],
    },
  ],
})

console.log(root)

// {
//   "type": "root",
//   "children": [
//     {
//       "type": "element",
//       "tagName": "span",
//       "properties": {},
//       "children": [
//         {
//           "type": "text",
//           "value": "/api/v1/<resource-type-name>/<resource-name" <-- this
//         }
//       ]
//     }
//   ],
//   "data": {
//     "quirksMode": false
//   }
// }

Expected behavior

The last > is retained.

Actual behavior

The last > is removed.

Runtime

Node v14

Package manager

npm v7

OS

macOS

Build and bundle tools

Other (please specify in steps to reproduce)

wooorm commented 2 years ago

Thanks for the repro, that helped. Complex to track down but it’s solved!