Closed
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
mdast-util-from-markdown@2.0.0
Link to runnable example
Steps to reproduce
import { fromMarkdown } from "mdast-util-from-markdown";
// const doc = fs.readFileSync("example.md", "utf8");
const doc = `abc _*_ efg`;
const tree = fromMarkdown(doc);
const emphasisEl = tree.children[0].children[1];
const starTextEl = emphasisEl.children[0];
console.log(emphasisEl.position);
// -> {
// start: { line: 1, column: 5, offset: 4 },
// end: { line: 1, column: 12, offset: 11 }
// }
console.log(starTextEl.position);
// -> {
// start: { line: 1, column: 6, offset: 5 },
// end: { line: 1, column: 10, offset: 9 } <-------- Expected end offset is 10
// }
console.log(
doc.substring(
emphasisEl.position.start.offset,
emphasisEl.position.end.offset
)
);
// -> _*_
console.log(
doc.substring(
starTextEl.position.start.offset,
starTextEl.position.end.offset
)
);
// -> * <----------------------------------- Expected: *
Expected behavior
The position.end.offset of html entity escape should be after ;
Actual behavior
The position.end.offset
of html entity escape is one less than expected.
Affected runtime and version
node@20.10.0
Affected package manager and version
npm@10.2.3
Affected OS and version
macOS Ventura 13.6.7
Build and bundle tools
webpack