mirror of
https://github.com/quitesimpleorg/qsmaddy.git
synced 2024-11-27 01:32:35 +01:00
fixed the inline code now also for not directly following letters
* em * s * strong updated regex
This commit is contained in:
parent
6619f03879
commit
2ee6840008
@ -41,7 +41,7 @@ public:
|
|||||||
void
|
void
|
||||||
Parse(std::string& line) override
|
Parse(std::string& line) override
|
||||||
{
|
{
|
||||||
static std::regex re("(?!`|<code>)\\*(?!`|</code>)([^\\*]*)\\*(?!`|</code>)");
|
static std::regex re("(?!.*`.*|.*<code>.*)\\*(?!.*`.*|.*<\\/code>.*)([^\\*]*)\\*(?!.*`.*|.*<\\/code>.*)");
|
||||||
static std::string replacement = "<em>$1</em>";
|
static std::string replacement = "<em>$1</em>";
|
||||||
|
|
||||||
line = std::regex_replace(line, re, replacement);
|
line = std::regex_replace(line, re, replacement);
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
void
|
void
|
||||||
Parse(std::string& line) override
|
Parse(std::string& line) override
|
||||||
{
|
{
|
||||||
static std::regex re("(?!`|<code>)\\~\\~(?!`|</code>)([^\\~]*)\\~\\~(?!`|</code>)");
|
static std::regex re("(?!.*`.*|.*<code>.*)\\~\\~(?!.*`.*|.*<\\/code>.*)([^\\~]*)\\~\\~(?!.*`.*|.*<\\/code>.*)");
|
||||||
static std::string replacement = "<s>$1</s>";
|
static std::string replacement = "<s>$1</s>";
|
||||||
|
|
||||||
line = std::regex_replace(line, re, replacement);
|
line = std::regex_replace(line, re, replacement);
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
void
|
void
|
||||||
Parse(std::string& line) override
|
Parse(std::string& line) override
|
||||||
{
|
{
|
||||||
static std::regex re("(?!`|<code>)\\*\\*(?!`|</code>)([^\\*\\*]*)\\*\\*(?!`|</code>)");
|
static std::regex re("(?!.*`.*|.*<code>.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)");
|
||||||
static std::string replacement = "<strong>$1</strong>";
|
static std::string replacement = "<strong>$1</strong>";
|
||||||
|
|
||||||
line = std::regex_replace(line, re, replacement);
|
line = std::regex_replace(line, re, replacement);
|
||||||
|
@ -23,8 +23,8 @@ TEST(MADDY_EMPHASIZEDPARSER, ItReplacesMarkdownWithEmphasizedHTML)
|
|||||||
|
|
||||||
TEST(MADDY_EMPHASIZEDPARSER, ItDoesNotParseInsideInlineCode)
|
TEST(MADDY_EMPHASIZEDPARSER, ItDoesNotParseInsideInlineCode)
|
||||||
{
|
{
|
||||||
std::string text = "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 <em>it</em> out";
|
std::string expected = "some text `*bla*` `/**text*/` testing <em>it</em> out";
|
||||||
auto emphasizedParser = std::make_shared<maddy::EmphasizedParser>();
|
auto emphasizedParser = std::make_shared<maddy::EmphasizedParser>();
|
||||||
|
|
||||||
emphasizedParser->Parse(text);
|
emphasizedParser->Parse(text);
|
||||||
|
@ -23,8 +23,8 @@ TEST(MADDY_STRIKETHROUGHPARSER, ItReplacesMarkdownWithStrikeThroughHTML)
|
|||||||
|
|
||||||
TEST(MADDY_STRIKETHROUGHPARSER, ItDoesNotParseInsideInlineCode)
|
TEST(MADDY_STRIKETHROUGHPARSER, ItDoesNotParseInsideInlineCode)
|
||||||
{
|
{
|
||||||
std::string text = "some text `~~bla~~` text testing <code>~~it~~</code> out";
|
std::string text = "some text `~~bla~~` ` ~~text~~ ` testing <code>~~it~~</code> out";
|
||||||
std::string expected = "some text `~~bla~~` text testing <code>~~it~~</code> out";
|
std::string expected = "some text `~~bla~~` ` ~~text~~ ` testing <code>~~it~~</code> out";
|
||||||
auto strikeThroughParser = std::make_shared<maddy::StrikeThroughParser>();
|
auto strikeThroughParser = std::make_shared<maddy::StrikeThroughParser>();
|
||||||
|
|
||||||
strikeThroughParser->Parse(text);
|
strikeThroughParser->Parse(text);
|
||||||
|
@ -34,8 +34,8 @@ TEST(MADDY_STRONGPARSER, ItReplacesEmphasizedMarkdownNotWithStrongHTML)
|
|||||||
|
|
||||||
TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode)
|
TEST(MADDY_STRONGPARSER, ItDoesNotParseInsideInlineCode)
|
||||||
{
|
{
|
||||||
std::string text = "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";
|
std::string expected = "some text **bla** `/**text**/` testing `**it**` out";
|
||||||
auto strongParser = std::make_shared<maddy::StrongParser>();
|
auto strongParser = std::make_shared<maddy::StrongParser>();
|
||||||
|
|
||||||
strongParser->Parse(text);
|
strongParser->Parse(text);
|
||||||
|
Loading…
Reference in New Issue
Block a user