diff --git a/include/maddy/emphasizedparser.h b/include/maddy/emphasizedparser.h index 40fdae6..65cf11b 100644 --- a/include/maddy/emphasizedparser.h +++ b/include/maddy/emphasizedparser.h @@ -41,7 +41,7 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!`|)\\*(?!`|)([^\\*]*)\\*(?!`|)"); + static std::regex re("(?!.*`.*|.*.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); diff --git a/include/maddy/strikethroughparser.h b/include/maddy/strikethroughparser.h index bc7002a..2640459 100644 --- a/include/maddy/strikethroughparser.h +++ b/include/maddy/strikethroughparser.h @@ -39,7 +39,7 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!`|)\\~\\~(?!`|)([^\\~]*)\\~\\~(?!`|)"); + static std::regex re("(?!.*`.*|.*.*)\\~\\~(?!.*`.*|.*<\\/code>.*)([^\\~]*)\\~\\~(?!.*`.*|.*<\\/code>.*)"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); diff --git a/include/maddy/strongparser.h b/include/maddy/strongparser.h index 4ca0fa5..cda6d21 100644 --- a/include/maddy/strongparser.h +++ b/include/maddy/strongparser.h @@ -41,7 +41,7 @@ public: void Parse(std::string& line) override { - static std::regex re("(?!`|)\\*\\*(?!`|)([^\\*\\*]*)\\*\\*(?!`|)"); + static std::regex re("(?!.*`.*|.*.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)"); static std::string replacement = "$1"; line = std::regex_replace(line, re, replacement); diff --git a/tests/maddy/test_maddy_emphasizedparser.cpp b/tests/maddy/test_maddy_emphasizedparser.cpp index e908c37..c200313 100644 --- a/tests/maddy/test_maddy_emphasizedparser.cpp +++ b/tests/maddy/test_maddy_emphasizedparser.cpp @@ -23,8 +23,8 @@ TEST(MADDY_EMPHASIZEDPARSER, ItReplacesMarkdownWithEmphasizedHTML) TEST(MADDY_EMPHASIZEDPARSER, ItDoesNotParseInsideInlineCode) { - std::string text = "some text `*bla*` text testing *it* out"; - std::string expected = "some text `*bla*` text testing it out"; + std::string text = "some text `*bla*` `/**text*/` testing *it* out"; + std::string expected = "some text `*bla*` `/**text*/` testing it out"; auto emphasizedParser = std::make_shared(); emphasizedParser->Parse(text); diff --git a/tests/maddy/test_maddy_strikethroughparser.cpp b/tests/maddy/test_maddy_strikethroughparser.cpp index f5dd933..b6efd04 100644 --- a/tests/maddy/test_maddy_strikethroughparser.cpp +++ b/tests/maddy/test_maddy_strikethroughparser.cpp @@ -23,8 +23,8 @@ TEST(MADDY_STRIKETHROUGHPARSER, ItReplacesMarkdownWithStrikeThroughHTML) TEST(MADDY_STRIKETHROUGHPARSER, ItDoesNotParseInsideInlineCode) { - std::string text = "some text `~~bla~~` text testing ~~it~~ out"; - std::string expected = "some text `~~bla~~` text testing ~~it~~ out"; + std::string text = "some text `~~bla~~` ` ~~text~~ ` testing ~~it~~ out"; + std::string expected = "some text `~~bla~~` ` ~~text~~ ` testing ~~it~~ out"; auto strikeThroughParser = std::make_shared(); strikeThroughParser->Parse(text); diff --git a/tests/maddy/test_maddy_strongparser.cpp b/tests/maddy/test_maddy_strongparser.cpp index 5086e4b..ad70762 100644 --- a/tests/maddy/test_maddy_strongparser.cpp +++ b/tests/maddy/test_maddy_strongparser.cpp @@ -34,8 +34,8 @@ TEST(MADDY_STRONGPARSER, ItReplacesEmphasizedMarkdownNotWithStrongHTML) TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode) { - std::string text = "some text *bla* text testing `**it**` out"; - std::string expected = "some text *bla* text testing `**it**` out"; + std::string text = "some text **bla** `/**text**/` testing `**it**` out"; + std::string expected = "some text **bla** `/**text**/` testing `**it**` out"; auto strongParser = std::make_shared(); strongParser->Parse(text);