mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 12:07:00 +02:00
fix(v2): remove Markdown heading id from excerpt (#4862)
This commit is contained in:
parent
d2e4e60cd5
commit
644f148a8b
2 changed files with 10 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue