summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2019-12-22 20:46:44 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2019-12-22 20:46:44 (GMT)
commit2beef53594232109e75f7daab2b2c059f2531bd6 (patch)
tree9246800163035b525cc0ded606c0ce57a1dfdf23
parent5d6f6b9971ab484fe811feba940200a31876a213 (diff)
parent5c5d546a393e68203ab853a99575d643672655cc (diff)
downloadDoxygen-2beef53594232109e75f7daab2b2c059f2531bd6.zip
Doxygen-2beef53594232109e75f7daab2b2c059f2531bd6.tar.gz
Doxygen-2beef53594232109e75f7daab2b2c059f2531bd6.tar.bz2
Merge branch 'albert-github-feature/bug_nbsp_code'
-rw-r--r--src/markdown.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 12fce3b..0a71aae 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -108,7 +108,8 @@ static Entry *g_current;
static QCString g_fileName;
static int g_lineNr;
static int g_indentLevel=0; // 0 is outside markdown, -1=page level
-
+static const char g_utf8_nbsp[3] = {'\xc2', '\xa0', '\0'}; // UTF-8 nbsp
+static const char *g_doxy_nsbp = "&_doxy_nbsp;"; // doxygen escape command for UTF-8 nbsp
//----------
const int codeBlockIndent = 4;
@@ -1028,6 +1029,17 @@ static int processCodeSpan(GrowBuf &out, const char *data, int /*offset*/, int s
return end;
}
+static void addStrEscapeUtf8Nbsp(GrowBuf &out,const char *s,int len)
+{
+ if (strnstr(s,g_doxy_nsbp,len)==0) // no escape needed -> fast
+ {
+ out.addStr(s,len);
+ }
+ else // escape needed -> slow
+ {
+ out.addStr(substitute(QCString(s).left(len),g_doxy_nsbp,g_utf8_nbsp));
+ }
+}
static int processSpecialCommand(GrowBuf &out, const char *data, int offset, int size)
{
@@ -1044,7 +1056,7 @@ static int processSpecialCommand(GrowBuf &out, const char *data, int offset, int
if (qstrncmp(&data[i+1],endBlockName,l)==0)
{
//printf("found end at %d\n",i);
- out.addStr(data,i+1+l);
+ addStrEscapeUtf8Nbsp(out,data,i+1+l);
return i+1+l;
}
}
@@ -2174,7 +2186,7 @@ static void writeFencedCodeBlock(GrowBuf &out,const char *data,const char *lng,
{
out.addStr("{"+lang+"}");
}
- out.addStr(data+blockStart,blockEnd-blockStart);
+ addStrEscapeUtf8Nbsp(out,data+blockStart,blockEnd-blockStart);
out.addStr("\n");
out.addStr("@endcode\n");
}
@@ -2484,7 +2496,7 @@ static QCString detab(const QCString &s,int &refIndent)
// special handling of the UTF-8 nbsp character 0xc2 0xa0
if (c == '\xc2' && data[i] == '\xa0')
{
- out.addStr("&nbsp;");
+ out.addStr(g_doxy_nsbp);
i++;
}
else
@@ -2561,7 +2573,7 @@ QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,cons
processInline(out,s,s.length());
out.addChar(0);
Debug::print(Debug::Markdown,0,"======== Markdown =========\n---- input ------- \n%s\n---- output -----\n%s\n=========\n",qPrint(input),qPrint(out.get()));
- return out.get();
+ return substitute(out.get(),g_doxy_nsbp,"&nbsp;");
}
//---------------------------------------------------------------------------