Skip to content

Commit

Permalink
Restructered html entity handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Feb 10, 2014
1 parent 69665ef commit dfa2027
Show file tree
Hide file tree
Showing 17 changed files with 603 additions and 536 deletions.
5 changes: 3 additions & 2 deletions src/docbookvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/docparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "config.h"
#include "growbuf.h"
#include "markdown.h"
#include "htmlentity.h"

// debug off
#define DBG(x) do {} while(0)
Expand Down Expand Up @@ -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);
}

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/dot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand Down Expand Up @@ -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()));
}
}

Expand Down
477 changes: 477 additions & 0 deletions src/htmlentity.cpp

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions src/htmlentity.h
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions src/latexdocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "cite.h"
#include "filedef.h"
#include "config.h"
#include "htmlentity.h"

static QCString escapeLabelName(const char *s)
{
Expand Down Expand Up @@ -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))
Expand All @@ -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()));
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/libdoxygen.pro.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ HEADERS = arguments.h \
htmldocvisitor.h \
htmlgen.h \
htmlhelp.h \
htmlentity.h \
image.h \
index.h \
language.h \
Expand Down Expand Up @@ -152,6 +153,7 @@ SOURCES = arguments.cpp \
htmldocvisitor.cpp \
htmlgen.cpp \
htmlhelp.cpp \
htmlentity.cpp \
image.cpp \
index.cpp \
language.cpp \
Expand Down
3 changes: 2 additions & 1 deletion src/mandocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 14 additions & 8 deletions src/perlmodgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "membergroup.h"
#include "section.h"
#include "util.h"
#include "htmlentity.h"

#define PERLOUTPUT_MAX_INDENTATION 40

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()));
}
}

Expand Down
14 changes: 11 additions & 3 deletions src/printdocvisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <qglobal.h>
#include "docvisitor.h"
#include "htmlentity.h"

/*! Concrete visitor implementation for pretty printing */
class PrintDocVisitor : public DocVisitor
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/rtfdocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/textdocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}

Expand Down

0 comments on commit dfa2027

Please sign in to comment.