Add initial <ul> list support

Added initial support for unordered lists.  This update adds <li> tags,
but doesn't add <ul> tags.
This commit is contained in:
luca0N! 2022-03-02 18:51:36 -03:00
parent 81b523d312
commit 58710d07c5
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
1 changed files with 14 additions and 1 deletions

View File

@ -41,6 +41,7 @@ std::string make_html(std::filesystem::path const &path) {
bool tag_b = false, bool tag_b = false,
tag_i = false, tag_i = false,
tag_p = false, tag_p = false,
tag_li = 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,
@ -78,13 +79,15 @@ std::string make_html(std::filesystem::path const &path) {
html += ">"; html += ">";
tag_h = 0; tag_h = 0;
} }
if (tag_li) html += "</li>", tag_li = false;
html += '\n'; html += '\n';
break; break;
} }
// Start paragraph if newline and no // Start paragraph if newline and no
// special characters were matched. // special characters were matched.
if (!tag_p && newline && x == 0 && c != '#') if (!tag_p && newline && x == 0 &&
c != '#' && c != '-')
html += "<p>", html += "<p>",
tag_p = true; tag_p = true;
@ -167,6 +170,16 @@ std::string make_html(std::filesystem::path const &path) {
break; break;
} }
break;
case '-':
if (x != 0) {
html += c;
break;
}
html += "<li>";
ignoreSpace = true;
tag_li = true;
break; break;
case ' ': case ' ':
if (ignoreSpace) { if (ignoreSpace) {