From 46f410699037824408daf7c035458ba7bd958d44 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 7 Apr 2020 20:32:10 +0300 Subject: feat: include content before first header --- src/lib/Markdown/Section.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/lib/Markdown/Section.tsx') diff --git a/src/lib/Markdown/Section.tsx b/src/lib/Markdown/Section.tsx index 5ce8954..987b771 100644 --- a/src/lib/Markdown/Section.tsx +++ b/src/lib/Markdown/Section.tsx @@ -30,7 +30,12 @@ const Section: React.FC = ({ rawLines, level = 0 }) => { const deeperLevelIndex = rawLines.findIndex(line => line.match(`^#{${level + 1},} .*$`)); const rawContent = rawLines.splice(0, (deeperLevelIndex < 0) ? rawLines.length : deeperLevelIndex); - if (!level) return ; + if (!level) return ( + <> + + + + ) const sectionName = rawContent.splice(0, 1)[0].slice(level).trim(); const deeperLevel = getHeaderLevel(rawLines[0]); -- cgit v1.2.3 From b74897afe41962312828ffd362b7dd5ee8336775 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 9 Apr 2020 12:05:35 +0300 Subject: feat: wrap no-section header into Typography --- src/lib/Markdown/Section.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/Markdown/Section.tsx') diff --git a/src/lib/Markdown/Section.tsx b/src/lib/Markdown/Section.tsx index 987b771..1fcc46f 100644 --- a/src/lib/Markdown/Section.tsx +++ b/src/lib/Markdown/Section.tsx @@ -1,5 +1,6 @@ import React from 'react'; import ContentSection from '../ContentSection/ContentSection'; +import { Typography } from '@material-ui/core'; import Content from './Content'; import { ParserPropTypes } from './types'; @@ -32,7 +33,7 @@ const Section: React.FC = ({ rawLines, level = 0 }) => { if (!level) return ( <> - + ) -- 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/Section.tsx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/lib/Markdown/Section.tsx') diff --git a/src/lib/Markdown/Section.tsx b/src/lib/Markdown/Section.tsx index 1fcc46f..f554062 100644 --- a/src/lib/Markdown/Section.tsx +++ b/src/lib/Markdown/Section.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import ContentSection from '../ContentSection/ContentSection'; import { Typography } from '@material-ui/core'; +import ContentSection from '../ContentSection/ContentSection'; import Content from './Content'; import { ParserPropTypes } from './types'; @@ -11,9 +11,9 @@ interface PropTypes extends ParserPropTypes { const getHeaderLevel = (header: string): number => { if (!header) return 0; let level = 0; - while(header[level] === '#') level++; + while (header[level] === '#') level++; return level; -} +}; const ChildrenSections: React.FC = ({ rawLines, level = 0 }) => { const childrenSectionLines = rawLines.reduce((sections: string[][], line: string) => { @@ -23,20 +23,22 @@ const ChildrenSections: React.FC = ({ rawLines, level = 0 }) => { } return sections; }, []); - const children = childrenSectionLines.map(sectionLines =>
); - return <> {children} ; -} + const children = childrenSectionLines.map(sectionLines =>
); + return <>{children}; +}; const Section: React.FC = ({ rawLines, level = 0 }) => { const deeperLevelIndex = rawLines.findIndex(line => line.match(`^#{${level + 1},} .*$`)); const rawContent = rawLines.splice(0, (deeperLevelIndex < 0) ? rawLines.length : deeperLevelIndex); - if (!level) return ( - <> - - - - ) + if (!level) { + return ( + <> + + + + ); + } const sectionName = rawContent.splice(0, 1)[0].slice(level).trim(); const deeperLevel = getHeaderLevel(rawLines[0]); @@ -46,7 +48,7 @@ const Section: React.FC = ({ rawLines, level = 0 }) => { ); -} +}; export default Section; -- 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/Section.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/Markdown/Section.tsx') diff --git a/src/lib/Markdown/Section.tsx b/src/lib/Markdown/Section.tsx index f554062..fc208b1 100644 --- a/src/lib/Markdown/Section.tsx +++ b/src/lib/Markdown/Section.tsx @@ -11,7 +11,7 @@ interface PropTypes extends ParserPropTypes { const getHeaderLevel = (header: string): number => { if (!header) return 0; let level = 0; - while (header[level] === '#') level++; + while (header[level] === '#') level += 1; return level; }; -- cgit v1.2.3