syntax-tree / hast-util-raw

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

word in a raw node value getting duplicated #16

Closed MoLow closed 2 years ago

MoLow commented 2 years ago

Initial checklist

Affected packages and versions

hast-util-raw 7.2.1

Link to runnable example

https://stackblitz.com/edit/node-h5dh1f?file=index.js

Steps to reproduce

this was discovered in node.js docs, see https://github.com/nodejs/node/issues/43864 provided a minimal repro in stackblitz where the last word in this case is repeated

Expected behavior

the output of

import { raw } from 'hast-util-raw';

const children = [
  { type: 'raw', value: 'this is a thing' },
  { type: 'raw', value: '<sup>' },
  { type: 'text', value: 'b' },
  { type: 'raw', value: '</sup>' },
];

console.log(raw({ type: 'root', children }));

should be

{
  type: 'root',
  children: [
    { type: 'text', value: 'this is a thing' },
    {
      type: 'element',
      tagName: 'sup',
      properties: {},
      children: [Array]
    }
  ],
  data: { quirksMode: false }
}

Actual behavior

the word thing is duplicated (changing to another word will result with the same issue):

{
  type: 'root',
  children: [
    { type: 'text', value: 'this is a thingthing' },
    {
      type: 'element',
      tagName: 'sup',
      properties: {},
      children: [Array]
    }
  ],
  data: { quirksMode: false }
}

Affected runtime and version

node18, node 16

Affected package manager and version

npm@8.11.0

Affected OS and version

any

Build and bundle tools

No response

wooorm commented 2 years ago

Thanks, found it!

github-actions[bot] commented 2 years ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

wooorm commented 2 years ago

Released!

MoLow commented 2 years ago

Thanks!