From 5c259810433be8cdbe6fcac8776cdbf4a0c244b0 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 7 Apr 2020 15:31:00 +0300 Subject: fix: account for \r line endings, remove consoles --- src/lib/Markdown/SyntacticSpan.tsx | 1 - 1 file changed, 1 deletion(-) (limited to 'src/lib/Markdown/SyntacticSpan.tsx') diff --git a/src/lib/Markdown/SyntacticSpan.tsx b/src/lib/Markdown/SyntacticSpan.tsx index 299bf87..7fd9bc5 100644 --- a/src/lib/Markdown/SyntacticSpan.tsx +++ b/src/lib/Markdown/SyntacticSpan.tsx @@ -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: { -- cgit v1.2.3 From 8b737b42fff0c0e21f9173e047cae9ed488493f4 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 7 Apr 2020 19:33:28 +0300 Subject: feat: support images nested into links --- src/lib/Markdown/SyntacticSpan.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/Markdown/SyntacticSpan.tsx') 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 = { 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 = ({ span }) => { const matchConceal = regex.conceal.local.exec(span); if (matchConceal) { if (span[0] === '!') return {matchConceal[1]}; - return {matchConceal[1]}; + return ; } const matchEmoji = span.match(regex.emoji.local); -- cgit v1.2.3 From 2c5fa193541eb8b74974731d01312f73951bca17 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 18 Apr 2020 20:26:32 +0300 Subject: style: correct some errors with eslint --fix --- src/lib/Markdown/SyntacticSpan.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/lib/Markdown/SyntacticSpan.tsx') diff --git a/src/lib/Markdown/SyntacticSpan.tsx b/src/lib/Markdown/SyntacticSpan.tsx index f3c2125..bdce3f7 100644 --- a/src/lib/Markdown/SyntacticSpan.tsx +++ b/src/lib/Markdown/SyntacticSpan.tsx @@ -19,24 +19,24 @@ interface Emoji { const enclosureRegex = (e: string): RegexPair => ({ local: new RegExp(`${e}([^${e}]+)${e}`), - global: new RegExp(`(${e}[^${e}]+${e})`) + global: new RegExp(`(${e}[^${e}]+${e})`), }); const regex: Record = { conceal: { global: /(!?\[.+?\]\(.+?\))(?!])/g, - local: /!?\[(.*\]?.*)\]\((.+?)\)/ + local: /!?\[(.*\]?.*)\]\((.+?)\)/, }, rawLink: { global: /((?:(?:[A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)(?:(?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/, - local: /&^/ + local: /&^/, }, emoji: enclosureRegex(':'), bold: enclosureRegex('\\*\\*'), italic: enclosureRegex('\\*'), code: enclosureRegex('`'), strikeThrough: enclosureRegex('~~'), -} +}; const splitter = new RegExp(Object.values(regex).map(pair => pair.global.source).join('|')); @@ -46,13 +46,13 @@ Object.keys(emojiLib).forEach(name => emojiList.push({ name, char: emojiLib[name const useStyles = makeStyles(theme => ({ code: { background: theme.palette.background.default, - borderRadius: theme.spacing(.5), - padding: theme.spacing(.5), + borderRadius: theme.spacing(0.5), + padding: theme.spacing(0.5), fontFamily: 'Monospace', }, image: { maxWidth: '100%', - maxHeight: '100%' + maxHeight: '100%', }, })); @@ -82,12 +82,12 @@ const SyntacticSpan: React.FC = ({ span }) => { if (matchItalic) return {matchItalic[1]}; const matchStrikeThrough = span.match(regex.strikeThrough.local); - if (matchStrikeThrough) return {matchStrikeThrough[1]}; + if (matchStrikeThrough) return {matchStrikeThrough[1]}; if (span.match(regex.rawLink.global)) return {span}; return <>{span}; -} +}; export { splitter }; -- cgit v1.2.3 From 8e4a483fb7d1ebdfc950c1cc456ae2d4bd558147 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 18 Apr 2020 20:52:31 +0300 Subject: style: fix remaining errors --- src/lib/Markdown/SyntacticSpan.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/Markdown/SyntacticSpan.tsx') diff --git a/src/lib/Markdown/SyntacticSpan.tsx b/src/lib/Markdown/SyntacticSpan.tsx index bdce3f7..11cc024 100644 --- a/src/lib/Markdown/SyntacticSpan.tsx +++ b/src/lib/Markdown/SyntacticSpan.tsx @@ -28,6 +28,7 @@ const regex: Record = { local: /!?\[(.*\]?.*)\]\((.+?)\)/, }, rawLink: { + // eslint-disable-next-line max-len global: /((?:(?:[A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)(?:(?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)/, local: /&^/, }, @@ -68,7 +69,7 @@ const SyntacticSpan: React.FC = ({ span }) => { const matchEmoji = span.match(regex.emoji.local); if (matchEmoji) { - const emoji = emojiList.find(emoji => emoji.name === matchEmoji[1]); + const emoji = emojiList.find(e => e.name === matchEmoji[1]); return {emoji ? emoji.char : span}; } -- cgit v1.2.3