aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/Markdown/Content.tsx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/Markdown/Content.tsx b/src/lib/Markdown/Content.tsx
index d0a2193..593b9e9 100644
--- a/src/lib/Markdown/Content.tsx
+++ b/src/lib/Markdown/Content.tsx
@@ -2,11 +2,16 @@ import React from 'react';
import CodeBlock from './CodeBlock';
import Paragraph from './Paragraph';
+import InlineSyntax from './InlineSyntax';
import { ParserPropTypes } from './types';
const denotesCodeBlock = (line: string): boolean => {
- return line.slice(0, 3) === '```';
+ return line.match(/^```.*$/) !== null;
+}
+
+const denotesDottedList = (line: string): boolean => {
+ return line.match(/^ ?- .*$/) !== null;
}
const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
@@ -19,6 +24,11 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
const closeIndex = rawLines.findIndex(line => denotesCodeBlock(line));
const codeBlockLines = rawLines.splice(0, closeIndex + 1).slice(0, closeIndex);
result = <CodeBlock rawLines={codeBlockLines} />
+ } else if (denotesDottedList(line)) {
+ const closeIndex = rawLines.findIndex(line => !denotesDottedList(line));
+ const dottedListLines = rawLines.splice(0, closeIndex).slice(0, closeIndex);
+ dottedListLines.unshift(line);
+ result = <ul>{dottedListLines.map(li => <li><InlineSyntax line={li} /></li>)}</ul>;
} else {
result = <Paragraph line={line} />
}
@@ -28,7 +38,7 @@ const Content: React.FC<ParserPropTypes> = ({ rawLines }) => {
{ result }
<Content rawLines={rawLines} />
</>
- )
+ );
}
export default Content;