From ea7222ade2f783970e2a04488ec2c84d9d983ba9 Mon Sep 17 00:00:00 2001 From: Neil An Date: Thu, 29 Sep 2022 16:53:32 -0400 Subject: [PATCH] added support for horizontal rule in markdown --- generateHTML.js | 25 +++++++++++++++++++++++-- markdownTest.md | 2 +- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/generateHTML.js b/generateHTML.js index bac0b82..1c06633 100644 --- a/generateHTML.js +++ b/generateHTML.js @@ -150,6 +150,12 @@ function readMdFile(input) } } + //check if the line is a horizontal rule + if (modifiedLine == "---") + { + modifiedLine = '
'; + } + lineArray.push(modifiedLine); } else @@ -180,11 +186,26 @@ function writeFile(input, result) //try to format the HTML file better if (lineNumber == 0) { - content += "

" + theLine + "

\n"; + //check if the line is an hr tag + if (theLine == "
") + { + content += theLine + "\n"; + } + else + { + content += "

" + theLine + "

\n"; + } } else { - content += "\t

" + theLine + "

\n"; + if (theLine == "
") + { + content += "\t" + theLine + "\n"; + } + else + { + content += "\t

" + theLine + "

\n"; + } } } else diff --git a/markdownTest.md b/markdownTest.md index ecddfe1..f1bcce4 100644 --- a/markdownTest.md +++ b/markdownTest.md @@ -2,6 +2,6 @@ this line has no bolded text this line has **bolded** text. this **line** has **alternating** bolded **text**. - +--- **this entire line should be bolded**.