Skip to content

Commit

Permalink
Desktop, CLI: Fixes #1476: Import lists and sub-lists from Enex files…
Browse files Browse the repository at this point in the history
… with correct indentation
  • Loading branch information
laurent22 committed May 1, 2019
1 parent 27f14c1 commit b2129cb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CliClient/tests/EnexToMd.js
Expand Up @@ -35,7 +35,7 @@ describe('EnexToMd', function() {
const htmlPath = basePath + '/' + htmlFilename;
const mdPath = basePath + '/' + filename(htmlFilename) + '.md';

// if (htmlFilename !== 'text2.html') continue;
// if (htmlFilename !== 'list5.html') continue;

const html = await shim.fsDriver().readFile(htmlPath);
let expectedMd = await shim.fsDriver().readFile(mdPath);
Expand Down
16 changes: 16 additions & 0 deletions CliClient/tests/enex_to_md/list5.html
@@ -0,0 +1,16 @@
<ul>
<li lang="en-US">
<div>Protocols</div>
</li>
<ul type="circle">
<li lang="en-US">
<div>two common network protocols used to send data packets over a network</div>
</li>
<li lang="en-US">
<div>TCP Transmission control protocol</div>
</li>
</ul>
<li lang="en-US">
<div>Network port - a network port is a process-specific or an application-specific software construct serving as a communication endpoint, which is used by the Transport Layer protocols of Internet Protocol suite, such as UDP and TCP</div>
</li>
</ul>
7 changes: 7 additions & 0 deletions CliClient/tests/enex_to_md/list5.md
@@ -0,0 +1,7 @@
- Protocols

- two common network protocols used to send data packets over a network

- TCP Transmission control protocol

- Network port - a network port is a process-specific or an application-specific software construct serving as a communication endpoint, which is used by the Transport Layer protocols of Internet Protocol suite, such as UDP and TCP
6 changes: 4 additions & 2 deletions ReactNativeClient/lib/import-enex-md-gen.js
Expand Up @@ -497,10 +497,12 @@ function enexXmlToMdArray(stream, resources) {

let container = state.lists[state.lists.length - 1];
container.startedText = false;

const indent = ' '.repeat(state.lists.length - 1);
if (container.tag == "ul") {
section.lines.push("- ");
section.lines.push(indent + "- ");
} else {
section.lines.push(container.counter + '. ');
section.lines.push(indent + container.counter + '. ');
container.counter++;
}
} else if (isStrongTag(n)) {
Expand Down

0 comments on commit b2129cb

Please sign in to comment.