diff --git a/src/1-one/output/api/html.js b/src/1-one/output/api/html.js index a44de9d77..f0889c124 100644 --- a/src/1-one/output/api/html.js +++ b/src/1-one/output/api/html.js @@ -1,12 +1,12 @@ const isClass = /^\../ const isId = /^#./ -const escapeXml = (str) => { +const escapeXml = str => { str = str.replace(/&/g, '&') str = str.replace(//g, '>') str = str.replace(/"/g, '"') - str = str.replace(/'/g, '''); + str = str.replace(/'/g, ''') return str } @@ -64,7 +64,8 @@ const html = function (obj) { if (starts.hasOwnProperty(t.id)) { out += starts[t.id].join('') } - out += t.pre || '' + t.text || '' + out += t.pre || '' + out += t.text || '' if (ends.hasOwnProperty(t.id)) { out += ends[t.id].join('') } @@ -73,4 +74,4 @@ const html = function (obj) { }) return out } -export default { html } \ No newline at end of file +export default { html } diff --git a/tests/one/output/html.test.js b/tests/one/output/html.test.js index 2fde7292b..26968eaba 100644 --- a/tests/one/output/html.test.js +++ b/tests/one/output/html.test.js @@ -18,6 +18,15 @@ test('html-match', function (t) { doc = nlp(`one match two.`) html = doc.html({ '.red': 'match+', '.blue': doc.match('two') }) t.equal(html, `one match two.`, here + 'html two classes') + + doc = nlp(`if i can recall, my grey dog loves pizza crusts (they are really good).`) + html = doc.html({ '.red': 'my grey dog', '.blue': doc.match('loves') }) + t.equal( + html, + `if i can recall, my grey dog loves pizza crusts (they are really good).`, + here + 'html pre test' + ) + t.end() }) @@ -25,7 +34,7 @@ test('html-nest', function (t) { let doc = nlp(`one match two.`) let html = doc.html({ i: 'match', - b: 'one match two' + b: 'one match two', }) t.equal(html, `one match two.`, here + 'easy nest') @@ -49,4 +58,4 @@ test('html-implicit', function (t) { let out = doc.html({ '.foo': '#Verb' }) t.equal(out, `he's cool`, here + 'implict') t.end() -}) \ No newline at end of file +})