From 8cd256f77142db9dab61ccf92c19f0297e33c8db Mon Sep 17 00:00:00 2001 From: taoqf Date: Sat, 22 May 2021 16:21:37 +0800 Subject: [PATCH] issue #115 --- src/nodes/html.ts | 2 +- test/115.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/115.js diff --git a/src/nodes/html.ts b/src/nodes/html.ts index 0a0773c..e231f4a 100644 --- a/src/nodes/html.ts +++ b/src/nodes/html.ts @@ -272,7 +272,7 @@ export default class HTMLElement extends Node { dfs(this); return blocks.map((block) => { // Normalize each line's whitespace - return block.join('').trim().replace(/\s{2,}/g, ' '); + return block.join('').replace(/\s{2,}/g, ' '); }) .join('\n').replace(/\s+$/, ''); // trimRight; } diff --git a/test/115.js b/test/115.js new file mode 100644 index 0000000..7592265 --- /dev/null +++ b/test/115.js @@ -0,0 +1,9 @@ +const { parse } = require('../dist'); + +describe('issue 115', function () { + it('parse html', async function () { + const html = '

Hello world!

'; + const root = parse(html); + root.firstChild.innerText.should.eql('Hello world!'); + }); +});