Doxygen
Loading...
Searching...
No Matches
textdocvisitor.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2026 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16// own header
17#include "textdocvisitor.h"
18
19// other headers
20#include "emoji.h"
21#include "htmlentity.h"
22#include "message.h"
23
24//-------------------------------------------------------------------------
25
27{
28 const char *res = HtmlEntityMapper::instance().html(s.symbol());
29 if (res)
30 {
31 m_t << res;
32 }
33 else
34 {
35 err("text: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),true));
36 }
37}
38
40{
41 // the TextDocVisitor is only invoked for the JS part of the HTML output
42 const char *res = EmojiEntityMapper::instance().unicode(s.index());
43 if (res)
44 {
45 const char *p = res;
46 while (*p)
47 {
48 switch(*p)
49 {
50 case '&': case '#':
51 break;
52 case 'x':
53 m_t << "\\u{";
54 break;
55 case ';':
56 m_t << "}";
57 break;
58 default:
59 m_t << *p;
60 break;
61 }
62 p++;
63 }
64 }
65 else
66 {
67 filter(s.name());
68 }
69}
70
72{
73 if (!cite.file().empty())
74 {
75 DString anchor = cite.anchor();
77 anchor = anchor.mid(anchorPrefix.length()); // strip prefix
78 m_t << anchor;
79 }
80 else
81 {
82 filter(cite.target());
83 }
84}
85
87{
88 if (str.empty()) return;
89 //printf("TextDocVisitor::filter(%s)\n",str);
90 const char *p=str.data();
91 while (*p)
92 {
93 char c = *p++;
94 if (c=='\n') c=' ';
95 else m_t << c;
96 }
97}
98
static CitationManager & instance()
Definition cite.cpp:90
DString anchorPrefix() const
Definition cite.cpp:131
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
DString mid(size_t index, size_t len=npos) const
Definition dstring.h:318
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:151
Node representing a citation of some bibliographic reference.
Definition docnode.h:245
DString anchor() const
Definition docnode.h:251
DString target() const
Definition docnode.h:252
DString file() const
Definition docnode.h:248
Node representing an emoji.
Definition docnode.h:341
int index() const
Definition docnode.h:345
DString name() const
Definition docnode.h:344
Node representing a special symbol.
Definition docnode.h:328
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:332
const char * unicode(int index) const
Access routine to the unicode sequence for the Emoji entity.
Definition emoji.cpp:2019
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1981
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
const char * html(SymType symb, bool useInPrintf=false) const
Access routine to the html code of the HTML entity.
void filter(const DString &str)
TextStream & m_t
void operator()(const DocWord &w)
#define err(fmt,...)
Definition message.h:127