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

All: Fixes #832: Enex import: Don't add extra line breaks at the beginning of list item when it contains a block element

This commit is contained in:
Laurent Cozic 2018-10-01 20:55:24 +01:00
parent 36c3521f40
commit 720927f488
5 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1,5 @@
<ul>
<li><div>This note has an unordered list</div></li>
<li><div>List item</div></li>
<li><div>List item</div></li>
</ul>

View File

@ -0,0 +1,3 @@
- This note has an unordered list
- List item
- List item

View File

@ -427,8 +427,19 @@ function enexXmlToMdArray(stream, resources) {
saxStream.on('opentag', function(node) {
const nodeAttributes = attributeToLowerCase(node);
let n = node.name.toLowerCase();
const currentList = state.lists && state.lists.length ? state.lists[state.lists.length - 1] : null;
// Kind of a hack: If we are inside a list, at the beginning of an item (when a "- " or "1. " has been added
// but no other text yet), if the current tag is eg. a <div> or any other block tag, we skip it, so that a new line
// does not get created. It is to handle list4.html test case.
// https://github.com/laurent22/joplin/issues/832
if (currentList) {
if (!currentList.startedText && isBlockTag(n)) return;
currentList.startedText = true;
}
if (n == 'en-note') {
// Start of note
} else if (isBlockTag(n)) {
@ -476,7 +487,7 @@ function enexXmlToMdArray(stream, resources) {
section = newSection;
} else if (isListTag(n)) {
section.lines.push(BLOCK_OPEN);
state.lists.push({ tag: n, counter: 1 });
state.lists.push({ tag: n, counter: 1, startedText: false });
} else if (n == 'li') {
section.lines.push(BLOCK_OPEN);
if (!state.lists.length) {
@ -485,6 +496,7 @@ function enexXmlToMdArray(stream, resources) {
}
let container = state.lists[state.lists.length - 1];
container.startedText = false;
if (container.tag == "ul") {
section.lines.push("- ");
} else {

View File

@ -265,6 +265,8 @@
</ol>
<h1 id="how-can-i-easily-enter-markdown-tags-in-android-">How can I easily enter Markdown tags in Android?</h1>
<p>You may use a special keyboard such as <a href="https://play.google.com/store/apps/details?id=kl.ime.oh&amp;hl=en">Multiling O Keyboard</a>, which has shortcuts to create Markdown tags. <a href="https://discourse.joplin.cozic.net/t/android-create-new-list-item-with-enter/585/2?u=laurent">More information in this post</a>.</p>
<h1 id="the-initial-sync-is-very-slow-how-can-i-speed-it-up-">The initial sync is very slow, how can I speed it up?</h1>
<p>Whenever importing a large number of notes, for example from Evernote, it may take a very long time for the first sync to complete. There are various techniques to speed thing up (if you don&#39;t want to simply wait for the sync to complete), which are outlined in <a href="https://discourse.joplin.cozic.net/t/workaround-for-slow-initial-bulk-sync-after-evernote-import/746?u=laurent">this post</a>.</p>
<h1 id="is-it-possible-to-use-real-file-and-folder-names-in-the-sync-target-">Is it possible to use real file and folder names in the sync target?</h1>
<p>Unfortunately it is not possible. Joplin synchronises with file systems using an open format however it does not mean the sync files are meant to be user-editable. The format is designed to be performant and reliable, not user friendly (it cannot be both), and that cannot be changed. Joplin sync directory is basically just a database.</p>
<h1 id="could-there-be-a-pin-or-password-to-restrict-access-to-joplin-">Could there be a PIN or password to restrict access to Joplin?</h1>

View File

@ -18,6 +18,10 @@ When changing the WebDAV URL, make sure that the new location has the same exact
You may use a special keyboard such as [Multiling O Keyboard](https://play.google.com/store/apps/details?id=kl.ime.oh&hl=en), which has shortcuts to create Markdown tags. [More information in this post](https://discourse.joplin.cozic.net/t/android-create-new-list-item-with-enter/585/2?u=laurent).
# The initial sync is very slow, how can I speed it up?
Whenever importing a large number of notes, for example from Evernote, it may take a very long time for the first sync to complete. There are various techniques to speed thing up (if you don't want to simply wait for the sync to complete), which are outlined in [this post](https://discourse.joplin.cozic.net/t/workaround-for-slow-initial-bulk-sync-after-evernote-import/746?u=laurent).
# Is it possible to use real file and folder names in the sync target?
Unfortunately it is not possible. Joplin synchronises with file systems using an open format however it does not mean the sync files are meant to be user-editable. The format is designed to be performant and reliable, not user friendly (it cannot be both), and that cannot be changed. Joplin sync directory is basically just a database.