fixed handling of < and > when they are not used for html tag

This commit is contained in:
Marko Klopcic 2013-01-21 22:22:02 +01:00
commit f6fc808534
5 changed files with 41 additions and 17 deletions

View file

@ -203,7 +203,12 @@ int function(int a, float b)
* </UL> Ends an unnumbered item list.
*
* <VAR> Starts a piece of text displayed in an italic font.
* </VAR>
* </VAR>
*
* \htmlonly
* <u>underlined \b bold text - doxy commands are ignored inside 'htmlonly' section </u>
* \endhtmlonly
* <u>underlined text</u>
*/
int htmlFunction(int a, float b)
{
@ -232,6 +237,8 @@ int htmlFunction(int a, float b)
* &ge;
* &larr;
* &rarr;
* Not an &text; html entity - ignored by Doxygen.
* Not an &text html entity - ampersand is replaced with entity.
*/
int htmlEntitiesFunction(int a, float b)
{

View file

@ -226,6 +226,10 @@ public class doxygen_translate_runme {
" \n" +
" <var> Starts a piece of text displayed in an italic font. \n" +
" </var> \n" +
"\n" +
"<u>underlined \\b bold text - doxy commands are ignored inside 'htmlonly' section </u>\n" +
"\n" +
"&lt;u&gt;underlined text&lt;u&gt;\n" +
"");
wantedComments.put("doxygen_translate.doxygen_translate.htmlEntitiesFunction(int, float)",
@ -250,6 +254,8 @@ public class doxygen_translate_runme {
"&ge; \n" +
"&larr; \n" +
"&rarr; \n" +
"Not an html entity - ignored by Doxygen. \n" +
"Not an &amp;text html entity - ampersand is replaced with entity.\n" +
"");
// and ask the parser to check comments for us

View file

@ -2,7 +2,9 @@
#ifndef DOXYGENCOMMANDS_H
#define DOXYGENCOMMANDS_H
// doxy commands are not processed inside this block
const char *CMD_HTML_ONLY = "htmlonly";
// doxy commands are not processed inside this block
const char *CMD_VERBATIM = "verbatim";
const char *CMD_END_HTML_ONLY = "endhtmlonly";
const char *CMD_END_VERBATIM = "endverbatim";

View file

@ -1136,15 +1136,15 @@ size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line)
pos++;
// characters '$[]{}' are used in commands \f$, \f[, ...
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz$[]{}", pos);
string cmd = line.substr(pos , endOfWordPos - pos);
string cmd = line.substr(pos, endOfWordPos - pos);
if (cmd == CMD_END_HTML_ONLY || cmd == CMD_END_VERBATIM) {
m_isVerbatimText = false;
addDoxyCommand(m_tokenList, cmd);
} else {
cmd = line[pos] + cmd; // prepend '\\' or '@'
m_tokenList.push_back(Token(PLAINSTRING,
line.substr(pos, endOfWordPos - pos)));
// include '\' or '@'
line.substr(pos - 1, endOfWordPos - pos + 1)));
}
pos = endOfWordPos;
} else {
@ -1189,14 +1189,14 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
addDoxyCommand(m_tokenList, cmd);
if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM) {
m_isVerbatimText = true;
}
// skip any possible spaces after command, because some commands have parameters,
// and spaces between command and parameter must be ignored.
if (endOfWordPos != string::npos) {
pos = line.find_first_not_of(" \t", endOfWordPos);
} else {
pos = string::npos;
// skip any possible spaces after command, because some commands have parameters,
// and spaces between command and parameter must be ignored.
if (endOfWordPos != string::npos) {
endOfWordPos = line.find_first_not_of(" \t", endOfWordPos);
}
}
pos = endOfWordPos;
} break;
case ' ': // whitespace
@ -1248,27 +1248,34 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line)
m_tokenList.push_back(Token(PLAINSTRING, ""));
}
}
pos++; // skip '>'
} else {
// the command is not HTML supported by Doxygen, < and > will be
// replaced by HTML entities &lt; and &gt; respectively,
// but only if 'htmlOnly' flag == false. The flag is set/reset by \htmlonly \verbatim,
// \endhtmlonly \endverbatim Doxygen commands.
m_tokenList.push_back(Token(PLAINSTRING, "&lt;"));
addDoxyCommand(m_tokenList, "&lt");
m_tokenList.push_back(Token(PLAINSTRING, cmd));
}
pos++;
} break;
case '>': // this char is detected here only when it is not part of HTML tag
addDoxyCommand(m_tokenList, "&gt");
pos++;
break;
case '&': { // process HTML entities
size_t endOfWordPos = line.find_first_not_of("abcdefghijklmnopqrstuvwxyz", pos + 1);
if (endOfWordPos != string::npos) {
if (line[endOfWordPos] == ';') {
// if entity is not recognized by Doxygen (not in the list of
// commands) nothing is added (here and in Doxygen).
addDoxyCommand(m_tokenList, line.substr(pos, endOfWordPos - pos));
endOfWordPos++; // skip ';'
} else {
// it is not an entity - push plain string
// it is not an entity - add entity for ampersand and
// the rest of string
addDoxyCommand(m_tokenList, "&amp");
m_tokenList.push_back(Token(PLAINSTRING,
line.substr(pos, endOfWordPos - pos)));
line.substr(pos + 1, endOfWordPos - pos - 1)));
}
}
pos = endOfWordPos;
@ -1322,7 +1329,7 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment,
while (pos != string::npos) {
// find the end of the word
size_t doxyCmdOrHtmlTagPos = line.find_first_of("\\@<& \t", pos);
size_t doxyCmdOrHtmlTagPos = line.find_first_of("\\@<>& \t", pos);
if (doxyCmdOrHtmlTagPos != pos) {
// plain text found
m_tokenList.push_back(Token(PLAINSTRING,

View file

@ -49,7 +49,7 @@ void JavaDocConverter::fillStaticTables() {
* Java src is <x> and therefore invisible on output - browser ignores unknown command.
* This is handy in syntax descriptions, for example: more <fileName>.
*
* Standlaone < and > need not to be translated, they are rendered properly in
* Standlaone < and > need not be translated, they are rendered properly in
* all three outputs.
*
* ., %, and " need not to be translated
@ -92,6 +92,8 @@ void JavaDocConverter::fillStaticTables() {
tagHandlers["bug"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["date"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["details"] = make_pair(&JavaDocConverter::handleParagraph, "");
// this command is inserts text accumulated after cmd htmlonly -
// see DoxygenParser - CMD_HTML_ONLY.
tagHandlers["htmlonly"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["invariant"] = make_pair(&JavaDocConverter::handleParagraph, "");
tagHandlers["latexonly"] = make_pair(&JavaDocConverter::handleParagraph, "");