Skip to content

Commit b207447

Browse files
committed
Make better use of capture ranges
1 parent 477b512 commit b207447

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/markdown.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,20 +3526,17 @@ void MarkdownOutlineParser::parseInput(const QCString &fileName,
35263526
break;
35273527
case ExplicitPageResult::explicitPage:
35283528
{
3529-
// look for `@page label Title\n` and capture `label`
3530-
static const reg::Ex re(R"([\\@]page\s+(\a[\w-]*)\s*[^\n]*\n)");
3529+
// look for `@page label My Title\n` and capture `label` (match[1]) and ` My Title` (match[2])
3530+
static const reg::Ex re(R"([\\@]page\s+(\a[\w-]*)(\s*[^\n]*)\n)");
35313531
reg::Match match;
35323532
std::string s = docs.str();
35333533
if (reg::search(s,match,re))
35343534
{
35353535
QCString orgLabel = match[1].str();
35363536
QCString newLabel = markdownFileNameToId(fileName);
3537-
size_t labelStartPos = match[1].position();
3538-
size_t labelEndPos = labelStartPos+match[1].length(); // i.e. first position after the label
3539-
size_t lineLen = match.length();
3540-
docs = docs.left(labelStartPos)+ // part before label
3537+
docs = docs.left(match[1].position())+ // part before label
35413538
newLabel+ // new label
3542-
docs.mid(labelEndPos,lineLen-labelEndPos)+ // part between orgLabel and \n
3539+
match[2].str()+ // part between orgLabel and \n
35433540
"\\ilinebr @anchor "+orgLabel+"\n"+ // add original anchor
35443541
docs.right(docs.length()-match.length()); // add remainder of docs
35453542
}

0 commit comments

Comments
 (0)