Skip to content

Commit

Permalink
fix: bug53, code cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Sep 24, 2020
2 parents 9f9f5fb + ae5992b commit 472552b
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 25 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/dropTheRope.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* istanbul ignore file */
// tslint:disable:no-console

import * as minimist from 'minimist';
import * as fs from 'fs';

Expand Down Expand Up @@ -42,3 +44,4 @@ export const run = async () => {
process.exit();
};
run();
// tslint:enable:no-console
2 changes: 2 additions & 0 deletions src/utils/turndown-rules/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ export const spanRule = {
`${HIGHLIGHT_SEPARATOR}${content}${HIGHLIGHT_SEPARATOR}` :
content;
}

return content;
},
};
2 changes: 1 addition & 1 deletion src/utils/turndown-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export const getTurndownService = () => {
turndownService.addRule('images', imagesRule);
turndownService.addRule('span', spanRule);
turndownService.use(gfm);

return turndownService;
};
26 changes: 6 additions & 20 deletions src/yarle.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -49,7 +50,7 @@ export const parseStream = async (options: YarleOptions): Promise<void> => {
console.log(
`Conversion finished: ${success} succeeded, ${
totalNotes - success
} failed.`
} failed.`,
);

return resolve();
Expand All @@ -63,7 +64,7 @@ export const parseStream = async (options: YarleOptions): Promise<void> => {
let np = new NodeProcessor();
np.processNode(item);
np = undefined;
console.log('note');
});*/
});
Expand All @@ -72,23 +73,8 @@ export const parseStream = async (options: YarleOptions): Promise<void> => {
export const dropTheRope = async (options: YarleOptions): Promise<void> => {
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
5 changes: 5 additions & 0 deletions test/data/test-nospanstyle.enex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export export-date="20200924T144847Z" application="Evernote" version="Evernote Mac 7.14 (458244)">
<note><title>test-nospanstyle</title><content><![CDATA[<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><span>N3<span>    ni ____</span></span></div><div><span><span>N5<span>    inin ____</span></span></span></div><div><span><span><span>N21<span>   īnī ____</span></span></span></span></div></en-note>]]></content><created>20200707T002138Z</created><updated>20200906T212153Z</updated><note-attributes><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes></note>
</en-export>
9 changes: 9 additions & 0 deletions test/data/test-nospanstyle.md
Original file line number Diff line number Diff line change
@@ -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


28 changes: 27 additions & 1 deletion test/yarle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'),
);
});

});

0 comments on commit 472552b

Please sign in to comment.