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] 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