@@ -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:
@@ -1455,150 +1465,57 @@ bool DocParser::defaultHandleToken(DocNodeVariant *parent,Token tok, DocNodeList
14551465 case HtmlTagType::HTML_PRE:
14561466 warn_doc_error (context.fileName ,tokenizer.getLineNr ()," found <pre> tag in heading" );
14571467 break ;
1468+ case HtmlTagType::HTML_SPAN:
1469+ handleEnterLeaveStyle (DocStyleChange::Span);
1470+ break ;
14581471 case HtmlTagType::HTML_BOLD:
1459- if (!context.token ->endTag )
1460- {
1461- handleStyleEnter (parent,children,DocStyleChange::Bold,tokenName,&context.token ->attribs );
1462- }
1463- else
1464- {
1465- handleStyleLeave (parent,children,DocStyleChange::Bold,tokenName);
1466- }
1472+ handleEnterLeaveStyle (DocStyleChange::Bold);
14671473 break ;
14681474 case HtmlTagType::HTML_S:
1469- if (!context.token ->endTag )
1470- {
1471- handleStyleEnter (parent,children,DocStyleChange::S,tokenName,&context.token ->attribs );
1472- }
1473- else
1474- {
1475- handleStyleLeave (parent,children,DocStyleChange::S,tokenName);
1476- }
1475+ handleEnterLeaveStyle (DocStyleChange::S);
14771476 break ;
14781477 case HtmlTagType::HTML_STRIKE:
1479- if (!context.token ->endTag )
1480- {
1481- handleStyleEnter (parent,children,DocStyleChange::Strike,tokenName,&context.token ->attribs );
1482- }
1483- else
1484- {
1485- handleStyleLeave (parent,children,DocStyleChange::Strike,tokenName);
1486- }
1478+ handleEnterLeaveStyle (DocStyleChange::Strike);
14871479 break ;
14881480 case HtmlTagType::HTML_DEL:
1489- if (!context.token ->endTag )
1490- {
1491- handleStyleEnter (parent,children,DocStyleChange::Del,tokenName,&context.token ->attribs );
1492- }
1493- else
1494- {
1495- handleStyleLeave (parent,children,DocStyleChange::Del,tokenName);
1496- }
1481+ handleEnterLeaveStyle (DocStyleChange::Del);
14971482 break ;
14981483 case HtmlTagType::HTML_UNDERLINE:
1499- if (!context.token ->endTag )
1500- {
1501- handleStyleEnter (parent,children,DocStyleChange::Underline,tokenName,&context.token ->attribs );
1502- }
1503- else
1504- {
1505- handleStyleLeave (parent,children,DocStyleChange::Underline,tokenName);
1506- }
1484+ handleEnterLeaveStyle (DocStyleChange::Underline);
15071485 break ;
15081486 case HtmlTagType::HTML_INS:
1509- if (!context.token ->endTag )
1510- {
1511- handleStyleEnter (parent,children,DocStyleChange::Ins,tokenName,&context.token ->attribs );
1512- }
1513- else
1514- {
1515- handleStyleLeave (parent,children,DocStyleChange::Ins,tokenName);
1516- }
1487+ handleEnterLeaveStyle (DocStyleChange::Ins);
15171488 break ;
15181489 case HtmlTagType::HTML_CODE:
15191490 case HtmlTagType::XML_C:
1520- if (!context.token ->endTag )
1521- {
1522- handleStyleEnter (parent,children,DocStyleChange::Code,tokenName,&context.token ->attribs );
1523- }
1524- else
1525- {
1526- handleStyleLeave (parent,children,DocStyleChange::Code,tokenName);
1527- }
1491+ handleEnterLeaveStyle (DocStyleChange::Code);
15281492 break ;
15291493 case HtmlTagType::HTML_KBD:
1530- if (!context.token ->endTag )
1531- {
1532- handleStyleEnter (parent,children,DocStyleChange::Kbd,tokenName,&context.token ->attribs );
1533- }
1534- else
1535- {
1536- handleStyleLeave (parent,children,DocStyleChange::Kbd,tokenName);
1537- }
1494+ handleEnterLeaveStyle (DocStyleChange::Kbd);
15381495 break ;
15391496 case HtmlTagType::HTML_EMPHASIS:
1540- if (!context.token ->endTag )
1541- {
1542- handleStyleEnter (parent,children,DocStyleChange::Italic,tokenName,&context.token ->attribs );
1543- }
1544- else
1545- {
1546- handleStyleLeave (parent,children,DocStyleChange::Italic,tokenName);
1547- }
1497+ handleEnterLeaveStyle (DocStyleChange::Italic);
15481498 break ;
15491499 case HtmlTagType::HTML_SUB:
1550- if (!context.token ->endTag )
1551- {
1552- handleStyleEnter (parent,children,DocStyleChange::Subscript,tokenName,&context.token ->attribs );
1553- }
1554- else
1555- {
1556- handleStyleLeave (parent,children,DocStyleChange::Subscript,tokenName);
1557- }
1500+ handleEnterLeaveStyle (DocStyleChange::Subscript);
15581501 break ;
15591502 case HtmlTagType::HTML_SUP:
1560- if (!context.token ->endTag )
1561- {
1562- handleStyleEnter (parent,children,DocStyleChange::Superscript,tokenName,&context.token ->attribs );
1563- }
1564- else
1565- {
1566- handleStyleLeave (parent,children,DocStyleChange::Superscript,tokenName);
1567- }
1503+ handleEnterLeaveStyle (DocStyleChange::Superscript);
15681504 break ;
15691505 case HtmlTagType::HTML_CENTER:
1570- if (!context.token ->endTag )
1571- {
1572- handleStyleEnter (parent,children,DocStyleChange::Center,tokenName,&context.token ->attribs );
1573- }
1574- else
1575- {
1576- handleStyleLeave (parent,children,DocStyleChange::Center,tokenName);
1577- }
1506+ handleEnterLeaveStyle (DocStyleChange::Center);
15781507 break ;
15791508 case HtmlTagType::HTML_SMALL:
1580- if (!context.token ->endTag )
1581- {
1582- handleStyleEnter (parent,children,DocStyleChange::Small,tokenName,&context.token ->attribs );
1583- }
1584- else
1585- {
1586- handleStyleLeave (parent,children,DocStyleChange::Small,tokenName);
1587- }
1509+ handleEnterLeaveStyle (DocStyleChange::Small);
15881510 break ;
15891511 case HtmlTagType::HTML_CITE:
1590- if (!context.token ->endTag )
1591- {
1592- handleStyleEnter (parent,children,DocStyleChange::Cite,tokenName,&context.token ->attribs );
1593- }
1594- else
1595- {
1596- handleStyleLeave (parent,children,DocStyleChange::Cite,tokenName);
1597- }
1512+ handleEnterLeaveStyle (DocStyleChange::Cite);
15981513 break ;
15991514 case HtmlTagType::HTML_IMG:
16001515 if (!context.token ->endTag )
1516+ {
16011517 handleImg (parent,children,context.token ->attribs );
1518+ }
16021519 break ;
16031520 default :
16041521 return FALSE ;
0 commit comments