Skip to content

Commit 96e79ff

Browse files
committed
issue doxygen#11491 [BUG] Space character is not rendered in code block
1 parent 200cec9 commit 96e79ff

15 files changed

+44
-16
lines changed

src/cmdmapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static const CommandMap<HtmlTagType> g_htmlTagMap =
184184
{ "ol", HtmlTagType::HTML_OL },
185185
{ "ul", HtmlTagType::HTML_UL },
186186
{ "li", HtmlTagType::HTML_LI },
187-
{ "tt", HtmlTagType::XML_C /*HtmlTagType::HTML_CODE*/ },
187+
{ "tt", HtmlTagType::HTML_TT },
188188
{ "kbd", HtmlTagType::HTML_KBD },
189189
{ "em", HtmlTagType::HTML_EMPHASIS },
190190
{ "hr", HtmlTagType::HTML_HR },

src/cmdmapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ enum class HtmlTagType
214214
HTML_TBODY = 42,
215215
HTML_TFOOT = 43,
216216
HTML_KBD = 44,
217+
HTML_TT = 45,
217218

218219
XML_CmdMask = 0x100,
219220

src/docbookvisitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ DB_VIS_C
288288
if (s.enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
289289
break;
290290
case DocStyleChange::Kbd:
291+
case DocStyleChange::Typewriter:
291292
case DocStyleChange::Code:
292293
if (s.enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
293294
break;

src/docnode.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ const char *DocStyleChange::styleString() const
143143
case DocStyleChange::Underline: return "u";
144144
case DocStyleChange::Ins: return "ins";
145145
case DocStyleChange::Kbd: return "kbd";
146+
case DocStyleChange::Typewriter: return "tt";
146147
}
147148
return "<invalid>";
148149
}
@@ -4802,6 +4803,9 @@ Token DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &
48024803
case HtmlTagType::HTML_KBD:
48034804
parser()->handleStyleEnter(thisVariant(),children(),DocStyleChange::Kbd,tagName,&parser()->context.token->attribs);
48044805
break;
4806+
case HtmlTagType::HTML_TT:
4807+
parser()->handleStyleEnter(thisVariant(),children(),DocStyleChange::Typewriter,tagName,&parser()->context.token->attribs);
4808+
break;
48054809
case HtmlTagType::HTML_EMPHASIS:
48064810
if (!parser()->context.token->emptyTag) parser()->handleStyleEnter(thisVariant(),children(),DocStyleChange::Italic,tagName,&parser()->context.token->attribs);
48074811
break;
@@ -5275,6 +5279,9 @@ Token DocPara::handleHtmlEndTag(const QCString &tagName)
52755279
case HtmlTagType::HTML_KBD:
52765280
parser()->handleStyleLeave(thisVariant(),children(),DocStyleChange::Kbd,tagName);
52775281
break;
5282+
case HtmlTagType::HTML_TT:
5283+
parser()->handleStyleLeave(thisVariant(),children(),DocStyleChange::Typewriter,tagName);
5284+
break;
52785285
case HtmlTagType::HTML_EMPHASIS:
52795286
parser()->handleStyleLeave(thisVariant(),children(),DocStyleChange::Italic,tagName);
52805287
break;

src/docnode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ class DocStyleChange : public DocNode
279279
Ins = (1<<13),
280280
S = (1<<14),
281281
Cite = (1<<15),
282-
Kbd = (1<<16)
282+
Kbd = (1<<16),
283+
Typewriter = (1<<17)
283284
};
284285

285286
DocStyleChange(DocParser *parser,DocNodeVariant *parent,size_t position,Style s,

src/docparser.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,9 @@ bool DocParser::defaultHandleToken(DocNodeVariant *parent,Token tok, DocNodeList
14931493
case HtmlTagType::HTML_KBD:
14941494
handleEnterLeaveStyle(DocStyleChange::Kbd);
14951495
break;
1496+
case HtmlTagType::HTML_TT:
1497+
handleEnterLeaveStyle(DocStyleChange::Typewriter);
1498+
break;
14961499
case HtmlTagType::HTML_EMPHASIS:
14971500
handleEnterLeaveStyle(DocStyleChange::Italic);
14981501
break;

src/htmldocvisitor.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,18 @@ void HtmlDocVisitor::operator()(const DocStyleChange &s)
463463
case DocStyleChange::Kbd:
464464
if (s.enable()) m_t << "<kbd" << s.attribs().toString() << ">"; else m_t << "</kbd>";
465465
break;
466+
case DocStyleChange::Typewriter:
467+
if (s.enable())
468+
{
469+
m_t << "<span class=\"tt\"" << s.attribs().toString() << ">";
470+
m_insidePre=true;
471+
}
472+
else
473+
{
474+
m_t << "</span>";
475+
m_insidePre=false;
476+
}
477+
break;
466478
case DocStyleChange::Code:
467479
if (s.enable())
468480
{
@@ -472,9 +484,11 @@ void HtmlDocVisitor::operator()(const DocStyleChange &s)
472484
attribs.mergeAttribute("class","param");
473485
}
474486
m_t << "<code" << attribs.toString() << ">";
487+
m_insidePre=true;
475488
}
476489
else
477490
{
491+
m_insidePre=false;
478492
m_t << "</code>";
479493
}
480494
break;

src/latexdocvisitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ void LatexDocVisitor::operator()(const DocStyleChange &s)
410410
if (s.enable()) m_t << "{\\itshape "; else m_t << "}";
411411
break;
412412
case DocStyleChange::Kbd:
413+
case DocStyleChange::Typewriter:
413414
case DocStyleChange::Code:
414415
if (s.enable()) m_t << "{\\ttfamily "; else m_t << "}";
415416
break;

src/mandocvisitor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ void ManDocVisitor::operator()(const DocStyleChange &s)
148148
m_firstCol=FALSE;
149149
break;
150150
case DocStyleChange::Kbd:
151+
case DocStyleChange::Typewriter:
151152
case DocStyleChange::Code:
152153
if (s.enable()) m_t << "\\fR"; else m_t << "\\fP";
153154
m_firstCol=FALSE;

src/markdown.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,24 +1672,12 @@ int Markdown::Private::processCodeSpan(std::string_view data,size_t)
16721672
return 0; // no matching delimiter
16731673
}
16741674

1675-
// trimming outside whitespaces
1676-
size_t f_begin = nb;
1677-
while (f_begin < end && data[f_begin]==' ')
1678-
{
1679-
f_begin++;
1680-
}
1681-
size_t f_end = end - nb;
1682-
while (f_end > nb && data[f_end-1]==' ')
1683-
{
1684-
f_end--;
1685-
}
1686-
16871675
//printf("found code span '%s'\n",qPrint(QCString(data+f_begin).left(f_end-f_begin)));
16881676

16891677
/* real code span */
1690-
if (f_begin < f_end)
1678+
if (nb+nb < end)
16911679
{
1692-
QCString codeFragment = data.substr(f_begin, f_end-f_begin);
1680+
QCString codeFragment = data.substr(nb, end-nb-nb);
16931681
out+="<tt>";
16941682
out+=escapeSpecialChars(codeFragment);
16951683
out+="</tt>";

0 commit comments

Comments
 (0)