From 5c259810433be8cdbe6fcac8776cdbf4a0c244b0 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 7 Apr 2020 15:31:00 +0300
Subject: fix: account for \r line endings, remove consoles

---
 src/lib/Markdown/Content.tsx | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

(limited to 'src/lib/Markdown/Content.tsx')

diff --git a/src/lib/Markdown/Content.tsx b/src/lib/Markdown/Content.tsx
index aaea100..30f2a8a 100644
--- a/src/lib/Markdown/Content.tsx
+++ b/src/lib/Markdown/Content.tsx
@@ -6,11 +6,10 @@ import { ParserPropTypes } from './types';
 
 
 const denotesCodeBlock = (line: string): boolean => {
-  return line.match(/^```.*$/) !== null;
-}
+  return line.match(/^\s*```.*$/) !== null; }
 
 const denotesDottedList = (line: string): boolean => {
-  return line.match(/^ ?- .*$/) !== null;
+  return line.match(/^ ?[-*] .*$/) !== null;
 }
 
 const denotesOpenHtml= (line: string): string => {
@@ -53,7 +52,6 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
   } else if ((buffer = denotesSelfClosingHtml(line)) !== null) {
     const match = buffer[0];
     const [before, after] = line.split(match);
-    console.log({ line, match, before, after});
     buffer = (
       <>
         <Text line={before} />
-- 
cgit v1.2.3


From c851a68e15daedb8dbe572ce5927a8e61254d4c9 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Tue, 7 Apr 2020 20:31:45 +0300
Subject: feat: support \| symbol, fix html parsing

---
 src/lib/Markdown/Content.tsx | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

(limited to 'src/lib/Markdown/Content.tsx')

diff --git a/src/lib/Markdown/Content.tsx b/src/lib/Markdown/Content.tsx
index 30f2a8a..5895df9 100644
--- a/src/lib/Markdown/Content.tsx
+++ b/src/lib/Markdown/Content.tsx
@@ -28,6 +28,10 @@ const denotesSelfClosingHtml = (line: string): string[] | null => {
   return line.match(regex);
 }
 
+const declaresNoLineBreak = (line: string): boolean => {
+  return line.match(/\\\|$/) !== null;
+}
+
 const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
   if (!rawLines.length) return null;
 
@@ -46,7 +50,7 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
   } else if ((buffer = denotesOpenHtml(line))) {
     const tag = buffer;
     const closeIndex = rawLines.findIndex(line => denotesClosingHtml(line, tag));
-    const htmlLines = rawLines.splice(0, closeIndex + 1).slice(0, closeIndex);
+    const htmlLines = rawLines.splice(0, closeIndex + 1);
     htmlLines.unshift(line);
     buffer = <div dangerouslySetInnerHTML={{ __html: htmlLines.join('\n') }}></div>;
   } else if ((buffer = denotesSelfClosingHtml(line)) !== null) {
@@ -59,6 +63,14 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
         <Text line={after} />
       </>
     );
+  } else if (declaresNoLineBreak(line)) {
+    const closeIndex = rawLines.findIndex(line => !declaresNoLineBreak(line));
+    const lineBreakLines = rawLines.splice(0, closeIndex).map(line => line.slice(0, -2));
+    lineBreakLines.unshift(line.slice(0, -2));
+    lineBreakLines.push(rawLines.splice(0, 1)[0]);
+    buffer = <p>{lineBreakLines.map(lineBreakLine => <Text line={lineBreakLine} />)}</p>;
+  } else if (denotesClosingHtml(line, '')) {
+    buffer = null;
   } else {
     buffer = <p><Text line={line} /></p>
   }
-- 
cgit v1.2.3


From d1bcd3348c67cfbcd83178c9710cc54de9f776e8 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Thu, 9 Apr 2020 12:20:34 +0300
Subject: feat: consider 1-line html tag

---
 src/lib/Markdown/Content.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/Markdown/Content.tsx')

diff --git a/src/lib/Markdown/Content.tsx b/src/lib/Markdown/Content.tsx
index 5895df9..5816214 100644
--- a/src/lib/Markdown/Content.tsx
+++ b/src/lib/Markdown/Content.tsx
@@ -49,7 +49,7 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
     buffer = <ul>{dottedListLines.map(li => <li><Text line={li.slice(2)} /></li>)}</ul>;
   } else if ((buffer = denotesOpenHtml(line))) {
     const tag = buffer;
-    const closeIndex = rawLines.findIndex(line => denotesClosingHtml(line, tag));
+    const closeIndex = denotesClosingHtml(line, tag) ? -1 : rawLines.findIndex(line => denotesClosingHtml(line, tag));
     const htmlLines = rawLines.splice(0, closeIndex + 1);
     htmlLines.unshift(line);
     buffer = <div dangerouslySetInnerHTML={{ __html: htmlLines.join('\n') }}></div>;
-- 
cgit v1.2.3

