Commit 0e080f48 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Improved handling of percent symbol

parent a28ff233
...@@ -81,7 +81,7 @@ void DocbookDocVisitor::visit(DocSymbol *s) ...@@ -81,7 +81,7 @@ void DocbookDocVisitor::visit(DocSymbol *s)
} }
else else
{ {
err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
} }
......
...@@ -190,7 +190,7 @@ void HtmlDocVisitor::visit(DocSymbol *s) ...@@ -190,7 +190,7 @@ void HtmlDocVisitor::visit(DocSymbol *s)
} }
else else
{ {
err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
} }
......
...@@ -354,23 +354,41 @@ void HtmlEntityMapper::deleteInstance() ...@@ -354,23 +354,41 @@ void HtmlEntityMapper::deleteInstance()
/*! @brief Access routine to the UTF8 code of the HTML entity /*! @brief Access routine to the UTF8 code of the HTML entity
* *
* @param symb Code of the requested HTML entity * @param symb Code of the requested HTML entity
* @param useInPrintf If TRUE the result will be escaped such that it can be
* used in a printf string pattern
* @return the UTF8 code of the HTML entity, * @return the UTF8 code of the HTML entity,
* in case the UTF code is unknown \c NULL is returned. * in case the UTF code is unknown \c NULL is returned.
*/ */
const char *HtmlEntityMapper::utf8(DocSymbol::SymType symb) const const char *HtmlEntityMapper::utf8(DocSymbol::SymType symb,bool useInPrintf) const
{ {
return g_htmlEntities[symb].UTF8; if (useInPrintf && symb==DocSymbol::Sym_Percent)
{
return "%%"; // escape for printf
}
else
{
return g_htmlEntities[symb].UTF8;
}
} }
/*! @brief Access routine to the html code of the HTML entity /*! @brief Access routine to the html code of the HTML entity
* *
* @param symb Code of the requested HTML entity * @param symb Code of the requested HTML entity
* @return the html of the HTML entity, * @param useInPrintf If TRUE the result will be escaped such that it can be
* used in a printf string pattern
* @return the html representation of the HTML entity,
* in case the html code is unknown \c NULL is returned. * in case the html code is unknown \c NULL is returned.
*/ */
const char *HtmlEntityMapper::html(DocSymbol::SymType symb) const const char *HtmlEntityMapper::html(DocSymbol::SymType symb,bool useInPrintf) const
{ {
return g_htmlEntities[symb].html; if (useInPrintf && symb==DocSymbol::Sym_Percent)
{
return "%%"; // escape for printf
}
else
{
return g_htmlEntities[symb].html;
}
} }
/*! @brief Access routine to the XML code of the HTML entity /*! @brief Access routine to the XML code of the HTML entity
......
...@@ -27,8 +27,8 @@ class HtmlEntityMapper ...@@ -27,8 +27,8 @@ class HtmlEntityMapper
static HtmlEntityMapper *instance(); static HtmlEntityMapper *instance();
static void deleteInstance(); static void deleteInstance();
DocSymbol::SymType name2sym(const QCString &symName) const; DocSymbol::SymType name2sym(const QCString &symName) const;
const char *utf8(DocSymbol::SymType symb) const; const char *utf8(DocSymbol::SymType symb,bool useInPrintf=FALSE) const;
const char *html(DocSymbol::SymType symb) const; const char *html(DocSymbol::SymType symb,bool useInPrintf=FALSE) const;
const char *xml(DocSymbol::SymType symb) const; const char *xml(DocSymbol::SymType symb) const;
const char *docbook(DocSymbol::SymType symb) const; const char *docbook(DocSymbol::SymType symb) const;
const char *latex(DocSymbol::SymType symb) const; const char *latex(DocSymbol::SymType symb) const;
......
...@@ -154,7 +154,7 @@ void LatexDocVisitor::visit(DocSymbol *s) ...@@ -154,7 +154,7 @@ void LatexDocVisitor::visit(DocSymbol *s)
} }
else else
{ {
err("LaTeX: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); err("LaTeX: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
} }
......
...@@ -606,7 +606,7 @@ void PerlModDocVisitor::visit(DocSymbol *sy) ...@@ -606,7 +606,7 @@ void PerlModDocVisitor::visit(DocSymbol *sy)
} }
else else
{ {
err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol())); err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol(),TRUE));
} }
} }
......
...@@ -57,21 +57,14 @@ class PrintDocVisitor : public DocVisitor ...@@ -57,21 +57,14 @@ class PrintDocVisitor : public DocVisitor
void visit(DocSymbol *s) void visit(DocSymbol *s)
{ {
indent_leaf(); indent_leaf();
const char *res = HtmlEntityMapper::instance()->utf8(s->symbol()); const char *res = HtmlEntityMapper::instance()->utf8(s->symbol(),TRUE);
if (res) if (res)
{ {
if (qstrcmp(res,"%")==0) printf("%s",res);
{
printf("%%");
}
else
{
printf("%s",res);
}
} }
else else
{ {
printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
} }
void visit(DocURL *u) void visit(DocURL *u)
......
...@@ -129,7 +129,7 @@ void RTFDocVisitor::visit(DocSymbol *s) ...@@ -129,7 +129,7 @@ void RTFDocVisitor::visit(DocSymbol *s)
} }
else else
{ {
err("RTF: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); err("RTF: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
m_lastIsPara=FALSE; m_lastIsPara=FALSE;
} }
......
...@@ -33,7 +33,7 @@ void TextDocVisitor::visit(DocSymbol *s) ...@@ -33,7 +33,7 @@ void TextDocVisitor::visit(DocSymbol *s)
} }
else else
{ {
err("text: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); err("text: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
} }
......
...@@ -78,7 +78,7 @@ void XmlDocVisitor::visit(DocSymbol *s) ...@@ -78,7 +78,7 @@ void XmlDocVisitor::visit(DocSymbol *s)
} }
else else
{ {
err("XML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol())); err("XML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment