File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -40,8 +40,10 @@ class EmphasizedParser : public LineParser
40
40
*/
41
41
void Parse (std::string& line) override
42
42
{
43
+ // Modifed from previous version, with help from
44
+ // https://stackoverflow.com/questions/61346949/regex-for-markdown-emphasis
43
45
static std::regex re (
44
- R"( (?!.*`.*|.*<code>.*)_ (?!.*`.*|.*<\/code>.*)([^_]*)_ (?!.*`.*|.*<\/code>.*))"
46
+ R"( (?!.*`.*|.*<code>.*)\b_ (?![\s])(?! .*`.*|.*<\/code>.*)(.*?[^\s])_\b (?!.*`.*|.*<\/code>.*))"
45
47
);
46
48
static std::string replacement = " <em>$1</em>" ;
47
49
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class Parser
59
59
*/
60
60
static const std::string& version ()
61
61
{
62
- static const std::string v = " 1.4 .0" ;
62
+ static const std::string v = " 1.5 .0" ;
63
63
return v;
64
64
}
65
65
Original file line number Diff line number Diff line change @@ -40,6 +40,23 @@ class StrongParser : public LineParser
40
40
*/
41
41
void Parse (std::string& line) override
42
42
{
43
+ // This version of the regex is changed exactly the same way
44
+ // that the regex for the emphasized parser was changed, and
45
+ // it then passes all the 'disabled' tests in the 'strong parser'
46
+ // test, but then it fails general parsing. For some reason,
47
+ // "__text__" translates "<i></i>text<i></i>" even though there
48
+ // are no word boundaries at the correct places. It's weird!
49
+
50
+ // static std::vector<std::regex> res{
51
+ // std::regex{
52
+ // R"((?!.*`.*|.*<code>.*)\b\*\*(?![\s])(?!.*`.*|.*<\/code>.*)"
53
+ // "(.*?[^\s])\*\*\b(?!.*`.*|.*<\/code>.*))"
54
+ // },
55
+ // std::regex{
56
+ // R"((?!.*`.*|.*<code>.*)\b__(?![\s])(?!.*`.*|.*<\/code>.*)"
57
+ // "(.*?[^\s])__\b(?!.*`.*|.*<\/code>.*))"
58
+ // }
59
+ // };
43
60
static std::vector<std::regex> res{
44
61
std::regex{
45
62
R"( (?!.*`.*|.*<code>.*)\*\*(?!.*`.*|.*<\/code>.*)([^\*\*]*)\*\*(?!.*`.*|.*<\/code>.*))"
You can’t perform that action at this time.
0 commit comments