summaryrefslogtreecommitdiffstats
path: root/src/xmlgen.cpp
diff options
context:
space:
mode:
authorVladimír Vondruš <mosra@centrum.cz>2017-11-25 17:37:26 (GMT)
committerVladimír Vondruš <mosra@centrum.cz>2017-11-25 17:37:26 (GMT)
commitb6a7abf02652b74872b9c676fcfa545e18d9bde7 (patch)
treef6ba2e5962f62fbf27f2058e241b36ae5adc373c /src/xmlgen.cpp
parent4f45bd20d4da7d40c793ec4c4c13558581e995ac (diff)
downloadDoxygen-b6a7abf02652b74872b9c676fcfa545e18d9bde7.zip
Doxygen-b6a7abf02652b74872b9c676fcfa545e18d9bde7.tar.gz
Doxygen-b6a7abf02652b74872b9c676fcfa545e18d9bde7.tar.bz2
Encode invalid XML characters instead of skipping them.
The <sp> element in <programlisting> has a new optional attribute `value`, which contains value of given invalid ASCII character. In case of space, the `value` attribute is omitted. Use cases for this: including snippets of *very esoteric* languages, markup that makes use of the advanced ASCII formatting characters or for example highlighting a console output containing ANSI color codes (which is my case, in fact). Regarding backwards compatibility -- as files with such ASCII characters are very rare, I don't expect this minor difference in the output to be a problem. Besides that, such ASCII characters are often replaced by a space in many applications anyway. A test snippet was extended to contain a special character so this difference in behavior could be verified.
Diffstat (limited to 'src/xmlgen.cpp')
-rw-r--r--src/xmlgen.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index 1b03c3b..56e107b 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -136,7 +136,9 @@ inline void writeXMLCodeString(FTextStream &t,const char *s, int &col)
case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18:
case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26:
case 27: case 28: case 29: case 30: case 31:
- break; // skip invalid XML characters (see http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char)
+ // encode invalid XML characters (see http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char)
+ t << "<sp value=\"" << int(c) << "\"/>";
+ break;
default: s=writeUtf8Char(t,s-1); col++; break;
}
}