mirror of
https://github.com/quitesimpleorg/qsmaddy.git
synced 2024-11-24 00:02:36 +01:00
strongparser: Add __ tag
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
This commit is contained in:
parent
a19845cdb5
commit
eb2b4fa929
@ -30,9 +30,9 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Parse
|
* Parse
|
||||||
*
|
*
|
||||||
* From Markdown: `text **text**`
|
* From Markdown: `text **text** __text__`
|
||||||
*
|
*
|
||||||
* To HTML: `text <strong>text</strong>`
|
* To HTML: `text <strong>text</strong> <strong>text</strong>`
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {std::string&} line The line to interpret
|
* @param {std::string&} line The line to interpret
|
||||||
@ -41,11 +41,17 @@ public:
|
|||||||
void
|
void
|
||||||
Parse(std::string& line) override
|
Parse(std::string& line) override
|
||||||
{
|
{
|
||||||
static std::regex re("(?!.*`.*|.*<code>.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)");
|
static std::vector<std::regex> res
|
||||||
|
{
|
||||||
|
std::regex{"(?!.*`.*|.*<code>.*)\\*\\*(?!.*`.*|.*<\\/code>.*)([^\\*\\*]*)\\*\\*(?!.*`.*|.*<\\/code>.*)"},
|
||||||
|
std::regex{"(?!.*`.*|.*<code>.*)\\_\\_(?!.*`.*|.*<\\/code>.*)([^\\_\\_]*)\\_\\_(?!.*`.*|.*<\\/code>.*)"}
|
||||||
|
};
|
||||||
static std::string replacement = "<strong>$1</strong>";
|
static std::string replacement = "<strong>$1</strong>";
|
||||||
|
for (const auto& re : res)
|
||||||
|
{
|
||||||
line = std::regex_replace(line, re, replacement);
|
line = std::regex_replace(line, re, replacement);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}; // class StrongParser
|
}; // class StrongParser
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user