diff --git a/src/plugins/search/markdown-to-txt.js b/src/plugins/search/markdown-to-txt.js index 4068c071b..da99c809a 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 000000000..449b729ca --- /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); + }); +});