diff options
author | eug-vs <eug-vs@keemail.me> | 2020-04-07 19:33:28 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-04-07 19:33:28 +0300 |
commit | 8b737b42fff0c0e21f9173e047cae9ed488493f4 (patch) | |
tree | c9e10f913d2dfdf1306dc674302ac59699247f1b /src/lib | |
parent | 5c259810433be8cdbe6fcac8776cdbf4a0c244b0 (diff) | |
download | react-benzin-8b737b42fff0c0e21f9173e047cae9ed488493f4.tar.gz |
feat: support images nested into links
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Markdown/SyntacticSpan.tsx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/Markdown/SyntacticSpan.tsx b/src/lib/Markdown/SyntacticSpan.tsx index 7fd9bc5..f3c2125 100644 --- a/src/lib/Markdown/SyntacticSpan.tsx +++ b/src/lib/Markdown/SyntacticSpan.tsx @@ -24,8 +24,8 @@ const enclosureRegex = (e: string): RegexPair => ({ const regex: Record<string, RegexPair> = { conceal: { - global: /(!?\[.+?\]\(.+?\))/g, - local: /!?\[(.+?)\]\((.+?)\)/ + global: /(!?\[.+?\]\(.+?\))(?!])/g, + local: /!?\[(.*\]?.*)\]\((.+?)\)/ }, rawLink: { global: /((?:(?:[A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)(?:(?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/, @@ -63,7 +63,7 @@ const SyntacticSpan: React.FC<PropTypes> = ({ span }) => { const matchConceal = regex.conceal.local.exec(span); if (matchConceal) { if (span[0] === '!') return <img src={matchConceal[2]} alt={matchConceal[1]} className={classes.image} />; - return <Link href={matchConceal[2]}>{matchConceal[1]}</Link>; + return <Link href={matchConceal[2]}><SyntacticSpan span={matchConceal[1]} /></Link>; } const matchEmoji = span.match(regex.emoji.local); |