Commit dfa20277 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Restructered html entity handling

parent 69665ef2
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "filedef.h" #include "filedef.h"
#include "msc.h" #include "msc.h"
#include "dia.h" #include "dia.h"
#include "htmlentity.h"
DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci) DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci)
: DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
...@@ -73,14 +74,14 @@ void DocbookDocVisitor::visit(DocWhiteSpace *w) ...@@ -73,14 +74,14 @@ void DocbookDocVisitor::visit(DocWhiteSpace *w)
void DocbookDocVisitor::visit(DocSymbol *s) void DocbookDocVisitor::visit(DocSymbol *s)
{ {
if (m_hide) return; if (m_hide) return;
const char *res = get_symbol_docbook(s->symbol()); const char *res = HtmlEntityMapper::instance()->docbook(s->symbol());
if (res) if (res)
{ {
m_t << res; m_t << res;
} }
else 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 @@ ...@@ -53,6 +53,7 @@
#include "config.h" #include "config.h"
#include "growbuf.h" #include "growbuf.h"
#include "markdown.h" #include "markdown.h"
#include "htmlentity.h"
// debug off // debug off
#define DBG(x) do {} while(0) #define DBG(x) do {} while(0)
...@@ -1573,7 +1574,7 @@ static void handleImg(DocNode *parent,QList<DocNode> &children,const HtmlAttribL ...@@ -1573,7 +1574,7 @@ static void handleImg(DocNode *parent,QList<DocNode> &children,const HtmlAttribL
DocSymbol::SymType DocSymbol::decodeSymbol(const QCString &symName) DocSymbol::SymType DocSymbol::decodeSymbol(const QCString &symName)
{ {
DBG(("decodeSymbol(%s)\n",qPrint(symName))); DBG(("decodeSymbol(%s)\n",qPrint(symName)));
return code_symbol(symName); return HtmlEntityMapper::instance()->name2sym(symName);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
...@@ -1224,7 +1224,7 @@ DotManager *DotManager::instance() ...@@ -1224,7 +1224,7 @@ DotManager *DotManager::instance()
return m_theInstance; return m_theInstance;
} }
DotManager::DotManager() : m_dotMaps(1007) DotManager::DotManager() : m_dotMaps(1009)
{ {
m_dotRuns.setAutoDelete(TRUE); m_dotRuns.setAutoDelete(TRUE);
m_dotMaps.setAutoDelete(TRUE); m_dotMaps.setAutoDelete(TRUE);
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "vhdldocgen.h" #include "vhdldocgen.h"
#include "filedef.h" #include "filedef.h"
#include "memberdef.h" #include "memberdef.h"
#include "htmlentity.h"
static const int NUM_HTML_LIST_TYPES = 4; static const int NUM_HTML_LIST_TYPES = 4;
static const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"}; static const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"};
...@@ -182,14 +183,14 @@ void HtmlDocVisitor::visit(DocWhiteSpace *w) ...@@ -182,14 +183,14 @@ void HtmlDocVisitor::visit(DocWhiteSpace *w)
void HtmlDocVisitor::visit(DocSymbol *s) void HtmlDocVisitor::visit(DocSymbol *s)
{ {
if (m_hide) return; if (m_hide) return;
const char *res = get_symbol_html(s->symbol()); const char *res = HtmlEntityMapper::instance()->html(s->symbol());
if (res) if (res)
{ {
m_t << res; m_t << res;
} }
else 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()));
} }
} }
......
This diff is collapsed.
/******************************************************************************
*
* 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 @@ ...@@ -31,6 +31,7 @@
#include "cite.h" #include "cite.h"
#include "filedef.h" #include "filedef.h"
#include "config.h" #include "config.h"
#include "htmlentity.h"
static QCString escapeLabelName(const char *s) static QCString escapeLabelName(const char *s)
{ {
...@@ -135,7 +136,7 @@ void LatexDocVisitor::visit(DocWhiteSpace *w) ...@@ -135,7 +136,7 @@ void LatexDocVisitor::visit(DocWhiteSpace *w)
void LatexDocVisitor::visit(DocSymbol *s) void LatexDocVisitor::visit(DocSymbol *s)
{ {
if (m_hide) return; if (m_hide) return;
const char *res = get_symbol_latex(s->symbol()); const char *res = HtmlEntityMapper::instance()->latex(s->symbol());
if (res) if (res)
{ {
if (((s->symbol() == DocSymbol::Sym_lt) || (s->symbol() == DocSymbol::Sym_Less))&& (!m_insidePre)) if (((s->symbol() == DocSymbol::Sym_lt) || (s->symbol() == DocSymbol::Sym_Less))&& (!m_insidePre))
...@@ -153,7 +154,7 @@ void LatexDocVisitor::visit(DocSymbol *s) ...@@ -153,7 +154,7 @@ void LatexDocVisitor::visit(DocSymbol *s)
} }
else 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 \ ...@@ -59,6 +59,7 @@ HEADERS = arguments.h \
htmldocvisitor.h \ htmldocvisitor.h \
htmlgen.h \ htmlgen.h \
htmlhelp.h \ htmlhelp.h \
htmlentity.h \
image.h \ image.h \
index.h \ index.h \
language.h \ language.h \
...@@ -152,6 +153,7 @@ SOURCES = arguments.cpp \ ...@@ -152,6 +153,7 @@ SOURCES = arguments.cpp \
htmldocvisitor.cpp \ htmldocvisitor.cpp \
htmlgen.cpp \ htmlgen.cpp \
htmlhelp.cpp \ htmlhelp.cpp \
htmlentity.cpp \
image.cpp \ image.cpp \
index.cpp \ index.cpp \
language.cpp \ language.cpp \
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "message.h" #include "message.h"
#include "parserintf.h" #include "parserintf.h"
#include "filedef.h" #include "filedef.h"
#include "htmlentity.h"
ManDocVisitor::ManDocVisitor(FTextStream &t,CodeOutputInterface &ci, ManDocVisitor::ManDocVisitor(FTextStream &t,CodeOutputInterface &ci,
const char *langExt) const char *langExt)
...@@ -75,7 +76,7 @@ void ManDocVisitor::visit(DocWhiteSpace *w) ...@@ -75,7 +76,7 @@ void ManDocVisitor::visit(DocWhiteSpace *w)
void ManDocVisitor::visit(DocSymbol *s) void ManDocVisitor::visit(DocSymbol *s)
{ {
if (m_hide) return; if (m_hide) return;
const char *res = get_symbol_man(s->symbol()); const char *res = HtmlEntityMapper::instance()->man(s->symbol());
if (res) if (res)
{ {
m_t << res; m_t << res;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "membergroup.h" #include "membergroup.h"
#include "section.h" #include "section.h"
#include "util.h" #include "util.h"
#include "htmlentity.h"
#define PERLOUTPUT_MAX_INDENTATION 40 #define PERLOUTPUT_MAX_INDENTATION 40
...@@ -541,8 +542,8 @@ void PerlModDocVisitor::visit(DocWhiteSpace *) ...@@ -541,8 +542,8 @@ void PerlModDocVisitor::visit(DocWhiteSpace *)
void PerlModDocVisitor::visit(DocSymbol *sy) void PerlModDocVisitor::visit(DocSymbol *sy)
{ {
const DocSymbol::PerlSymb *res = get_symbol_perl(sy->symbol()); const DocSymbol::PerlSymb *res = HtmlEntityMapper::instance()->perl(sy->symbol());
const char *accent; const char *accent=0;
if (res-> symb) if (res-> symb)
{ {
switch (res->type) switch (res->type)
...@@ -588,19 +589,24 @@ void PerlModDocVisitor::visit(DocSymbol *sy) ...@@ -588,19 +589,24 @@ void PerlModDocVisitor::visit(DocSymbol *sy)
case DocSymbol::Perl_ring: case DocSymbol::Perl_ring:
accent = "ring"; accent = "ring";
break; break;
default:
break;
} }
leaveText(); leaveText();
if (accent)
{
openItem("accent"); openItem("accent");
m_output m_output
.addFieldQuotedString("accent", accent) .addFieldQuotedString("accent", accent)
.addFieldQuotedChar("letter", res->symb[0]); .addFieldQuotedChar("letter", res->symb[0]);
closeItem(); closeItem();
}
break; break;
} }
} }
else 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 @@ ...@@ -21,6 +21,7 @@
#include <qglobal.h> #include <qglobal.h>
#include "docvisitor.h" #include "docvisitor.h"
#include "htmlentity.h"
/*! Concrete visitor implementation for pretty printing */ /*! Concrete visitor implementation for pretty printing */
class PrintDocVisitor : public DocVisitor class PrintDocVisitor : public DocVisitor
...@@ -56,14 +57,21 @@ class PrintDocVisitor : public DocVisitor ...@@ -56,14 +57,21 @@ class PrintDocVisitor : public DocVisitor
void visit(DocSymbol *s) void visit(DocSymbol *s)
{ {
indent_leaf(); indent_leaf();
const char *res = get_symbol_print(s->symbol()); const char *res = HtmlEntityMapper::instance()->utf8(s->symbol());
if (res) if (res)
{
if (qstrcmp(res,"%")==0)
{
printf("%%");
}
else
{ {
printf("%s",res); printf("%s",res);
} }
}
else 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) void visit(DocURL *u)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "dia.h" #include "dia.h"
#include "filedef.h" #include "filedef.h"
#include "config.h" #include "config.h"
#include "htmlentity.h"
//#define DBG_RTF(x) m_t << x //#define DBG_RTF(x) m_t << x
#define DBG_RTF(x) do {} while(0) #define DBG_RTF(x) do {} while(0)
...@@ -121,14 +122,14 @@ void RTFDocVisitor::visit(DocSymbol *s) ...@@ -121,14 +122,14 @@ void RTFDocVisitor::visit(DocSymbol *s)
{ {
if (m_hide) return; if (m_hide) return;
DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n"); 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) if (res)
{ {
m_t << res; m_t << res;
} }
else 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; m_lastIsPara=FALSE;
} }
......
...@@ -20,19 +20,20 @@ ...@@ -20,19 +20,20 @@
#include "textdocvisitor.h" #include "textdocvisitor.h"
#include "message.h" #include "message.h"
#include "util.h" #include "util.h"
#include "htmlentity.h"
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
void TextDocVisitor::visit(DocSymbol *s) void TextDocVisitor::visit(DocSymbol *s)
{ {
const char *res = get_symbol_text(s->symbol()); const char *res = HtmlEntityMapper::instance()->html(s->symbol());
if (res) if (res)
{ {
m_t << res; m_t << res;
} }
else 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()));
} }
} }
......
This diff is collapsed.
...@@ -455,19 +455,5 @@ void convertProtectionLevel( ...@@ -455,19 +455,5 @@ void convertProtectionLevel(
int *outListType2 int *outListType2
); );
DocSymbol::SymType code_symbol(const QCString &symName);
const char *get_symbol_item(DocSymbol::SymType symb);
const char *get_symbol_UTF8(DocSymbol::SymType symb);
const char *get_symbol_html(DocSymbol::SymType symb);
const char *get_symbol_print(DocSymbol::SymType symb);
const char *get_symbol_text(DocSymbol::SymType symb);
const char *get_symbol_xml(DocSymbol::SymType symb);
const char *get_symbol_docbook(DocSymbol::SymType symb);
const char *get_symbol_latex(DocSymbol::SymType symb);
const char *get_symbol_man(DocSymbol::SymType symb);
const char *get_symbol_rtf(DocSymbol::SymType symb);
const DocSymbol::PerlSymb *get_symbol_perl(DocSymbol::SymType symb);
int get_num_standard_symbols(void);
void validate_html_entities(void);
#endif #endif
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "parserintf.h" #include "parserintf.h"
#include "filename.h" #include "filename.h"
#include "config.h" #include "config.h"
#include "htmlentity.h"
XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci) XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci)
: DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
...@@ -70,14 +71,14 @@ void XmlDocVisitor::visit(DocWhiteSpace *w) ...@@ -70,14 +71,14 @@ void XmlDocVisitor::visit(DocWhiteSpace *w)
void XmlDocVisitor::visit(DocSymbol *s) void XmlDocVisitor::visit(DocSymbol *s)
{ {
if (m_hide) return; if (m_hide) return;
const char *res = get_symbol_xml(s->symbol()); const char *res = HtmlEntityMapper::instance()->xml(s->symbol());
if (res) if (res)
{ {
m_t << res; m_t << res;
} }
else else
{ {
err("XML: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol())); err("XML: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol()));
} }
} }
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "membergroup.h" #include "membergroup.h"
#include "dirdef.h" #include "dirdef.h"
#include "section.h" #include "section.h"
#include "htmlentity.h"
// no debug info // no debug info
#define XML_DB(x) do {} while(0) #define XML_DB(x) do {} while(0)
...@@ -1897,47 +1898,31 @@ void generateXML() ...@@ -1897,47 +1898,31 @@ void generateXML()
err("Cannot open file %s for writing!\n",fileName.data()); err("Cannot open file %s for writing!\n",fileName.data());
return; return;
} }
/*
* If the compound_xsd contyains the special string // write compound.xsd, but replace special marker with the entities
* write part till special string const char *startLine = compound_xsd;
* for each html entity while (*startLine)
* write xsd entry with xml element name without enclosing < and /> {
* write part after special string // find end of the line
* otherwise const char *endLine = startLine+1;
* write original compound_xsd while (*(endLine-1) && *(endLine-1)!='\n') endLine++; // skip to end of the line
*/ int len=endLine-startLine;
QCString cmp_org(compound_xsd); if (len>0)
QCString ins("<!-- Automatically insert here the HTML entities -->"); {
if (cmp_org.contains(QRegExp(ins))) QCString s(len+1);
{ strlcpy(s.data(),startLine,len);
QCString xsd_txt; s[len]='\0';
QCString xsd_tmp; if (s.find("<!-- Automatically insert here the HTML entities -->")!=-1)
QCString cmp_tmp1; {
QCString cmp_tmp2; FTextStream t(&f);
QRegExp beg("^<"); HtmlEntityMapper::instance()->writeXMLSchema(t);
QRegExp end("/>$");
cmp_tmp1 = cmp_org;
cmp_tmp1 = cmp_tmp1.replace(QRegExp(" *"+ins+".*"),"");
f.writeBlock(cmp_tmp1,qstrlen(cmp_tmp1));
int num_std = get_num_standard_symbols();
for (int i = 0; i < num_std; i++)
{
xsd_tmp = QCString(get_symbol_xml((DocSymbol::SymType)i));
if (xsd_tmp.contains(beg))
{
xsd_txt = " <xsd:element name=\"";
xsd_txt += xsd_tmp.replace(beg,"").replace(end,"");
xsd_txt += "\" type=\"docEmptyType\" />\n";
f.writeBlock(xsd_txt,qstrlen(xsd_txt));
}
}
cmp_tmp2 = cmp_org;
cmp_tmp2 = cmp_tmp2.replace(QRegExp(".*"+ins),"");
f.writeBlock(cmp_tmp2,qstrlen(cmp_tmp2));
} }
else else
{ {
f.writeBlock(compound_xsd,qstrlen(compound_xsd)); f.writeBlock(startLine,len);
}
}
startLine=endLine;
} }
f.close(); f.close();
......
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