summaryrefslogtreecommitdiff
path: root/js/lib/html.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/html.js')
-rw-r--r--js/lib/html.js16
1 files changed, 3 insertions, 13 deletions
diff --git a/js/lib/html.js b/js/lib/html.js
index afe7a33..3f2c1dd 100644
--- a/js/lib/html.js
+++ b/js/lib/html.js
@@ -1,5 +1,7 @@
"use strict";
+var escapeXml = require('./common').escapeXml;
+
// Helper function to produce an HTML tag.
var tag = function(name, attrs, selfclosing) {
var result = '<' + name;
@@ -246,8 +248,6 @@ var replaceUnsafeChar = function(s) {
}
};
-var reNeedsEscaping = /[&<>"]/;
-
// The HtmlRenderer object.
function HtmlRenderer(options){
return {
@@ -255,17 +255,7 @@ function HtmlRenderer(options){
softbreak: '\n', // by default, soft breaks are rendered as newlines in HTML
// set to "<br />" to make them hard breaks
// set to " " if you want to ignore line wrapping in source
- escape: function(s, preserve_entities) {
- if (reNeedsEscaping.test(s)) {
- if (preserve_entities) {
- return s.replace(/[&](?:[#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)|[&<>"]/gi, replaceUnsafeChar);
- } else {
- return s.replace(/[&<>"]/g, replaceUnsafeChar);
- }
- } else {
- return s;
- }
- },
+ escape: escapeXml,
options: options || {},
render: renderNodes
};