From 9272b0af3d7b2fba4738a341a1f2776243e0e515 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 18 Apr 2020 20:44:55 +0300 Subject: style: manually fix some errors --- src/lib/Markdown/Content.tsx | 12 +++++++----- src/lib/Markdown/Markdown.tsx | 11 +++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/lib/Markdown') diff --git a/src/lib/Markdown/Content.tsx b/src/lib/Markdown/Content.tsx index d64720b..88409fa 100644 --- a/src/lib/Markdown/Content.tsx +++ b/src/lib/Markdown/Content.tsx @@ -40,17 +40,19 @@ const Content: React.FC = ({ rawLines }) => { let buffer; if (denotesCodeBlock(line)) { - const closeIndex = rawLines.findIndex(line => denotesCodeBlock(line)); + const closeIndex = rawLines.findIndex(rawLine => denotesCodeBlock(rawLine)); const codeBlockLines = rawLines.splice(0, closeIndex + 1).slice(0, closeIndex); buffer = ; } else if (denotesDottedList(line)) { - const closeIndex = rawLines.findIndex(line => !denotesDottedList(line)); + const closeIndex = rawLines.findIndex(rawLine => !denotesDottedList(rawLine)); const dottedListLines = rawLines.splice(0, closeIndex).slice(0, closeIndex); dottedListLines.unshift(line); buffer =
    {dottedListLines.map(li =>
  • )}
; } else if ((buffer = denotesOpenHtml(line))) { const tag = buffer; - const closeIndex = denotesClosingHtml(line, tag) ? -1 : rawLines.findIndex(line => denotesClosingHtml(line, tag)); + const closeIndex = denotesClosingHtml(line, tag) ? -1 : rawLines.findIndex( + rawLine => denotesClosingHtml(rawLine, tag), + ); const htmlLines = rawLines.splice(0, closeIndex + 1); htmlLines.unshift(line); buffer =
; @@ -65,8 +67,8 @@ const Content: React.FC = ({ rawLines }) => { ); } else if (declaresNoLineBreak(line)) { - const closeIndex = rawLines.findIndex(line => !declaresNoLineBreak(line)); - const lineBreakLines = rawLines.splice(0, closeIndex).map(line => line.slice(0, -2)); + const closeIndex = rawLines.findIndex(rawLine => !declaresNoLineBreak(rawLine)); + const lineBreakLines = rawLines.splice(0, closeIndex).map(rawLine => rawLine.slice(0, -2)); lineBreakLines.unshift(line.slice(0, -2)); lineBreakLines.push(rawLines.splice(0, 1)[0]); buffer =

{lineBreakLines.map(lineBreakLine => )}

; diff --git a/src/lib/Markdown/Markdown.tsx b/src/lib/Markdown/Markdown.tsx index 68967c5..cfcf117 100644 --- a/src/lib/Markdown/Markdown.tsx +++ b/src/lib/Markdown/Markdown.tsx @@ -8,10 +8,13 @@ interface PropTypes { url?: string; } -const resolveUrls = (line: string, baseUrl: string): string => { - return line.replace(/src="(?!http)(.*)"[\s>]/, (match, url, offset, string) => `src="${baseUrl}/${url}?sanitize=true"`) - .replace(/\[(.*\]?.*)\]\((?!http)(.+?)\)/, (match, text, url, offset, string) => `[${text}](${baseUrl}/${url})`); -}; +const resolveUrls = (line: string, baseUrl: string): string => line.replace( + /src="(?!http)(.*)"[\s>]/, + (match, url) => `src="${baseUrl}/${url}?sanitize=true"`, +).replace( + /\[(.*\]?.*)\]\((?!http)(.+?)\)/, + (match, text, url) => `[${text}](${baseUrl}/${url})`, +); const Markdown: React.FC = ({ data, url }) => { const [markdown, setMarkdown] = useState(data || ''); -- cgit v1.2.3