mirror of
https://github.com/progsource/maddy.git
synced 2026-03-24 23:40:39 +01:00
Fix linkparser line handling with multiple parenthesis
This commit is contained in:
@@ -17,6 +17,7 @@ maddy uses [semver versioning](https://semver.org/).
|
||||
*  Updated google test to v1.16.0.
|
||||
*  clang-format
|
||||
*  automatic update dependencies ci
|
||||
*  `(This is a [link](/ABC/some file) (the URL will include this).)` should not put the later parenthesis into the link url.
|
||||
|
||||
## version 1.3.0 2023-08-26
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
*/
|
||||
void Parse(std::string& line) override
|
||||
{
|
||||
static std::regex re(R"(\[([^\]]*)\]\(([^\]]*)\))");
|
||||
static std::regex re(R"(\[([^\]]*)\]\(([^)]*)\))");
|
||||
static std::string replacement = "<a href=\"$2\">$1</a>";
|
||||
|
||||
line = std::regex_replace(line, re, replacement);
|
||||
|
||||
@@ -37,6 +37,22 @@ TEST(MADDY_LINKPARSER, ItReplacesMarkdownWithLinks)
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
TEST(
|
||||
MADDY_LINKPARSER, ItReplacesMarkdownProperlyEvenWithMultipleParenthesisInLine
|
||||
)
|
||||
{
|
||||
std::string text =
|
||||
"(This is a [link](/ABC/some file) (the URL will include this).)";
|
||||
std::string expected =
|
||||
"(This is a <a href=\"/ABC/some file\">link</a> (the URL will include "
|
||||
"this).)";
|
||||
auto linkParser = std::make_shared<maddy::LinkParser>();
|
||||
|
||||
linkParser->Parse(text);
|
||||
|
||||
ASSERT_EQ(expected, text);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class DISABLED_MADDY_LINKPARSER : public ::testing::Test
|
||||
|
||||
@@ -123,7 +123,7 @@ def main():
|
||||
"""
|
||||
if len(sys.argv) != 2:
|
||||
print(
|
||||
"Usage: python check_clang_format.py <dry_run|format>"
|
||||
"Usage: python format.py <dry_run|format>"
|
||||
)
|
||||
sys.exit(1)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user