commit 298a96b48f29baf082ac4d3c551fab2b6398c66b
parent c78768cdf461af899dff73d7628e4243162469ce
Author: Andrew Laack <andrew@laack.co>
Date: Wed, 30 Sep 2026 21:05:14 -0500
More adherence work. should be better now
Diffstat:
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/list-item.cpp b/src/list-item.cpp
@@ -3,9 +3,12 @@
#include <cstdint>
ListItem::ListItem(std::string input) {
- textToRender = input.substr(1);
- textToRender = stripLeadingWhiteSpace(textToRender);
- textToRender = "* " + textToRender;
+
+// list-item = "*" SP text-line
+// notice that a space is required along with a *. There'd be no reason to remove
+// them and then add them back here, so we just pass everything through.
+
+ textToRender = input;
}
std::string ListItem::textToDraw() {
diff --git a/src/utils.cpp b/src/utils.cpp
@@ -122,7 +122,7 @@ Line* lineToLine(std::string input, std::optional<uri> prior, int linkCount, boo
Quote* qt= new Quote{input};
return qt;
}
- if(input.substr(0,1) == "*") {
+ if(input.substr(0,2) == "* ") {
ListItem* li= new ListItem{input};
return li;
}
diff --git a/tests/pure-test.cpp b/tests/pure-test.cpp
@@ -3,11 +3,9 @@
#include <rapidcheck.h>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
-#include <climits>
#include <cstdlib>
#include <ctime>
#include <filesystem>
-#include <iostream>
#include <optional>
#include <rapidcheck/Check.h>
#include <utility>
@@ -269,7 +267,6 @@ TEST_CASE("Test line parsing handles whitespace correctly") {
std::unordered_map<std::string, LineType> prefixes {};
- prefixes["*"] = LIST_ITEM;
prefixes[">"] = QUOTE;
prefixes["#"] = H1;
prefixes["##"] = H2;
@@ -341,8 +338,16 @@ TEST_CASE("Proper whitespace compliance") {
auto res8 = lineToLine(">test quote", std::nullopt, 1, false);
REQUIRE(res8->type() == QUOTE);
+ // the only one that requires a whitespace, and it must be a space, not tab
auto res9 = lineToLine("*test li", std::nullopt, 1, false);
- REQUIRE(res9->type() == LIST_ITEM);
+ REQUIRE(res9->type() == PLAINTEXT);
+
+ auto res10 = lineToLine("*\ttest li", std::nullopt, 1, false);
+ REQUIRE(res10->type() == PLAINTEXT);
+
+ auto res11 = lineToLine("* test li", std::nullopt, 1, false);
+ REQUIRE(res11->type() == LIST_ITEM);
+ REQUIRE(res11->textToDraw() == "* test li\n");
}
SECTION("Non-whitespace based line types don't require whitespace") {
@@ -413,7 +418,7 @@ TEST_CASE("Line parser handles lines that are only format characters without whi
REQUIRE(res8->type() == QUOTE);
auto res9 = lineToLine("*", std::nullopt, 1, false);
- REQUIRE(res9->type() == LIST_ITEM);
+ REQUIRE(res9->type() == PLAINTEXT);
}
static std::string linecharset = "#>=abc## de_-><0193248$#)(&@)(*&$#^*&#^%^&*&fghijklmnopqrstuvwxyz #````ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";