fixed handling of < and > when they are not used for html tag
This commit is contained in:
parent
a2b0d42c32
commit
f6fc808534
5 changed files with 41 additions and 17 deletions
|
|
@ -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)
|
|||
* ≥
|
||||
* ←
|
||||
* →
|
||||
* Not an &text; html entity - ignored by Doxygen.
|
||||
* Not an &text html entity - ampersand is replaced with entity.
|
||||
*/
|
||||
int htmlEntitiesFunction(int a, float b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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" +
|
||||
"<u>underlined text<u>\n" +
|
||||
"");
|
||||
|
||||
wantedComments.put("doxygen_translate.doxygen_translate.htmlEntitiesFunction(int, float)",
|
||||
|
|
@ -250,6 +254,8 @@ public class doxygen_translate_runme {
|
|||
"≥ \n" +
|
||||
"← \n" +
|
||||
"→ \n" +
|
||||
"Not an html entity - ignored by Doxygen. \n" +
|
||||
"Not an &text html entity - ampersand is replaced with entity.\n" +
|
||||
"");
|
||||
|
||||
// and ask the parser to check comments for us
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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 < and > 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, "<"));
|
||||
addDoxyCommand(m_tokenList, "<");
|
||||
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, ">");
|
||||
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, "&");
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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, "");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue