Skip to content

Commit dfec5ed

Browse files
authored
Merge pull request doxygen#11211 from albert-github/feature/issue_11209
issue doxygen#11209 `<kbd>` tag gets rewritten as `<code>`
2 parents 5af1d31 + bc0baa7 commit dfec5ed

14 files changed

+35
-4
lines changed

src/cmdmapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static const CommandMap<HtmlTagType> g_htmlTagMap =
183183
{ "ul", HtmlTagType::HTML_UL },
184184
{ "li", HtmlTagType::HTML_LI },
185185
{ "tt", HtmlTagType::XML_C /*HtmlTagType::HTML_CODE*/ },
186-
{ "kbd", HtmlTagType::XML_C /*HtmlTagType::HTML_CODE*/ },
186+
{ "kbd", HtmlTagType::HTML_KBD },
187187
{ "em", HtmlTagType::HTML_EMPHASIS },
188188
{ "hr", HtmlTagType::HTML_HR },
189189
{ "dl", HtmlTagType::HTML_DL },

src/cmdmapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ enum class HtmlTagType
211211
HTML_THEAD = 41,
212212
HTML_TBODY = 42,
213213
HTML_TFOOT = 43,
214+
HTML_KBD = 44,
214215

215216
XML_CmdMask = 0x100,
216217

src/docbookvisitor.cpp

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

src/docnode.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ const char *DocStyleChange::styleString() const
142142
case DocStyleChange::Del: return "del";
143143
case DocStyleChange::Underline: return "u";
144144
case DocStyleChange::Ins: return "ins";
145+
case DocStyleChange::Kbd: return "kbd";
145146
}
146147
return "<invalid>";
147148
}
@@ -4782,6 +4783,9 @@ Token DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &
47824783
parser()->handleStyleEnter(thisVariant(),children(),DocStyleChange::Code,tagName,&parser()->context.token->attribs);
47834784
}
47844785
break;
4786+
case HtmlTagType::HTML_KBD:
4787+
parser()->handleStyleEnter(thisVariant(),children(),DocStyleChange::Kbd,tagName,&parser()->context.token->attribs);
4788+
break;
47854789
case HtmlTagType::HTML_EMPHASIS:
47864790
if (!parser()->context.token->emptyTag) parser()->handleStyleEnter(thisVariant(),children(),DocStyleChange::Italic,tagName,&parser()->context.token->attribs);
47874791
break;
@@ -5252,6 +5256,9 @@ Token DocPara::handleHtmlEndTag(const QCString &tagName)
52525256
case HtmlTagType::HTML_CODE:
52535257
parser()->handleStyleLeave(thisVariant(),children(),DocStyleChange::Code,tagName);
52545258
break;
5259+
case HtmlTagType::HTML_KBD:
5260+
parser()->handleStyleLeave(thisVariant(),children(),DocStyleChange::Kbd,tagName);
5261+
break;
52555262
case HtmlTagType::HTML_EMPHASIS:
52565263
parser()->handleStyleLeave(thisVariant(),children(),DocStyleChange::Italic,tagName);
52575264
break;

src/docnode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ class DocStyleChange : public DocNode
278278
Del = (1<<12),
279279
Ins = (1<<13),
280280
S = (1<<14),
281-
Cite = (1<<15)
281+
Cite = (1<<15),
282+
Kbd = (1<<16)
282283
};
283284

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

src/docparser.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,16 @@ bool DocParser::defaultHandleToken(DocNodeVariant *parent,Token tok, DocNodeList
15131513
handleStyleLeave(parent,children,DocStyleChange::Code,tokenName);
15141514
}
15151515
break;
1516+
case HtmlTagType::HTML_KBD:
1517+
if (!context.token->endTag)
1518+
{
1519+
handleStyleEnter(parent,children,DocStyleChange::Kbd,tokenName,&context.token->attribs);
1520+
}
1521+
else
1522+
{
1523+
handleStyleLeave(parent,children,DocStyleChange::Kbd,tokenName);
1524+
}
1525+
break;
15161526
case HtmlTagType::HTML_EMPHASIS:
15171527
if (!context.token->endTag)
15181528
{

src/htmldocvisitor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ void HtmlDocVisitor::operator()(const DocStyleChange &s)
505505
case DocStyleChange::Italic:
506506
if (s.enable()) m_t << "<em" << htmlAttribsToString(s.attribs()) << ">"; else m_t << "</em>";
507507
break;
508+
case DocStyleChange::Kbd:
509+
if (s.enable()) m_t << "<kbd" << htmlAttribsToString(s.attribs()) << ">"; else m_t << "</kbd>";
510+
break;
508511
case DocStyleChange::Code:
509512
if (s.enable()) m_t << "<code" << htmlAttribsToString(s.attribs()) << ">"; else m_t << "</code>";
510513
break;

src/latexdocvisitor.cpp

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

src/mandocvisitor.cpp

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

src/perlmodgen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ void PerlModDocVisitor::operator()(const DocStyleChange &s)
613613
case DocStyleChange::Preformatted: style = "preformatted"; break;
614614
case DocStyleChange::Div: style = "div"; break;
615615
case DocStyleChange::Span: style = "span"; break;
616+
case DocStyleChange::Kbd: style = "kbd"; break;
616617
}
617618
openItem("style");
618619
m_output.addFieldQuotedString("style", style)

0 commit comments

Comments
 (0)