Permalink
Browse files

Restructered html entity handling

  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Feb 10, 2014
1 parent 69665ef commit dfa20277697fe904a0846b60a01cc388fc13c933
@@ -33,6 +33,7 @@
#include "filedef.h"
#include "msc.h"
#include "dia.h"
#include "htmlentity.h"
DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci)
: DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
@@ -73,14 +74,14 @@ void DocbookDocVisitor::visit(DocWhiteSpace *w)
void DocbookDocVisitor::visit(DocSymbol *s)
{
if (m_hide) return;
const char *res = get_symbol_docbook(s->symbol());
const char *res = HtmlEntityMapper::instance()->docbook(s->symbol());
if (res)
{
m_t << res;
}
else
{
err("DocBook: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
}
}
@@ -53,6 +53,7 @@
#include "config.h"
#include "growbuf.h"
#include "markdown.h"
#include "htmlentity.h"
// debug off
#define DBG(x) do {} while(0)
@@ -1573,7 +1574,7 @@ static void handleImg(DocNode *parent,QList<DocNode> &children,const HtmlAttribL
DocSymbol::SymType DocSymbol::decodeSymbol(const QCString &symName)
{
DBG(("decodeSymbol(%s)\n",qPrint(symName)));
return code_symbol(symName);
return HtmlEntityMapper::instance()->name2sym(symName);
}
//---------------------------------------------------------------------------
@@ -1224,7 +1224,7 @@ DotManager *DotManager::instance()
return m_theInstance;
}
DotManager::DotManager() : m_dotMaps(1007)
DotManager::DotManager() : m_dotMaps(1009)
{
m_dotRuns.setAutoDelete(TRUE);
m_dotMaps.setAutoDelete(TRUE);
@@ -33,6 +33,7 @@
#include "vhdldocgen.h"
#include "filedef.h"
#include "memberdef.h"
#include "htmlentity.h"
static const int NUM_HTML_LIST_TYPES = 4;
static const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"};
@@ -182,14 +183,14 @@ void HtmlDocVisitor::visit(DocWhiteSpace *w)
void HtmlDocVisitor::visit(DocSymbol *s)
{
if (m_hide) return;
const char *res = get_symbol_html(s->symbol());
const char *res = HtmlEntityMapper::instance()->html(s->symbol());
if (res)
{
m_t << res;
}
else
{
err("HTML: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
err("HTML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
}
}

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,47 @@
/******************************************************************************
*
* Copyright (C) 1997-2013 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#ifndef HTMLENTITY_H
#define HTMLENTITY_H
#include <qdict.h>
#include "docparser.h"
class FTextStream;
/** @brief Singleton helper class to map html entities to other formats */
class HtmlEntityMapper
{
public:
static HtmlEntityMapper *instance();
static void deleteInstance();
DocSymbol::SymType name2sym(const QCString &symName) const;
const char *utf8(DocSymbol::SymType symb) const;
const char *html(DocSymbol::SymType symb) const;
const char *xml(DocSymbol::SymType symb) const;
const char *docbook(DocSymbol::SymType symb) const;
const char *latex(DocSymbol::SymType symb) const;
const char *man(DocSymbol::SymType symb) const;
const char *rtf(DocSymbol::SymType symb) const;
const DocSymbol::PerlSymb *perl(DocSymbol::SymType symb) const;
void writeXMLSchema(FTextStream &t);
void validate();
private:
HtmlEntityMapper();
~HtmlEntityMapper();
static HtmlEntityMapper *s_instance;
QDict<int> *m_name2sym;
};
#endif
@@ -31,6 +31,7 @@
#include "cite.h"
#include "filedef.h"
#include "config.h"
#include "htmlentity.h"
static QCString escapeLabelName(const char *s)
{
@@ -135,7 +136,7 @@ void LatexDocVisitor::visit(DocWhiteSpace *w)
void LatexDocVisitor::visit(DocSymbol *s)
{
if (m_hide) return;
const char *res = get_symbol_latex(s->symbol());
const char *res = HtmlEntityMapper::instance()->latex(s->symbol());
if (res)
{
if (((s->symbol() == DocSymbol::Sym_lt) || (s->symbol() == DocSymbol::Sym_Less))&& (!m_insidePre))
@@ -153,7 +154,7 @@ void LatexDocVisitor::visit(DocSymbol *s)
}
else
{
err("LaTeX: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
err("LaTeX: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
}
}
@@ -59,6 +59,7 @@ HEADERS = arguments.h \
htmldocvisitor.h \
htmlgen.h \
htmlhelp.h \
htmlentity.h \
image.h \
index.h \
language.h \
@@ -152,6 +153,7 @@ SOURCES = arguments.cpp \
htmldocvisitor.cpp \
htmlgen.cpp \
htmlhelp.cpp \
htmlentity.cpp \
image.cpp \
index.cpp \
language.cpp \
@@ -29,6 +29,7 @@
#include "message.h"
#include "parserintf.h"
#include "filedef.h"
#include "htmlentity.h"
ManDocVisitor::ManDocVisitor(FTextStream &t,CodeOutputInterface &ci,
const char *langExt)
@@ -75,7 +76,7 @@ void ManDocVisitor::visit(DocWhiteSpace *w)
void ManDocVisitor::visit(DocSymbol *s)
{
if (m_hide) return;
const char *res = get_symbol_man(s->symbol());
const char *res = HtmlEntityMapper::instance()->man(s->symbol());
if (res)
{
m_t << res;
@@ -42,6 +42,7 @@
#include "membergroup.h"
#include "section.h"
#include "util.h"
#include "htmlentity.h"
#define PERLOUTPUT_MAX_INDENTATION 40
@@ -541,8 +542,8 @@ void PerlModDocVisitor::visit(DocWhiteSpace *)
void PerlModDocVisitor::visit(DocSymbol *sy)
{
const DocSymbol::PerlSymb *res = get_symbol_perl(sy->symbol());
const char *accent;
const DocSymbol::PerlSymb *res = HtmlEntityMapper::instance()->perl(sy->symbol());
const char *accent=0;
if (res-> symb)
{
switch (res->type)
@@ -588,19 +589,24 @@ void PerlModDocVisitor::visit(DocSymbol *sy)
case DocSymbol::Perl_ring:
accent = "ring";
break;
default:
break;
}
leaveText();
openItem("accent");
m_output
.addFieldQuotedString("accent", accent)
.addFieldQuotedChar("letter", res->symb[0]);
closeItem();
if (accent)
{
openItem("accent");
m_output
.addFieldQuotedString("accent", accent)
.addFieldQuotedChar("letter", res->symb[0]);
closeItem();
}
break;
}
}
else
{
err("perl: non supported HTML-entity found: &%s;\n",get_symbol_item(sy->symbol()));
err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol()));
}
}
@@ -21,6 +21,7 @@
#include <qglobal.h>
#include "docvisitor.h"
#include "htmlentity.h"
/*! Concrete visitor implementation for pretty printing */
class PrintDocVisitor : public DocVisitor
@@ -56,14 +57,21 @@ class PrintDocVisitor : public DocVisitor
void visit(DocSymbol *s)
{
indent_leaf();
const char *res = get_symbol_print(s->symbol());
const char *res = HtmlEntityMapper::instance()->utf8(s->symbol());
if (res)
{
printf("%s",res);
if (qstrcmp(res,"%")==0)
{
printf("%%");
}
else
{
printf("%s",res);
}
}
else
{
printf("print: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
}
}
void visit(DocURL *u)
@@ -32,6 +32,7 @@
#include "dia.h"
#include "filedef.h"
#include "config.h"
#include "htmlentity.h"
//#define DBG_RTF(x) m_t << x
#define DBG_RTF(x) do {} while(0)
@@ -121,14 +122,14 @@ void RTFDocVisitor::visit(DocSymbol *s)
{
if (m_hide) return;
DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
const char *res = get_symbol_rtf(s->symbol());
const char *res = HtmlEntityMapper::instance()->rtf(s->symbol());
if (res)
{
m_t << res;
}
else
{
err("RTF: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
err("RTF: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
}
m_lastIsPara=FALSE;
}
@@ -20,19 +20,20 @@
#include "textdocvisitor.h"
#include "message.h"
#include "util.h"
#include "htmlentity.h"
//-------------------------------------------------------------------------
void TextDocVisitor::visit(DocSymbol *s)
{
const char *res = get_symbol_text(s->symbol());
const char *res = HtmlEntityMapper::instance()->html(s->symbol());
if (res)
{
m_t << res;
}
else
{
err("text: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
err("text: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
}
}
Oops, something went wrong.

0 comments on commit dfa2027

Please sign in to comment.