From ffbc2f105861088668a3e74ef676dcc976d3cde6 Mon Sep 17 00:00:00 2001 From: hhang <17309584214@163.com> Date: Sun, 27 Sep 2026 13:49:49 +0800 Subject: [PATCH] fix(search): parse inline formatting inside bold text (#2815) --- src/plugins/search/markdown-to-txt.js | 4 ++-- test/unit/search-markdown-to-txt.test.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test/unit/search-markdown-to-txt.test.js diff --git a/src/plugins/search/markdown-to-txt.js b/src/plugins/search/markdown-to-txt.js index 4068c071b9..da99c809a6 100644 --- a/src/plugins/search/markdown-to-txt.js +++ b/src/plugins/search/markdown-to-txt.js @@ -154,8 +154,8 @@ const markdownToTxtRenderer = { return this.parser?.parseInline(token.tokens) || ''; }, - strong({ text }) { - return text; + strong({ tokens }) { + return this.parser?.parseInline(tokens) || ''; }, em({ tokens }) { diff --git a/test/unit/search-markdown-to-txt.test.js b/test/unit/search-markdown-to-txt.test.js new file mode 100644 index 0000000000..449b729cae --- /dev/null +++ b/test/unit/search-markdown-to-txt.test.js @@ -0,0 +1,12 @@ +import { markdownToTxt } from '../../src/plugins/search/markdown-to-txt.js'; + +describe('search markdown to text', () => { + test.each([ + ['**a *formatted* word**', 'a formatted word'], + ['**a `code` word**', 'a code word'], + ['**[link](https://example.org)**', 'link https://example.org'], + ['**plain bold text**', 'plain bold text'], + ])('extracts nested inline content from %s', (markdown, expected) => { + expect(markdownToTxt(markdown)).toBe(expected); + }); +});