import { test, expect } from 'vitest' import { removeNonCodeWrappedHTML } from 'node/utils/parseHeader' test('removeNonCodeWrappedHTML', () => { const asserts: Record = { // Remove tail html '# H1 ': '# H1 ', '# H1': '# H1', '# H1 ': '# H1 ', '# H1': '# H1', '# H1 ': '# H1 ', '# H1': '# H1', '# H1 ': '# H1 ', '# H1': '# H1', // Reserve code-wrapped tail html '# H1 ``': '# H1 ``', '# H1 ``': '# H1 ``', '# H1 ``': '# H1 ``', '# H1 ``': '# H1 ``', // Remove leading html '# H1': '# H1', '# H1': '# H1', '# H1': '# H1', '# H1': '# H1', '# H1': '# H1', '# H1': '# H1', '# H1': '# H1', '# H1': '# H1', // Reserve code-wrapped leading html '# `` H1': '# `` H1', '# `` H1': '# `` H1', '# `` H1': '# `` H1', '# `` H1': '# `` H1', // Remove middle html '# H1 H2': '# H1 H2', '# H1 H2': '# H1 H2', '# H1 H2': '# H1 H2', '# H1 H2': '# H1 H2', // Reserve code-wrapped middle html '# H1 `` H2': '# H1 `` H2', '# H1 `` H2': '# H1 `` H2', '# H1 `` H2': '# H1 `` H2', '# H1 `` H2': '# H1 `` H2', // vuepress #2688 '# \\': '# \\' } Object.keys(asserts).forEach((input) => { expect(removeNonCodeWrappedHTML(input)).toBe(asserts[input]) }) })