1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop, CLI: Fixes #1672: Fix line break issue when importing certain notes from Evernotes

This commit is contained in:
Laurent Cozic 2019-06-22 11:23:22 +01:00
parent b175c1fc94
commit 50fd075168
4 changed files with 40 additions and 1 deletions

View File

@ -35,7 +35,7 @@ describe('EnexToMd', function() {
const htmlPath = basePath + '/' + htmlFilename;
const mdPath = basePath + '/' + filename(htmlFilename) + '.md';
// if (htmlFilename !== 'list5.html') continue;
// if (htmlFilename !== 'multiline_inner_text.html') continue;
const html = await shim.fsDriver().readFile(htmlPath);
let expectedMd = await shim.fsDriver().readFile(mdPath);

View File

@ -0,0 +1,7 @@
<div>Sometimes Evernote
wraps lines inside blocks</div>
<div>Sometimes it doesn't wrap them</div>
<pre>But
careful
with
pre tags</pre>

View File

@ -0,0 +1,6 @@
Sometimes Evernote wraps lines inside blocks
Sometimes it doesn't wrap them
But
careful
with
pre tags

View File

@ -430,8 +430,34 @@ function enexXmlToMdArray(stream, resources) {
//reject(e);
})
const unwrapInnerText = text => {
const lines = text.split('\n');
let output = '';
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const nextLine = i < lines.length - 1 ? lines[i+1] : '';
if (!line) {
output += '\n';
continue;
}
if (nextLine) {
output += line + ' ';
} else {
output += line;
}
}
return output;
}
saxStream.on('text', function(text) {
if (['table', 'tr', 'tbody'].indexOf(section.type) >= 0) return;
text = !state.inPre ? unwrapInnerText(text) : text;
section.lines = collapseWhiteSpaceAndAppend(section.lines, state, text);
})