From 83db204cd8839b0bbe49e9ba1dc90f7519e34f71 Mon Sep 17 00:00:00 2001 From: albert-github Date: Thu, 4 Apr 2019 14:43:57 +0200 Subject: Adding HTML tags ins and del Github does not support the `` tag for underlined text, in HTML there exists the tag ``. On https://www.w3schools.com/tags/tag_ins.asp is written: The `` tag defines a text that has been inserted into a document. Browsers will normally strike a line through deleted text and underline inserted text. Most browsers will display the `` element with the following default values: ``` ins { text-decoration: underline; } ``` analogous there exists the tag `` (https://www.w3schools.com/tags/tag_del.asp): The `` tag defines text that has been deleted from a document. Browsers will normally strike a line through deleted text and underline inserted text. Most browsers will display the `` element with the following default values: ``` del { text-decoration: line-through; } ``` Definitions analogue to the underline and strike through tag the implementation for the other formats has been chosen. --- doc/htmlcmds.doc | 4 ++++ src/cmdmapper.cpp | 2 ++ src/cmdmapper.h | 2 ++ src/docbookvisitor.cpp | 2 ++ src/docparser.cpp | 34 ++++++++++++++++++++++++++++++++++ src/docparser.h | 4 +++- src/doctokenizer.l | 4 ++-- src/htmldocvisitor.cpp | 6 ++++++ src/latexdocvisitor.cpp | 2 ++ src/mandocvisitor.cpp | 2 ++ src/perlmodgen.cpp | 2 ++ src/printdocvisitor.h | 6 ++++++ src/rtfdocvisitor.cpp | 2 ++ src/xmldocvisitor.cpp | 6 ++++++ testing/086/086__style__tags_8h.xml | 13 +++++++++++++ testing/086_style_tags.h | 17 +++++++++++++++++ 16 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 testing/086/086__style__tags_8h.xml create mode 100644 testing/086_style_tags.h diff --git a/doc/htmlcmds.doc b/doc/htmlcmds.doc index d483237..12347ab 100644 --- a/doc/htmlcmds.doc +++ b/doc/htmlcmds.doc @@ -45,6 +45,8 @@ of a HTML tag are passed on to the HTML output only \ref cmdendcode "\\endcode".
  • \ Starts an item description.
  • \ Ends an item description. +
  • \ Starts a section of deleted text, typically shown strike through text. +
  • \ Ends a section of deleted text.
  • \ Starts a piece of text displayed in a typewriter font.
  • \ Ends a \ section.
  • \
    Starts a section with a specific style (HTML only) @@ -71,6 +73,8 @@ of a HTML tag are passed on to the HTML output only
  • \ Starts a piece of text displayed in an italic font.
  • \ Ends a \ section.
  • \ This command is written with its attributes to the HTML output only. The SRC attribute is mandatory. +
  • \ Starts a section of inserted text, typically shown as underlined text. +
  • \ Ends a section of inserted text.
  • \ Starts a new list item.
  • \ Ends a list item.
  • \ Starts a numbered item list. diff --git a/src/cmdmapper.cpp b/src/cmdmapper.cpp index 55f8214..b4d35d4 100644 --- a/src/cmdmapper.cpp +++ b/src/cmdmapper.cpp @@ -197,6 +197,8 @@ CommandMap htmlTagMap[] = { "blockquote", HTML_BLOCKQUOTE }, { "strike", HTML_STRIKE }, { "u", HTML_UNDERLINE }, + { "ins", HTML_INS }, + { "del", HTML_DEL }, { "c", XML_C }, // { "code", XML_CODE }, <= ambiguous is also a HTML tag diff --git a/src/cmdmapper.h b/src/cmdmapper.h index 8c49b3f..d670cd4 100644 --- a/src/cmdmapper.h +++ b/src/cmdmapper.h @@ -179,6 +179,8 @@ enum HtmlTagType HTML_BLOCKQUOTE= 33, HTML_STRIKE = 34, HTML_UNDERLINE = 35, + HTML_INS = 36, + HTML_DEL = 37, XML_CmdMask = 0x100, diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 64425c6..33b3a53 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -263,7 +263,9 @@ DB_VIS_C case DocStyleChange::Small: /* XSLT Stylesheets can be used */ break; /* HTML only */ case DocStyleChange::Strike: break; + case DocStyleChange::Del: break; case DocStyleChange::Underline: break; + case DocStyleChange::Ins: break; case DocStyleChange::Div: /* HTML only */ break; case DocStyleChange::Span: /* HTML only */ break; } diff --git a/src/docparser.cpp b/src/docparser.cpp index 1c8479b..bba27a3 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -1095,7 +1095,9 @@ const char *DocStyleChange::styleString() const case DocStyleChange::Div: return "div"; case DocStyleChange::Span: return "span"; case DocStyleChange::Strike: return "strike"; + case DocStyleChange::Del: return "del"; case DocStyleChange::Underline: return "u"; + case DocStyleChange::Ins: return "ins"; } return ""; } @@ -1625,6 +1627,16 @@ reparsetoken: handleStyleLeave(parent,children,DocStyleChange::Strike,tokenName); } break; + case HTML_DEL: + if (!g_token->endTag) + { + handleStyleEnter(parent,children,DocStyleChange::Del,&g_token->attribs); + } + else + { + handleStyleLeave(parent,children,DocStyleChange::Del,tokenName); + } + break; case HTML_UNDERLINE: if (!g_token->endTag) { @@ -1635,6 +1647,16 @@ reparsetoken: handleStyleLeave(parent,children,DocStyleChange::Underline,tokenName); } break; + case HTML_INS: + if (!g_token->endTag) + { + handleStyleEnter(parent,children,DocStyleChange::Ins,&g_token->attribs); + } + else + { + handleStyleLeave(parent,children,DocStyleChange::Ins,tokenName); + } + break; case HTML_CODE: case XML_C: if (!g_token->endTag) @@ -6041,9 +6063,15 @@ int DocPara::handleHtmlStartTag(const QCString &tagName,const HtmlAttribList &ta case HTML_STRIKE: handleStyleEnter(this,m_children,DocStyleChange::Strike,&g_token->attribs); break; + case HTML_DEL: + handleStyleEnter(this,m_children,DocStyleChange::Del,&g_token->attribs); + break; case HTML_UNDERLINE: handleStyleEnter(this,m_children,DocStyleChange::Underline,&g_token->attribs); break; + case HTML_INS: + handleStyleEnter(this,m_children,DocStyleChange::Ins,&g_token->attribs); + break; case HTML_CODE: if (/*getLanguageFromFileName(g_fileName)==SrcLangExt_CSharp ||*/ g_xmlComment) // for C# source or inside a or section we @@ -6456,9 +6484,15 @@ int DocPara::handleHtmlEndTag(const QCString &tagName) case HTML_STRIKE: handleStyleLeave(this,m_children,DocStyleChange::Strike,"strike"); break; + case HTML_DEL: + handleStyleLeave(this,m_children,DocStyleChange::Del,"del"); + break; case HTML_UNDERLINE: handleStyleLeave(this,m_children,DocStyleChange::Underline,"u"); break; + case HTML_INS: + handleStyleLeave(this,m_children,DocStyleChange::Ins,"ins"); + break; case HTML_CODE: handleStyleLeave(this,m_children,DocStyleChange::Code,"code"); break; diff --git a/src/docparser.h b/src/docparser.h index 15180f9..8e3b266 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -382,7 +382,9 @@ class DocStyleChange : public DocNode Span = (1<<8), Div = (1<<9), Strike = (1<<10), - Underline = (1<<11) + Underline = (1<<11), + Del = (1<<12), + Ins = (1<<13) }; DocStyleChange(DocNode *parent,uint position,Style s,bool enable, diff --git a/src/doctokenizer.l b/src/doctokenizer.l index 5cf5f02..1c102a1 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -405,8 +405,8 @@ WORD1NQ {ESCWORD}|{CHARWORDQ}+|"{"|"}" WORD2NQ "."|","|"("|")"|"["|"]"|"::"|":"|";"|"\?"|"="|"'" CAPTION [cC][aA][pP][tT][iI][oO][nN] HTMLTAG "<"(("/")?){ID}({WS}+{ATTRIB})*{WS}*(("/")?)">" -HTMLKEYL "strong"|"center"|"table"|"caption"|"small"|"code"|"dfn"|"var"|"img"|"pre"|"sub"|"sup"|"tr"|"td"|"th"|"ol"|"ul"|"li"|"tt"|"kbd"|"em"|"hr"|"dl"|"dt"|"dd"|"br"|"i"|"a"|"b"|"p"|"strike"|"u" -HTMLKEYU "STRONG"|"CENTER"|"TABLE"|"CAPTION"|"SMALL"|"CODE"|"DFN"|"VAR"|"IMG"|"PRE"|"SUB"|"SUP"|"TR"|"TD"|"TH"|"OL"|"UL"|"LI"|"TT"|"KBD"|"EM"|"HR"|"DL"|"DT"|"DD"|"BR"|"I"|"A"|"B"|"P"|"STRIKE"|"U" +HTMLKEYL "strong"|"center"|"table"|"caption"|"small"|"code"|"dfn"|"var"|"img"|"pre"|"sub"|"sup"|"tr"|"td"|"th"|"ol"|"ul"|"li"|"tt"|"kbd"|"em"|"hr"|"dl"|"dt"|"dd"|"br"|"i"|"a"|"b"|"p"|"strike"|"u"|"del"|"ins" +HTMLKEYU "STRONG"|"CENTER"|"TABLE"|"CAPTION"|"SMALL"|"CODE"|"DFN"|"VAR"|"IMG"|"PRE"|"SUB"|"SUP"|"TR"|"TD"|"TH"|"OL"|"UL"|"LI"|"TT"|"KBD"|"EM"|"HR"|"DL"|"DT"|"DD"|"BR"|"I"|"A"|"B"|"P"|"STRIKE"|"U"|"DEL"|"INS" HTMLKEYW {HTMLKEYL}|{HTMLKEYU} REFWORD2_PRE ("#"|"::")?((({ID}{TEMPLPART}?)|{ANONNS})("."|"#"|"::"|"-"|"/"))*({ID}{TEMPLPART}?(":")?) REFWORD2 {REFWORD2_PRE}{FUNCARG2}? diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index 37f6bd0..6e637f2 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -403,9 +403,15 @@ void HtmlDocVisitor::visit(DocStyleChange *s) case DocStyleChange::Strike: if (s->enable()) m_t << "attribs()) << ">"; else m_t << ""; break; + case DocStyleChange::Del: + if (s->enable()) m_t << "attribs()) << ">"; else m_t << ""; + break; case DocStyleChange::Underline: if (s->enable()) m_t << "attribs()) << ">"; else m_t << ""; break; + case DocStyleChange::Ins: + if (s->enable()) m_t << "attribs()) << ">"; else m_t << ""; + break; case DocStyleChange::Italic: if (s->enable()) m_t << "attribs()) << ">"; else m_t << ""; break; diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 2e979bd..02f5a03 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -292,9 +292,11 @@ void LatexDocVisitor::visit(DocStyleChange *s) if (s->enable()) m_t << "{\\bfseries{"; else m_t << "}}"; break; case DocStyleChange::Strike: + case DocStyleChange::Del: if (s->enable()) m_t << "\\sout{"; else m_t << "}"; break; case DocStyleChange::Underline: + case DocStyleChange::Ins: if (s->enable()) m_t << "\\uline{"; else m_t << "}"; break; case DocStyleChange::Italic: diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp index 5c98c6f..25e56d3 100644 --- a/src/mandocvisitor.cpp +++ b/src/mandocvisitor.cpp @@ -137,9 +137,11 @@ void ManDocVisitor::visit(DocStyleChange *s) m_firstCol=FALSE; break; case DocStyleChange::Strike: + case DocStyleChange::Del: /* not supported */ break; case DocStyleChange::Underline: //underline is shown as emphasis + case DocStyleChange::Ins: if (s->enable()) m_t << "\\fI"; else m_t << "\\fP"; m_firstCol=FALSE; break; diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index 1ec4bf3..7cc2940 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -642,7 +642,9 @@ void PerlModDocVisitor::visit(DocStyleChange *s) { case DocStyleChange::Bold: style = "bold"; break; case DocStyleChange::Strike: style = "strike"; break; + case DocStyleChange::Del: style = "del"; break; case DocStyleChange::Underline: style = "underline"; break; + case DocStyleChange::Ins: style = "ins"; break; case DocStyleChange::Italic: style = "italic"; break; case DocStyleChange::Code: style = "code"; break; case DocStyleChange::Subscript: style = "subscript"; break; diff --git a/src/printdocvisitor.h b/src/printdocvisitor.h index 26bb3e7..1472110 100644 --- a/src/printdocvisitor.h +++ b/src/printdocvisitor.h @@ -108,9 +108,15 @@ class PrintDocVisitor : public DocVisitor case DocStyleChange::Strike: if (s->enable()) printf(""); else printf(""); break; + case DocStyleChange::Del: + if (s->enable()) printf(""); else printf(""); + break; case DocStyleChange::Underline: if (s->enable()) printf(""); else printf(""); break; + case DocStyleChange::Ins: + if (s->enable()) printf(""); else printf(""); + break; case DocStyleChange::Italic: if (s->enable()) printf(""); else printf(""); break; diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 55c03a5..efeac64 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -236,9 +236,11 @@ void RTFDocVisitor::visit(DocStyleChange *s) if (s->enable()) m_t << "{\\b "; else m_t << "} "; break; case DocStyleChange::Strike: + case DocStyleChange::Del: if (s->enable()) m_t << "{\\strike "; else m_t << "} "; break; case DocStyleChange::Underline: + case DocStyleChange::Ins: if (s->enable()) m_t << "{\\ul "; else m_t << "} "; break; case DocStyleChange::Italic: diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index 1005719..444fbe8 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -190,9 +190,15 @@ void XmlDocVisitor::visit(DocStyleChange *s) case DocStyleChange::Strike: if (s->enable()) m_t << ""; else m_t << ""; break; + case DocStyleChange::Del: + if (s->enable()) m_t << ""; else m_t << ""; + break; case DocStyleChange::Underline: if (s->enable()) m_t << ""; else m_t << ""; break; + case DocStyleChange::Ins: + if (s->enable()) m_t << ""; else m_t << ""; + break; case DocStyleChange::Italic: if (s->enable()) m_t << ""; else m_t << ""; break; diff --git a/testing/086/086__style__tags_8h.xml b/testing/086/086__style__tags_8h.xml new file mode 100644 index 0000000..a1803da --- /dev/null +++ b/testing/086/086__style__tags_8h.xml @@ -0,0 +1,13 @@ + + + + 086_style_tags.h + + + + In the following the word tag has the style as indicated before it.This is a bold tag.This is a strong bold tag.This is an italic tag.This is an em italic tag.This is a strike through tag.This is an underline tag.This is an insterted tag.This is a deleted tag.This is a typewriter tag. + + + + + diff --git a/testing/086_style_tags.h b/testing/086_style_tags.h new file mode 100644 index 0000000..105adca --- /dev/null +++ b/testing/086_style_tags.h @@ -0,0 +1,17 @@ +// objective: test different HTML style tags +// check: 086__style__tags_8h.xml +/** +\file + +In the following the word tag has the style as indicated before it. +- This is a bold tag. +- This is a `strong` bold tag. +- This is an italic tag. +- This is an `em` italic tag. +- This is a strike through tag. +- This is an underline tag. +- This is an insterted tag. +- This is a deleted tag. +- This is a typewriter tag. +*/ + -- cgit v0.12