summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2021-02-13 19:27:10 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2021-02-20 19:17:51 (GMT)
commit275d3ed4372cee6694f0c63bd79d82be8a3d8acd (patch)
tree5bdd7d2c6ce5df0f9c98109225a12bbe54202227 /src
parent0e85b883e4b66632b352f910c3e1ae13f47cb47b (diff)
downloadDoxygen-275d3ed4372cee6694f0c63bd79d82be8a3d8acd.zip
Doxygen-275d3ed4372cee6694f0c63bd79d82be8a3d8acd.tar.gz
Doxygen-275d3ed4372cee6694f0c63bd79d82be8a3d8acd.tar.bz2
Refactoring: replace QRegExp by std::regex in markdown.cpp
Diffstat (limited to 'src')
-rw-r--r--src/markdown.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index b9fad70..df632d7 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -33,11 +33,11 @@
#include <stdio.h>
#include <qglobal.h>
-#include <qregexp.h>
#include <qfileinfo.h>
#include <unordered_map>
#include <functional>
+#include <regex>
#include "markdown.h"
#include "growbuf.h"
@@ -1471,15 +1471,15 @@ static int isHRuler(const char *data,int size)
static QCString extractTitleId(QCString &title, int level)
{
TRACE(title.data());
- //static QRegExp r1("^[a-z_A-Z][a-z_A-Z0-9\\-]*:");
- static QRegExp r2("\\{#[a-z_A-Z][a-z_A-Z0-9\\-]*\\}");
- int l=0;
- int i = r2.match(title,0,&l);
- if (i!=-1 && title.mid(i+l).stripWhiteSpace().isEmpty()) // found {#id} style id
- {
- QCString id = title.mid(i+2,l-3);
- title = title.left(i);
- //printf("found id='%s' title='%s'\n",id.data(),title.data());
+ // match e.g. '{#id-b11} ' and capture 'id-b11'
+ static std::regex r2("\\{#([a-z_A-Z][a-z_A-Z0-9\\-]*)\\}[[:space:]]*$");
+ std::smatch match;
+ std::string ti = title.str();
+ if (std::regex_search(ti,match,r2))
+ {
+ std::string id = match[1].str();
+ title = title.left(match.position());
+ //printf("found match id='%s' title=%s\n",id.c_str(),title.data());
return id;
}
if ((level > 0) && (level <= Config_getInt(TOC_INCLUDE_HEADINGS)))