From 4e826d0ec6f50d44920499462f6f43262fca9a34 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 15 Sep 2026 20:41:37 +0000 Subject: [PATCH] docs: record 14.1.2 release and add linkify pos/size tests @hackmd/markdown-it@14.1.2 is already published. Document the HackMD 14.1.1/14.1.2 fixes and add regression coverage for linkify text-token position/size so autolink highlights keep mapping to the URL. Co-authored-by: Yukai Huang --- CHANGELOG.md | 15 +++++++++++++++ test/annotation.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77653829e..f8920476f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [14.1.2] - 2026-09-15 +### Fixed +- Set `position` and `size` on linkify text tokens so autolink highlights + map to the URL instead of the start of the block, #20. + + +## [14.1.1] - 2025-08-28 +### Fixed +- Handle incorrect `pos`/`size` when `text_special` and `text_join` process + escaped links, #19. +- Restore ZWSP handling after the 14.1.0 merge. + + ## [14.1.0] - 2024-03-19 ### Changed - Updated CM spec compatibility to 0.31.2, #1009. @@ -648,6 +661,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed presets folder (configs -> presets). +[14.1.2]: https://github.com/hackmdio/markdown-it/compare/b412edd7f252808f14ea03049cd04aebefc401a3...1ecb0cd2a2a4e8807d1b49e57e93cb84f55023fd +[14.1.1]: https://github.com/hackmdio/markdown-it/compare/6479bb4046afac05328c9d6a9ab6c1e714e444a1...b412edd7f252808f14ea03049cd04aebefc401a3 [14.1.0]: https://github.com/markdown-it/markdown-it/compare/14.0.0...14.1.0 [14.0.0]: https://github.com/markdown-it/markdown-it/compare/13.0.2...14.0.0 [13.0.2]: https://github.com/markdown-it/markdown-it/compare/13.0.1...13.0.2 diff --git a/test/annotation.js b/test/annotation.js index 241c46d9c..7644f12bf 100644 --- a/test/annotation.js +++ b/test/annotation.js @@ -141,4 +141,46 @@ describe('Annotation', function () { assertTokenContent(src, tokens[28], 'Monde') assertTokenContent(src, tokens[29], '|') }) + + it('should annotate linkify text tokens with pos/size', function () { + const linkifyMd = require('../')({ linkify: true }) + const src = 'See https://example.org/foo for details' + const tokens = linkifyMd.parse(src) + const children = tokens[1].children + const url = 'https://example.org/foo' + + assert.strictEqual(children[0].type, 'text') + assert.strictEqual(children[0].content, 'See ') + assertTokenContent(src, children[0], 'See ') + + assert.strictEqual(children[1].type, 'link_open') + assert.strictEqual(children[1].markup, 'linkify') + + assert.strictEqual(children[2].type, 'text') + assert.strictEqual(children[2].content, url) + assert.strictEqual(children[2].position, 4) + assert.strictEqual(children[2].size, url.length) + assertTokenContent(src, children[2], url) + + assert.strictEqual(children[3].type, 'link_close') + assert.strictEqual(children[4].content, ' for details') + assertTokenContent(src, children[4], ' for details') + }) + + it('should annotate multiple linkify text tokens in one block', function () { + const linkifyMd = require('../')({ linkify: true }) + const src = 'text https://example.org/foo and https://hackmd.io/ more' + const tokens = linkifyMd.parse(src) + const children = tokens[1].children.filter(function (token) { + return token.type === 'text' && token.content.indexOf('http') === 0 + }) + + assert.strictEqual(children.length, 2) + assert.strictEqual(children[0].position, 5) + assert.strictEqual(children[0].size, 'https://example.org/foo'.length) + assertTokenContent(src, children[0], 'https://example.org/foo') + assert.strictEqual(children[1].position, 33) + assert.strictEqual(children[1].size, 'https://hackmd.io/'.length) + assertTokenContent(src, children[1], 'https://hackmd.io/') + }) })