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