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:
parent
b175c1fc94
commit
50fd075168
@ -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);
|
||||
|
7
CliClient/tests/enex_to_md/multiline_inner_text.html
Normal file
7
CliClient/tests/enex_to_md/multiline_inner_text.html
Normal 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>
|
6
CliClient/tests/enex_to_md/multiline_inner_text.md
Normal file
6
CliClient/tests/enex_to_md/multiline_inner_text.md
Normal file
@ -0,0 +1,6 @@
|
||||
Sometimes Evernote wraps lines inside blocks
|
||||
Sometimes it doesn't wrap them
|
||||
But
|
||||
careful
|
||||
with
|
||||
pre tags
|
@ -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);
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user