From 77d6455be31daf2e7f9b6fe28d066f55fc5a4752 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 14 Jan 2025 13:38:50 +0900 Subject: [PATCH 1/2] kunai-config: handle Marked v1.0.0 tokens https://github.com/cpprefjp/kunai/pull/145#issuecomment-2587467616 --- js/crsearch/kunai-config.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/js/crsearch/kunai-config.js b/js/crsearch/kunai-config.js index 5210d0a..f29f1ba 100644 --- a/js/crsearch/kunai-config.js +++ b/js/crsearch/kunai-config.js @@ -47,6 +47,32 @@ class ArticleProcessor { this._zoneProc = new Map([ [ Prop.toplevel_category, { + /* Token handlers for Marked >= v1.0.0 */ + 'list': list => { + for (const item of list.get('items')) { + if (item.type !== 'list_item') continue + + let buf = '' + for (const token of item.tokens) { + if (token.type === 'text') + buf += token.text + } + + const m = buf.match(/^([^[]+)\[([^\]]+)\]$/) + if (!m) { + throw new Error(`[BUG] unhandled format ${buf}`) + } + + this._categories.set( + m[2], + new Priority( + this._currentIndex++, m[1] + ) + ) + } + }, + + /* Token handlers for Marked < v1.0.0 */ 'list_item_start': () => { this._single_bufs.push('') }, @@ -67,8 +93,8 @@ class ArticleProcessor { ) }, 'text': token => { - // console.log(token) - this._single_bufs[this._single_bufs.length - 1] += token.get('text').trim() + if (this._single_bufs.length > 0) + this._single_bufs[this._single_bufs.length - 1] += token.get('text').trim() }, } ], From d5d194f2188999ca1e698c99ddb91c823acbf1d9 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 18 May 2024 00:34:58 +0900 Subject: [PATCH 2/2] bump 3.0.24 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 037f17e..8fadc5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "crsearch", - "version": "3.0.23", + "version": "3.0.24", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index f569b79..cea598f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crsearch", - "version": "3.0.23", + "version": "3.0.24", "description": "cpprefjp / boostjp searcher", "main": "dist/js/crsearch.js", "module": "js/crsearch.js",