From eb2b4fa9295d6c6c53f6b72531450029caef3b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 19 Oct 2018 11:31:13 -0300 Subject: [PATCH 1/4] strongparser: Add __ tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- include/maddy/strongparser.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/maddy/strongparser.h b/include/maddy/strongparser.h index cda6d21..c2dc441 100644 --- a/include/maddy/strongparser.h +++ b/include/maddy/strongparser.h @@ -30,9 +30,9 @@ public: /** * Parse * - * From Markdown: `text **text**` + * From Markdown: `text **text** __text__` * - * To HTML: `text text` + * To HTML: `text text text` * * @method * @param {std::string&} line The line to interpret @@ -41,10 +41,16 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!.*`.*|.*.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)"); + static std::vector res + { + std::regex{"(?!.*`.*|.*.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)"}, + std::regex{"(?!.*`.*|.*.*)\\_\\_(?!.*`.*|.*<\\/code>.*)([^\\_\\_]*)\\_\\_(?!.*`.*|.*<\\/code>.*)"} + }; static std::string replacement = "$1"; - - line = std::regex_replace(line, re, replacement); + for (const auto& re : res) + { + line = std::regex_replace(line, re, replacement); + } } }; // class StrongParser From 62365f1c7c39b816b3e8d249e334a59b4f3b4ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Fri, 19 Oct 2018 11:31:59 -0300 Subject: [PATCH 2/4] test_maddy_strongparser: Add tests to __ tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- tests/maddy/test_maddy_strongparser.cpp | 84 ++++++++++++++++++++----- 1 file changed, 69 insertions(+), 15 deletions(-) diff --git a/tests/maddy/test_maddy_strongparser.cpp b/tests/maddy/test_maddy_strongparser.cpp index ad70762..e054aa7 100644 --- a/tests/maddy/test_maddy_strongparser.cpp +++ b/tests/maddy/test_maddy_strongparser.cpp @@ -12,33 +12,87 @@ TEST(MADDY_STRONGPARSER, ItReplacesMarkdownWithStrongHTML) { - std::string text = "some text **bla** text testing **it** out"; - std::string expected = "some text bla text testing it out"; + struct testIt + { + std::string text; + std::string expected; + }; + + std::vector tests + { + { + "some text **bla** text testing **it** out", + "some text bla text testing it out" + }, + { + "some text __bla__ text testing __it__ out", + "some text bla text testing it out" + }, + }; + auto strongParser = std::make_shared(); - strongParser->Parse(text); - - ASSERT_EQ(expected, text); + for (auto& test : tests) + { + strongParser->Parse(test.text); + ASSERT_EQ(test.expected, test.text); + } } TEST(MADDY_STRONGPARSER, ItReplacesEmphasizedMarkdownNotWithStrongHTML) { - std::string text = "some text *bla* text testing **it** out"; - std::string expected = "some text *bla* text testing it out"; + struct testIt + { + std::string text; + std::string expected; + }; + + std::vector tests + { + { + "some text *bla* text testing **it** out", + "some text *bla* text testing it out" + }, + { + "some text _bla_ text testing __it__ out", + "some text _bla_ text testing it out" + }, + }; + auto strongParser = std::make_shared(); - strongParser->Parse(text); - - ASSERT_EQ(expected, text); + for (auto& test : tests) + { + strongParser->Parse(test.text); + ASSERT_EQ(test.expected, test.text); + } } TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode) { - std::string text = "some text **bla** `/**text**/` testing `**it**` out"; - std::string expected = "some text **bla** `/**text**/` testing `**it**` out"; + struct testIt + { + std::string text; + std::string expected; + }; + + std::vector tests + { + { + "some text **bla** `/**text**/` testing `**it**` out", + "some text **bla** `/**text**/` testing `**it**` out", + }, + { + "some text _bla_ text testing __it__ out", + "some text _bla_ text testing it out" + }, + }; + auto strongParser = std::make_shared(); - strongParser->Parse(text); - - ASSERT_EQ(expected, text); + for (auto& test : tests) + { + strongParser->Parse(test.text); + ASSERT_EQ(test.expected, test.text); + } } From 7e56e82b6af55b0c1e0edf617d0c2d49d38440b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Thu, 25 Oct 2018 10:24:08 -0300 Subject: [PATCH 3/4] AUTHORS: Add my name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index de388e1..c29b373 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,3 +5,4 @@ licensing terms detailed in LICENSE. a license to everyone to use it as detailed in LICENSE.) M. Petra Baranski (info@progsource.de) +Patrick José Pereira (patrickelectric@gmail.com) From a85ba0eec760b7da75780c1cc4bc3dd39e521e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Thu, 25 Oct 2018 11:14:25 -0300 Subject: [PATCH 4/4] docs: Update strong documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- docs/definitions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/definitions.md b/docs/definitions.md index a17e7bd..f93a380 100644 --- a/docs/definitions.md +++ b/docs/definitions.md @@ -221,10 +221,12 @@ results in ``` **bold text** +__bold text__ ``` results in ```html bold text +bold text ``` ## emphasized