From 51d61b68fed1784d5f587d1969ffe2754563644c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kopeck=C3=BD?= Date: Thu, 30 Jan 2020 17:38:55 +0100 Subject: [PATCH 1/2] Added another character for bullet point("-") --- include/maddy/unorderedlistparser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/maddy/unorderedlistparser.h b/include/maddy/unorderedlistparser.h index d8706af..2d70eed 100644 --- a/include/maddy/unorderedlistparser.h +++ b/include/maddy/unorderedlistparser.h @@ -54,7 +54,7 @@ public: static bool IsStartingLine(const std::string& line) { - static std::regex re("^\\* .*"); + static std::regex re("^[\\*-] .*"); return std::regex_match(line, re); } @@ -89,7 +89,7 @@ protected: bool isStartOfNewListItem = IsStartingLine(line); uint32_t indentation = getIndentationWidth(line); - static std::regex lineRegex("^(\\* )"); + static std::regex lineRegex("^([\\*-] )"); line = std::regex_replace(line, lineRegex, ""); if (!this->isStarted) From cb75226b4a80742886fa2ba3b2ea216b50ce89a4 Mon Sep 17 00:00:00 2001 From: Martin Kopecky Date: Mon, 3 Feb 2020 22:52:52 +0100 Subject: [PATCH 2/2] *, + and - are equivalent for making unordered bullet lists as per https://spec-md.com/#sec-Lists Modified tests and documentation to reflect that. --- AUTHORS | 2 ++ docs/definitions.md | 10 ++++++---- include/maddy/unorderedlistparser.h | 4 ++-- tests/maddy/test_maddy_unorderedlistparser.cpp | 12 ++++++++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index c29b373..f64561c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,3 +6,5 @@ a license to everyone to use it as detailed in LICENSE.) M. Petra Baranski (info@progsource.de) Patrick José Pereira (patrickelectric@gmail.com) +Martin Kopecky (martin.kopecky357@gmail.com) + diff --git a/docs/definitions.md b/docs/definitions.md index 6595d8b..fd6f286 100644 --- a/docs/definitions.md +++ b/docs/definitions.md @@ -44,11 +44,13 @@ results in ## Lists ### unordered +Characters "*", "+" or "-" to make an unordered "bullet" list are equivalent. + ``` -* unordered +- unordered * list -* items ++ items ``` results in @@ -66,8 +68,8 @@ results in * list * items * in - * an - * hierarchy + + an + - hierarchy ``` results in diff --git a/include/maddy/unorderedlistparser.h b/include/maddy/unorderedlistparser.h index 2d70eed..0c1aa5d 100644 --- a/include/maddy/unorderedlistparser.h +++ b/include/maddy/unorderedlistparser.h @@ -54,7 +54,7 @@ public: static bool IsStartingLine(const std::string& line) { - static std::regex re("^[\\*-] .*"); + static std::regex re("^[+*-] .*"); return std::regex_match(line, re); } @@ -89,7 +89,7 @@ protected: bool isStartOfNewListItem = IsStartingLine(line); uint32_t indentation = getIndentationWidth(line); - static std::regex lineRegex("^([\\*-] )"); + static std::regex lineRegex("^([+*-] )"); line = std::regex_replace(line, lineRegex, ""); if (!this->isStarted) diff --git a/tests/maddy/test_maddy_unorderedlistparser.cpp b/tests/maddy/test_maddy_unorderedlistparser.cpp index df94ba0..eed8427 100644 --- a/tests/maddy/test_maddy_unorderedlistparser.cpp +++ b/tests/maddy/test_maddy_unorderedlistparser.cpp @@ -55,9 +55,14 @@ TEST_F(MADDY_UNORDEREDLISTPARSER, ItReplacesMarkdownWithAnHtmlUnorderedList) std::vector markdown = { "* a" , "* b" + , "- c" + , "- d" + , "+ e" + , "+ f" + , "* g" , "" }; - std::string expected = "
  • a
  • b
"; + std::string expected = "
  • a
  • b
  • c
  • d
  • e
  • f
  • g
"; for (std::string md : markdown) { @@ -80,9 +85,12 @@ TEST_F(MADDY_UNORDEREDLISTPARSER, ItReplacesMarkdownWithAnHierachicalHtmlList) , " * e" , "* b" , " * c" + , " + x" + , " + y" + , " - z" , "" }; - std::string expected = "
  • a
    • d
    • e
  • b
    • c
"; + std::string expected = "
  • a
    • d
    • e
  • b
    • c
    • x
    • y
    • z
"; for (std::string md : markdown) {