Skip to content

Commit 0a78201

Browse files
committed
Incorr5ect representation of accented characters with \cite{shortauthor}
In case we have in the bibliography author something like: ``` author = "Herv{\'e} Br{\"o}nnimann" ``` and we give `\cite{shortauthor}` this is shown as: ``` Brönnimann ``` instead of ``` Brönnimann ```
1 parent 4f3ec1d commit 0a78201

16 files changed

Lines changed: 154 additions & 24 deletions

src/docbookgen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ void DocbookGenerator::endTocEntry(const SectionInfo *si)
14811481
static constexpr auto hex="0123456789ABCDEF";
14821482

14831483
/*! Converts a string to an DocBook-encoded string */
1484-
QCString convertToDocBook(const QCString &s, const bool retainNewline)
1484+
QCString convertToDocBook(const QCString &s, const bool retainNewline, const bool /* citeEntry */)
14851485
{
14861486
if (s.isEmpty()) return s;
14871487
QCString result;

src/docbookgen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class DocbookGenerator final : public OutputGenerator, public OutputGenIntf
352352
TocState m_tocState;
353353
};
354354

355-
QCString convertToDocBook(const QCString &s, const bool retainNewline = false);
355+
QCString convertToDocBook(const QCString &s, const bool retainNewline = false, const bool citeEntry = false);
356356

357357

358358
#endif

src/docbookvisitor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ DB_VIS_C
579579
{
580580
if (!opt.noCite()) startLink(cite.file(),filterId(cite.anchor()));
581581

582-
filter(cite.getText());
582+
filter(cite.getText(), false, true);
583583

584584
if (!opt.noCite()) endLink();
585585
}
@@ -1533,10 +1533,10 @@ DB_VIS_C
15331533
}
15341534

15351535

1536-
void DocbookDocVisitor::filter(const QCString &str, const bool retainNewLine)
1536+
void DocbookDocVisitor::filter(const QCString &str, const bool retainNewLine, const bool citeEntry)
15371537
{
15381538
DB_VIS_C
1539-
m_t << convertToDocBook(str, retainNewLine);
1539+
m_t << convertToDocBook(str, retainNewLine, citeEntry);
15401540
}
15411541

15421542
void DocbookDocVisitor::startLink(const QCString &file,const QCString &anchor)

src/docbookvisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class DocbookDocVisitor final : public DocVisitor
111111
//--------------------------------------
112112
// helper functions
113113
//--------------------------------------
114-
void filter(const QCString &str, const bool retainNewLine = false);
114+
void filter(const QCString &str, const bool retainNewLine = false, const bool citeEntry = false);
115115
void startLink(const QCString &file,
116116
const QCString &anchor);
117117
void endLink();

src/htmldocvisitor.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ void HtmlDocVisitor::operator()(const DocCite &cite)
967967
if (!cite.file().isEmpty())
968968
{
969969
if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.relPath(),cite.anchor());
970-
filter(cite.getText());
970+
filter(cite.getText(), false, true);
971971
if (!opt.noCite()) endLink();
972972
}
973973
else
@@ -2153,10 +2153,12 @@ void HtmlDocVisitor::operator()(const DocParBlock &pb)
21532153
visitChildren(pb);
21542154
}
21552155

