Initial work

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
Josh-Cena 2021-06-17 17:06:39 +08:00
parent 1b0acc5547
commit 6d3d416f58
No known key found for this signature in database
GPG key ID: C37145B818BDB68F
5 changed files with 15 additions and 9 deletions

View file

@ -36,17 +36,17 @@ export function createExcerpt(fileString: string): string | undefined {
// Remove HTML tags.
.replace(/<[^>]*>/g, '')
// Remove Title headers
.replace(/^\#\s*([^#]*)\s*\#?/gm, '')
.replace(/^#\s*([^#]*)\s*#?/gm, '')
// Remove Markdown + ATX-style headers
.replace(/^\#{1,6}\s*([^#]*)\s*(\#{1,6})?/gm, '$1')
.replace(/^#{1,6}\s*([^#]*)\s*(#{1,6})?/gm, '$1')
// Remove emphasis and strikethroughs.
.replace(/([\*_~]{1,3})(\S.*?\S{0,1})\1/g, '$2')
.replace(/([*_~]{1,3})(\S.*?\S{0,1})\1/g, '$2')
// Remove images.
.replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
.replace(/!\[(.*?)\][[(].*?[\])]/g, '$1')
// Remove footnotes.
.replace(/\[\^.+?\](\: .*?$)?/g, '')
.replace(/\[\^.+?\](: .*?$)?/g, '')
// Remove inline links.
.replace(/\[(.*?)\][\[\(].*?[\]\)]/g, '$1')
.replace(/\[(.*?)\][[(].*?[\])]/g, '$1')
// Remove inline code.
.replace(/`(.+?)`/g, '$1')
// Remove blockquotes.