@@ -1447,6 +1447,16 @@ bool DocParser::defaultHandleToken(DocNodeVariant *parent,Token tok, DocNodeList
14471447 break ;
14481448 case TokenRetval::TK_HTMLTAG:
14491449 {
1450+ auto handleEnterLeaveStyle = [this ,&parent,&children,&tokenName](DocStyleChange::Style style) {
1451+ if (!context.token ->endTag )
1452+ {
1453+ handleStyleEnter (parent,children,style,tokenName,&context.token ->attribs );
1454+ }
1455+ else
1456+ {
1457+ handleStyleLeave (parent,children,style,tokenName);
1458+ }
1459+ };
14501460 switch (Mappers::htmlTagMapper->map (tokenName))
14511461 {
14521462 case HtmlTagType::HTML_DIV:
@@ -1456,159 +1466,56 @@ bool DocParser::defaultHandleToken(DocNodeVariant *parent,Token tok, DocNodeList
14561466 warn_doc_error (context.fileName ,tokenizer.getLineNr ()," found <pre> tag in heading" );
14571467 break ;
14581468 case HtmlTagType::HTML_SPAN:
1459- if (!context.token ->endTag )
1460- {
1461- handleStyleEnter (parent,children,DocStyleChange::Span,tokenName,&context.token ->attribs );
1462- }
1463- else
1464- {
1465- handleStyleLeave (parent,children,DocStyleChange::Span,tokenName);
1466- }
1469+ handleEnterLeaveStyle (DocStyleChange::Span);
14671470 break ;
14681471 case HtmlTagType::HTML_BOLD:
1469- if (!context.token ->endTag )
1470- {
1471- handleStyleEnter (parent,children,DocStyleChange::Bold,tokenName,&context.token ->attribs );
1472- }
1473- else
1474- {
1475- handleStyleLeave (parent,children,DocStyleChange::Bold,tokenName);
1476- }
1472+ handleEnterLeaveStyle (DocStyleChange::Bold);
14771473 break ;
14781474 case HtmlTagType::HTML_S:
1479- if (!context.token ->endTag )
1480- {
1481- handleStyleEnter (parent,children,DocStyleChange::S,tokenName,&context.token ->attribs );
1482- }
1483- else
1484- {
1485- handleStyleLeave (parent,children,DocStyleChange::S,tokenName);
1486- }
1475+ handleEnterLeaveStyle (DocStyleChange::S);
14871476 break ;
14881477 case HtmlTagType::HTML_STRIKE:
1489- if (!context.token ->endTag )
1490- {
1491- handleStyleEnter (parent,children,DocStyleChange::Strike,tokenName,&context.token ->attribs );
1492- }
1493- else
1494- {
1495- handleStyleLeave (parent,children,DocStyleChange::Strike,tokenName);
1496- }
1478+ handleEnterLeaveStyle (DocStyleChange::Strike);
14971479 break ;
14981480 case HtmlTagType::HTML_DEL:
1499- if (!context.token ->endTag )
1500- {
1501- handleStyleEnter (parent,children,DocStyleChange::Del,tokenName,&context.token ->attribs );
1502- }
1503- else
1504- {
1505- handleStyleLeave (parent,children,DocStyleChange::Del,tokenName);
1506- }
1481+ handleEnterLeaveStyle (DocStyleChange::Del);
15071482 break ;
15081483 case HtmlTagType::HTML_UNDERLINE:
1509- if (!context.token ->endTag )
1510- {
1511- handleStyleEnter (parent,children,DocStyleChange::Underline,tokenName,&context.token ->attribs );
1512- }
1513- else
1514- {
1515- handleStyleLeave (parent,children,DocStyleChange::Underline,tokenName);
1516- }
1484+ handleEnterLeaveStyle (DocStyleChange::Underline);
15171485 break ;
15181486 case HtmlTagType::HTML_INS:
1519- if (!context.token ->endTag )
1520- {
1521- handleStyleEnter (parent,children,DocStyleChange::Ins,tokenName,&context.token ->attribs );
1522- }
1523- else
1524- {
1525- handleStyleLeave (parent,children,DocStyleChange::Ins,tokenName);
1526- }
1487+ handleEnterLeaveStyle (DocStyleChange::Ins);
15271488 break ;
15281489 case HtmlTagType::HTML_CODE:
15291490 case HtmlTagType::XML_C:
1530- if (!context.token ->endTag )
1531- {
1532- handleStyleEnter (parent,children,DocStyleChange::Code,tokenName,&context.token ->attribs );
1533- }
1534- else
1535- {
1536- handleStyleLeave (parent,children,DocStyleChange::Code,tokenName);
1537- }
1491+ handleEnterLeaveStyle (DocStyleChange::Code);
15381492 break ;
15391493 case HtmlTagType::HTML_KBD:
1540- if (!context.token ->endTag )
1541- {
1542- handleStyleEnter (parent,children,DocStyleChange::Kbd,tokenName,&context.token ->attribs );
1543- }
1544- else
1545- {
1546- handleStyleLeave (parent,children,DocStyleChange::Kbd,tokenName);
1547- }
1494+ handleEnterLeaveStyle (DocStyleChange::Kbd);
15481495 break ;
15491496 case HtmlTagType::HTML_EMPHASIS:
1550- if (!context.token ->endTag )
1551- {
1552- handleStyleEnter (parent,children,DocStyleChange::Italic,tokenName,&context.token ->attribs );
1553- }
1554- else
1555- {
1556- handleStyleLeave (parent,children,DocStyleChange::Italic,tokenName);
1557- }
1497+ handleEnterLeaveStyle (DocStyleChange::Italic);
15581498 break ;
15591499 case HtmlTagType::HTML_SUB:
1560- if (!context.token ->endTag )
1561- {
1562- handleStyleEnter (parent,children,DocStyleChange::Subscript,tokenName,&context.token ->attribs );
1563- }
1564- else
1565- {
1566- handleStyleLeave (parent,children,DocStyleChange::Subscript,tokenName);
1567- }
1500+ handleEnterLeaveStyle (DocStyleChange::Subscript);
15681501 break ;
15691502 case HtmlTagType::HTML_SUP:
1570- if (!context.token ->endTag )
1571- {
1572- handleStyleEnter (parent,children,DocStyleChange::Superscript,tokenName,&context.token ->attribs );
1573- }
1574- else
1575- {
1576- handleStyleLeave (parent,children,DocStyleChange::Superscript,tokenName);
1577- }
1503+ handleEnterLeaveStyle (DocStyleChange::Superscript);
15781504 break ;
15791505 case HtmlTagType::HTML_CENTER:
1580- if (!context.token ->endTag )
1581- {
1582- handleStyleEnter (parent,children,DocStyleChange::Center,tokenName,&context.token ->attribs );
1583- }
1584- else
1585- {
1586- handleStyleLeave (parent,children,DocStyleChange::Center,tokenName);
1587- }
1506+ handleEnterLeaveStyle (DocStyleChange::Center);
15881507 break ;
15891508 case HtmlTagType::HTML_SMALL:
1590- if (!context.token ->endTag )
1591- {
1592- handleStyleEnter (parent,children,DocStyleChange::Small,tokenName,&context.token ->attribs );
1593- }
1594- else
1595- {
1596- handleStyleLeave (parent,children,DocStyleChange::Small,tokenName);
1597- }
1509+ handleEnterLeaveStyle (DocStyleChange::Small);
15981510 break ;
15991511 case HtmlTagType::HTML_CITE:
1600- if (!context.token ->endTag )
1601- {
1602- handleStyleEnter (parent,children,DocStyleChange::Cite,tokenName,&context.token ->attribs );
1603- }
1604- else
1605- {
1606- handleStyleLeave (parent,children,DocStyleChange::Cite,tokenName);
1607- }
1512+ handleEnterLeaveStyle (DocStyleChange::Cite);
16081513 break ;
16091514 case HtmlTagType::HTML_IMG:
16101515 if (!context.token ->endTag )
1516+ {
16111517 handleImg (parent,children,context.token ->attribs );
1518+ }
16121519 break ;
16131520 default :
16141521 return FALSE ;
0 commit comments