2156-
void HtmlDocVisitor::filter(const QCString &str, const bool retainNewline)
2156+
void HtmlDocVisitor::filter(const QCString &str, const bool retainNewline, const bool citeEntry)
21572157
{
21582158
if (str.isEmpty()) return;
21592159
const char *p=str.data();
2160+
const char *q = nullptr;
2161+
int cnt = 0;
21602162
while (*p)
21612163
{
21622164
char c=*p++;
@@ -2165,7 +2167,37 @@ void HtmlDocVisitor::filter(const QCString &str, const bool retainNewline)
21652167
case '\n': if(retainNewline) m_t << "<br/>"; m_t << c; break;
21662168
case '<': m_t << "&lt;"; break;
21672169
case '>': m_t << "&gt;"; break;
2168-
case '&': m_t << "&amp;"; break;
2170+
case '&': // possibility to have a special symbol
2171+
if (!citeEntry) {m_t << "&amp;"; break;}
2172+
q = p;
2173+
cnt = 2; // we have to count & and ; as well
2174+
while ((*q >= 'a' && *q <= 'z') || (*q >= 'A' && *q <= 'Z') || (*q >= '0' && *q <= '9'))
2175+
{
2176+
cnt++;
2177+
q++;
2178+
}
2179+
if (*q == ';')
2180+
{
2181+
--p; // we need & as well
2182+
HtmlEntityMapper::SymType res = HtmlEntityMapper::instance().name2sym(QCString(p).left(cnt));
2183+
if (res == HtmlEntityMapper::Sym_Unknown)
2184+
{
2185+
p++;
2186+
m_t << "&amp;";
2187+
}
2188+
else
2189+
{
2190+
m_t << HtmlEntityMapper::instance().html(res);
2191+
q++;
2192+
p = q;
2193+
}
2194+
}
2195+
else
2196+
{
2197+
m_t << "&amp;";
2198+
}
2199+
break;
2200+
21692201
case '\\':
21702202
if ((*p == '(') || (*p == ')') || (*p == '[') || (*p == ']'))
21712203
m_t << "\\&zwj;" << *p++;

src/htmldocvisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class HtmlDocVisitor final : public DocVisitor
118118
//--------------------------------------
119119

120120
void writeObfuscatedMailAddress(const QCString &url);
121-
void filter(const QCString &str, const bool retainNewline = false);
121+
void filter(const QCString &str, const bool retainNewline = false, const bool citeEntry = false);
122122
QCString filterQuotedCdataAttr(const QCString &str);
123123
void startLink(const QCString &ref,const QCString &file,
124124
const QCString &relPath,const QCString &anchor,

src/latexdocvisitor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ void LatexDocVisitor::operator()(const DocParBlock &pb)
18481848
visitChildren(pb);
18491849
}
18501850

1851-
void LatexDocVisitor::filter(const QCString &str, const bool retainNewLine)
1851+
void LatexDocVisitor::filter(const QCString &str, const bool retainNewLine, const bool /* citeEntry */)
18521852
{
18531853
//printf("LatexDocVisitor::filter(%s) m_insideTabbing=%d m_insideTable=%d\n",qPrint(str),m_lcg.insideTabbing(),m_lcg.usedTableLevel()>0);
18541854
filterLatexString(m_t,str,

src/latexdocvisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class LatexDocVisitor final : public DocVisitor
135135
// helper functions
136136
//--------------------------------------
137137

138-
void filter(const QCString &str, const bool retainNewLine = false);
138+
void filter(const QCString &str, const bool retainNewLine = false, const bool citeEntry = false);
139139
void startLink(const QCString &ref,const QCString &file,
140140
const QCString &anchor,bool refToTable=false,bool refToSection=false);
141141
void endLink(const QCString &ref,const QCString &file,

src/mandocvisitor.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,15 @@ void ManDocVisitor::operator()(const DocCite &cite)
424424
if (!cite.file().isEmpty())
425425
{
426426
txt = cite.getText();
427+
filter(txt, false, true);
427428
}
428429
else
429430
{
430431
if (!opt.noPar()) txt += "[";
431432
txt += cite.target();
432433
if (!opt.noPar()) txt += "]";
434+
filter(txt);
433435
}
434-
filter(txt);
435436
m_t << "\\fP";
436437
}
437438

@@ -991,13 +992,15 @@ void ManDocVisitor::operator()(const DocParBlock &pb)
991992
visitChildren(pb);
992993
}
993994

994-
void ManDocVisitor::filter(const QCString &str, const bool retainNewline)
995+
void ManDocVisitor::filter(const QCString &str, const bool retainNewline, const bool citeEntry)
995996
{
996997
if (!str.isEmpty())
997998
{
998999
const char *p=str.data();
9991000
char c=0;
10001001
bool insideDoubleQuote = false;
1002+
const char *q = nullptr;
1003+
int cnt = 0;
10011004
while ((c=*p++))
10021005
{
10031006
switch(c)
@@ -1006,6 +1009,37 @@ void ManDocVisitor::filter(const QCString &str, const bool retainNewline)
10061009
case '\\': m_t << "\\\\"; break;
10071010
case '\"': m_t << "\""; insideDoubleQuote = !insideDoubleQuote; break;
10081011
case '\n': if (retainNewline || !insideDoubleQuote) m_t << c; break;
1012+
case '&': // possibility to have a special symbol
1013+
if (!citeEntry) { m_t << c; break;}
1014+
q = p;
1015+
cnt = 2; // we have to count & and ; as well
1016+
while ((*q >= 'a' && *q <= 'z') || (*q >= 'A' && *q <= 'Z') || (*q >= '0' && *q <= '9'))
1017+
{
1018+
cnt++;
1019+
q++;
1020+
}
1021+
if (*q == ';')
1022+
{
1023+
--p; // we need & as well
1024+
HtmlEntityMapper::SymType res = HtmlEntityMapper::instance().name2sym(QCString(p).left(cnt));
1025+
if (res == HtmlEntityMapper::Sym_Unknown)
1026+
{
1027+
p++;
1028+
m_t << "&";
1029+
}
1030+
else
1031+
{
1032+
m_t << HtmlEntityMapper::instance().man(res);
1033+
q++;
1034+
p = q;
1035+
}
1036+
}
1037+
else
1038+
{
1039+
m_t << "&";
1040+
}
1041+
break;
1042+
10091043
default: m_t << c; break;
10101044
}
10111045
}

src/mandocvisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class ManDocVisitor final : public DocVisitor
118118
// helper functions
119119
//--------------------------------------
120120

121-
void filter(const QCString &str, const bool retainNewline = false);
121+
void filter(const QCString &str, const bool retainNewline = false, const bool citeEntry = false);
122122

123123
//--------------------------------------
124124
// state variables

0 commit comments

Comments
 (0)