Added paragraph support to MarkdownParser

MarkdownParser will now recognize and insert paragraphs.
This commit is contained in:
luca0N! 2022-03-02 17:44:07 -03:00
parent 3cc372de97
commit 9f94172050
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
1 changed files with 15 additions and 0 deletions

View File

@ -40,6 +40,7 @@ std::string make_html(std::filesystem::path const &path) {
// Tag flags
bool tag_b = false,
tag_i = false,
tag_p = false,
// If there is an escape character at the end of the buffer, use
// this flag to prevent ignoring it.
escaping = false,
@ -52,6 +53,13 @@ std::string make_html(std::filesystem::path const &path) {
int tag_h = 0;
while (fgets(buf, buflen, mdFile) != NULL) {
manualBreak = false;
if (tag_p && buf[0] == '\n') {
// Empty newline; end paragraph.
html += "</p>\n";
continue;
}
// Read character by character
for (int x = 0; x < buflen; x++) {
char c = buf[x];
@ -72,6 +80,13 @@ std::string make_html(std::filesystem::path const &path) {
html += '\n';
break;
}
// Start paragraph if newline and no
// special characters were matched.
if (newline && x == 0 && c != '#')
html += "<p>",
tag_p = true;
switch (c) {
case '*':
// Bold check