From 720927f4883f5670ee3b71ad365b5049fd234753 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Mon, 1 Oct 2018 20:55:24 +0100 Subject: [PATCH] All: Fixes #832: Enex import: Don't add extra line breaks at the beginning of list item when it contains a block element --- CliClient/tests/enex_to_md/list4.html | 5 +++++ CliClient/tests/enex_to_md/list4.md | 3 +++ ReactNativeClient/lib/import-enex-md-gen.js | 16 ++++++++++++++-- docs/faq/index.html | 2 ++ readme/faq.md | 4 ++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 CliClient/tests/enex_to_md/list4.html create mode 100644 CliClient/tests/enex_to_md/list4.md diff --git a/CliClient/tests/enex_to_md/list4.html b/CliClient/tests/enex_to_md/list4.html new file mode 100644 index 000000000..9af5fdfa5 --- /dev/null +++ b/CliClient/tests/enex_to_md/list4.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/CliClient/tests/enex_to_md/list4.md b/CliClient/tests/enex_to_md/list4.md new file mode 100644 index 000000000..3c6be4362 --- /dev/null +++ b/CliClient/tests/enex_to_md/list4.md @@ -0,0 +1,3 @@ +- This note has an unordered list +- List item +- List item \ No newline at end of file diff --git a/ReactNativeClient/lib/import-enex-md-gen.js b/ReactNativeClient/lib/import-enex-md-gen.js index 8c86ff451..6e96acab7 100644 --- a/ReactNativeClient/lib/import-enex-md-gen.js +++ b/ReactNativeClient/lib/import-enex-md-gen.js @@ -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
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 { diff --git a/docs/faq/index.html b/docs/faq/index.html index e2468f3d9..55f480ba5 100644 --- a/docs/faq/index.html +++ b/docs/faq/index.html @@ -265,6 +265,8 @@

How can I easily enter Markdown tags in Android?

You may use a special keyboard such as Multiling O Keyboard, which has shortcuts to create Markdown tags. More information in this post.

+

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.

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.

Could there be a PIN or password to restrict access to Joplin?

diff --git a/readme/faq.md b/readme/faq.md index e0fd9a878..5367d0c0c 100644 --- a/readme/faq.md +++ b/readme/faq.md @@ -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.