fix(v2): strip images and footnotes for excerpt correctly (#2855)

This commit is contained in:
Alexey Pyltsyn 2020-06-01 13:36:02 +03:00 committed by GitHub
parent af912f5a65
commit 1b2744570b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View file

@ -204,16 +204,16 @@ export function createExcerpt(fileString: string): string | undefined {
.replace(/^\#{1,6}\s*([^#]*)\s*(\#{1,6})?/gm, '$1')
// Remove emphasis and strikethroughs.
.replace(/([\*_~]{1,3})(\S.*?\S{0,1})\1/g, '$2')
// Remove images.
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
// Remove footnotes.
.replace(/\[\^.+?\](\: .*?$)?/g, '')
// Remove inline links.
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
// Remove inline code.
.replace(/`(.+?)`/g, '$1')
// Remove images.
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, '')
// Remove blockquotes.
.replace(/^\s{0,3}>\s?/g, '')
// Remove footnotes.
.replace(/\[\^.+?\](\: .*?$)?/g, '')
// Remove admonition definition.
.replace(/(:{3}.*)/, '')
// Remove Emoji names within colons include preceding whitespace.