From ae5992b3f361c07969dce6e612dc13f2c610199f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Akos=20Balask=C3=B3?= Date: Thu, 24 Sep 2020 21:41:17 +0200 Subject: [PATCH] bugs fixed, code cleaned --- README.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- src/dropTheRope.ts | 3 +++ src/utils/turndown-rules/span.ts | 2 ++ src/utils/turndown-service.ts | 2 +- src/yarle.ts | 26 ++++++-------------------- test/data/test-nospanstyle.enex | 5 +++++ test/data/test-nospanstyle.md | 9 +++++++++ test/yarle.spec.ts | 28 +++++++++++++++++++++++++++- 10 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 test/data/test-nospanstyle.enex create mode 100644 test/data/test-nospanstyle.md diff --git a/README.md b/README.md index 3c7c0dab..b91105ee 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,11 @@ Those markdown notes that contains external resources such pictures or files, ar ## Release notes +### Version 2.9.2 + +- [Issue#49](https://github.com/akosbalasko/yarle/issues/49) fixed +- [Issue#53](https://github.com/akosbalasko/yarle/issues/53) fixed + ### Version 2.9.1 - Enclosing brackets around links are removed to avoid causing troubles in MD file (fixes: [Issue#50](https://github.com/akosbalasko/yarle/issues/50)) diff --git a/package-lock.json b/package-lock.json index a1d3c2ba..fd686a4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yarle-evernote-to-md", - "version": "2.9.0", + "version": "2.9.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2295,7 +2295,7 @@ }, "rimraf": { "version": "2.1.4", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.1.4.tgz", + "resolved": "http://registry.npmjs.org/rimraf/-/rimraf-2.1.4.tgz", "integrity": "sha1-Wm62Lu2gaPUe3lDymz5c0i89m7I=", "requires": { "graceful-fs": "~1" diff --git a/package.json b/package.json index 4b5c76a4..7ec34e2f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yarle-evernote-to-md", - "version": "2.9.1", + "version": "2.9.2", "description": "Yet Another Rope Ladder from Evernote", "keywords": [ "evernote", diff --git a/src/dropTheRope.ts b/src/dropTheRope.ts index cf78abae..8e8b35d1 100644 --- a/src/dropTheRope.ts +++ b/src/dropTheRope.ts @@ -1,4 +1,6 @@ /* istanbul ignore file */ +// tslint:disable:no-console + import * as minimist from 'minimist'; import * as fs from 'fs'; @@ -42,3 +44,4 @@ export const run = async () => { process.exit(); }; run(); +// tslint:enable:no-console diff --git a/src/utils/turndown-rules/span.ts b/src/utils/turndown-rules/span.ts index 09d6843a..fa89f1ca 100644 --- a/src/utils/turndown-rules/span.ts +++ b/src/utils/turndown-rules/span.ts @@ -18,5 +18,7 @@ export const spanRule = { `${HIGHLIGHT_SEPARATOR}${content}${HIGHLIGHT_SEPARATOR}` : content; } + + return content; }, }; diff --git a/src/utils/turndown-service.ts b/src/utils/turndown-service.ts index bc749513..5e2f438c 100644 --- a/src/utils/turndown-service.ts +++ b/src/utils/turndown-service.ts @@ -26,6 +26,6 @@ export const getTurndownService = () => { turndownService.addRule('images', imagesRule); turndownService.addRule('span', spanRule); turndownService.use(gfm); - + return turndownService; }; diff --git a/src/yarle.ts b/src/yarle.ts index d85f251e..b9074b52 100644 --- a/src/yarle.ts +++ b/src/yarle.ts @@ -1,3 +1,4 @@ +// tslint:disable:no-console import * as fs from 'fs'; import * as parser from 'fast-xml-parser'; import * as XmlStream from 'xml-stream'; @@ -49,7 +50,7 @@ export const parseStream = async (options: YarleOptions): Promise => { console.log( `Conversion finished: ${success} succeeded, ${ totalNotes - success - } failed.` + } failed.`, ); return resolve(); @@ -63,7 +64,7 @@ export const parseStream = async (options: YarleOptions): Promise => { let np = new NodeProcessor(); np.processNode(item); np = undefined; - + console.log('note'); });*/ }); @@ -72,23 +73,8 @@ export const parseStream = async (options: YarleOptions): Promise => { export const dropTheRope = async (options: YarleOptions): Promise => { setOptions(options); utils.setPaths(); - /* const content = fs.readFileSync(options.enexFile, 'utf8'); - const notebook = parser.parse(content, xmlParserOptions); - const notes = notebook['en-export'];*/ + return parseStream(options); - /* - const notes = notebook['en-export']; - // utils.clearResourceDistDir(); - - if (notes) { - if (Array.isArray(notes['note'])) { - for (const [index, note] of notes['note'].entries()) { - if (!(yarleOptions.plainTextNotesOnly && note.resource)) { - processNode(note); - } - } - } else if (!(yarleOptions.plainTextNotesOnly && notes['note'] as any).resource) { - processNode(notes['note']); - } - }*/ + }; +// tslint:enable:no-console diff --git a/test/data/test-nospanstyle.enex b/test/data/test-nospanstyle.enex new file mode 100644 index 00000000..5bff2a3a --- /dev/null +++ b/test/data/test-nospanstyle.enex @@ -0,0 +1,5 @@ + + + +test-nospanstyle
N3    ni ____
N5    inin ____
N21   īnī ____
]]>
20200707T002138Z20200906T212153Zdesktop.mac0
+
diff --git a/test/data/test-nospanstyle.md b/test/data/test-nospanstyle.md new file mode 100644 index 00000000..e6d80030 --- /dev/null +++ b/test/data/test-nospanstyle.md @@ -0,0 +1,9 @@ +# test-nospanstyle +N3 ni \_\_\_\_ +N5 inin \_\_\_\_ +N21 īnī \_\_\_\_ + + Created at: 2020-07-07T01:21:38+01:00 + Updated at: 2020-09-06T22:21:53+01:00 + + diff --git a/test/yarle.spec.ts b/test/yarle.spec.ts index f23174c8..bd05bb10 100644 --- a/test/yarle.spec.ts +++ b/test/yarle.spec.ts @@ -77,7 +77,7 @@ describe('dropTheRope ', async () => { fs.readFileSync(`${__dirname}/data/test-bracketlinks.md`, 'utf8'), ); }); - + it('Enex file with note containing text only', async () => { const options: YarleOptions = { enexFile: './test/data/test-justText.enex', @@ -693,4 +693,30 @@ describe('dropTheRope ', async () => { fs.readFileSync(`${__dirname}/data/test-twoNotes-text.md`, 'utf8'), ); }); + + it('Enex file - no span style', async () => { + const options: YarleOptions = { + enexFile: './test/data/test-nospanstyle.enex', + outputDir: 'out', + isMetadataNeeded: true, + plainTextNotesOnly: false, + outputFormat: OutputFormat.ObsidianMD, + }; + await yarle.dropTheRope(options); + assert.equal( + fs.existsSync( + `${__dirname}/../out/simpleNotes/test-nospanstyle/test-nospanstyle.md`, + ), + true, + ); + + assert.equal( + fs.readFileSync( + `${__dirname}/../out/simpleNotes/test-nospanstyle/test-nospanstyle.md`, + 'utf8', + ), + fs.readFileSync(`${__dirname}/data/test-nospanstyle.md`, 'utf8'), + ); + }); + });