mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
fix(v2): remove Markdown heading id from excerpt (#4862)
This commit is contained in:
parent
d2e4e60cd5
commit
644f148a8b
|
|
@ -121,6 +121,14 @@ describe('createExcerpt', () => {
|
|||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ex urna, molestie et sagittis ut, varius ac justo.',
|
||||
);
|
||||
});
|
||||
|
||||
test('should create excerpt for heading specified with anchor-id syntax', () => {
|
||||
expect(
|
||||
createExcerpt(dedent`
|
||||
## Markdown title {#my-anchor-id}
|
||||
`),
|
||||
).toEqual('Markdown title');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseMarkdownContentTitle', () => {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ export function createExcerpt(fileString: string): string | undefined {
|
|||
.replace(/(:{3}.*)/, '')
|
||||
// Remove Emoji names within colons include preceding whitespace.
|
||||
.replace(/\s?(:(::|[^:\n])+:)/g, '')
|
||||
// Remove custom Markdown heading id.
|
||||
.replace(/{#*[\w-]+}/, '')
|
||||
.trim();
|
||||
|
||||
if (cleanedLine) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue