Added paragraph support to MarkdownParser
MarkdownParser will now recognize and insert paragraphs.
This commit is contained in:
parent
3cc372de97
commit
9f94172050
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue