diff options
author | Peter Elliott <pelliott@ualberta.ca> | 2021-09-29 19:24:22 -0600 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-10-05 13:27:25 +0330 |
commit | a76a23e33b1038687b644c33dff6e5c8955f7230 (patch) | |
tree | 819e00e16d53deada25e79a1ff681a40af9ccc0a /Userland/Libraries/LibMarkdown | |
parent | 0a21c2bace9797f835718bf4ea45fb09a5a2297a (diff) | |
download | serenity-a76a23e33b1038687b644c33dff6e5c8955f7230.zip |
LibMarkdown: Allow spaces before list items
also allow '+' as an unordered list marker
Diffstat (limited to 'Userland/Libraries/LibMarkdown')
-rw-r--r-- | Userland/Libraries/LibMarkdown/List.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Libraries/LibMarkdown/List.cpp b/Userland/Libraries/LibMarkdown/List.cpp index a75757b6e9..5ddc8472e1 100644 --- a/Userland/Libraries/LibMarkdown/List.cpp +++ b/Userland/Libraries/LibMarkdown/List.cpp @@ -67,15 +67,19 @@ OwnPtr<List> List::parse(LineIterator& lines) const StringView& line = *lines; bool appears_unordered = false; - if (line.length() > 2) { - if (line[1] == ' ' && (line[0] == '*' || line[0] == '-')) { + + while (offset < line.length() && line[offset] == ' ') + ++offset; + + if (offset + 2 <= line.length()) { + if (line[offset + 1] == ' ' && (line[offset] == '*' || line[offset] == '-' || line[offset] == '+')) { appears_unordered = true; - offset = 1; + offset++; } } bool appears_ordered = false; - for (size_t i = 0; i < 10 && i < line.length(); i++) { + for (size_t i = offset; i < 10 && i < line.length(); i++) { char ch = line[i]; if ('0' <= ch && ch <= '9') continue; |