diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-04-09 16:42:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 16:42:12 +0300 |
commit | ad42e742c04c8302c2bcaf67c07ef215bba04f3b (patch) | |
tree | da29af275ec03232d81938e77c36d894c7093c2f /src/lib/Markdown/SyntacticSpan.tsx | |
parent | b808381b02097a25eb51b14246f7a239a785b347 (diff) | |
parent | d1bcd3348c67cfbcd83178c9710cc54de9f776e8 (diff) | |
download | react-benzin-ad42e742c04c8302c2bcaf67c07ef215bba04f3b.tar.gz |
Merge pull request #9 from eug-vs/md-improve
Markdown extensive features
Diffstat (limited to 'src/lib/Markdown/SyntacticSpan.tsx')
-rw-r--r-- | src/lib/Markdown/SyntacticSpan.tsx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/Markdown/SyntacticSpan.tsx b/src/lib/Markdown/SyntacticSpan.tsx index 299bf87..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]*))?)/, @@ -42,7 +42,6 @@ const splitter = new RegExp(Object.values(regex).map(pair => pair.global.source) const emojiList: Emoji[] = []; Object.keys(emojiLib).forEach(name => emojiList.push({ name, char: emojiLib[name].char })); -console.log({emojiList}) const useStyles = makeStyles(theme => ({ code: { @@ -64,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); |