From c42c0ae66542e4e154c2646fc725890554208d89 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 29 Oct 2019 17:21:50 +0100 Subject: Length of identifying fenced code block In case we have a problem like: ``` /** \file * ``` * router = (new Router()); * ``` */ ``` there is no problem, but as soon as we add a space somewhere before the start or end identifier of the fenced code block we get: ``` .../aa.h:6: warning: reached end of file while inside a '```' block! The command that should end the block seems to be missing! ``` i.e. a problem like: ``` /** \file * ``` * router = (new Router()); * ``` */ ``` or ``` /** \file * ``` * router = (new Router()); * ``` */ ``` The relevant length is the length identifying the fenced code block / number of back ticks, not the number of spaces in front of it (analogous number of tildes). --- src/scanner.l | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/scanner.l b/src/scanner.l index 61b51cb..513846e 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -6630,16 +6630,18 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) BEGIN(DocCopyBlock); } ^({B}*"*"+)?{B}{0,3}"~~~"[~]* { - docBlock+=substitute(yytext,"*"," "); + QCString pat = substitute(yytext,"*"," "); + docBlock+=pat; docBlockName="~~~"; - g_fencedSize=yyleng; + g_fencedSize=pat.stripWhiteSpace().length(); g_nestedComment=FALSE; BEGIN(DocCopyBlock); } ^({B}*"*"+)?{B}{0,3}"```"[`]* { - docBlock+=substitute(yytext,"*"," "); + QCString pat = substitute(yytext,"*"," "); + docBlock+=pat; docBlockName="```"; - g_fencedSize=yyleng; + g_fencedSize=pat.stripWhiteSpace().length(); g_nestedComment=FALSE; BEGIN(DocCopyBlock); } @@ -6755,15 +6757,17 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } ^({B}*"*"+)?{B}{0,3}"~~~"[~]* { - docBlock+=substitute(yytext,"*"," "); - if (g_fencedSize==yyleng) + QCString pat = substitute(yytext,"*"," "); + docBlock+=pat; + if (g_fencedSize==pat.stripWhiteSpace().length()) { BEGIN(DocBlock); } } ^({B}*"*"+)?{B}{0,3}"```"[`]* { - docBlock+=substitute(yytext,"*"," "); - if (g_fencedSize==yyleng) + QCString pat = substitute(yytext,"*"," "); + docBlock+=pat; + if (g_fencedSize==pat.stripWhiteSpace().length()) { BEGIN(DocBlock); } -- cgit v0.12