Skip to content

Commit

Permalink
fix: of issue#50 implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
akosbalasko authored Sep 18, 2020
2 parents 4da2633 + 0b3974a commit 8945ea7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Those markdown notes that contains external resources such pictures or files, ar

## Release notes

### 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))

### Version 2.9.0

- NodeJs version limitation resolved.
Expand Down
2 changes: 1 addition & 1 deletion 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.0",
"version": "2.9.1",
"description": "Yet Another Rope Ladder from Evernote",
"keywords": [
"evernote",
Expand Down
9 changes: 6 additions & 3 deletions src/utils/turndown-rules/wikistyle-links-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { yarleOptions } from './../../yarle';
import { filterByNodeName } from './filter-by-nodename';
import { getAttributeProxy } from './get-attribute-proxy';

export const removeBrackets = (str: string): string => {
return str.replace(/\[|\]/g,'');
}
export const wikiStyleLinksRule = {
filter: filterByNodeName('A'),
replacement: (content: any, node: any) => {
Expand All @@ -13,10 +16,10 @@ export const wikiStyleLinksRule = {
return (
(!nodeProxy.href.value.startsWith('http') && !nodeProxy.href.value.startsWith('www')) ||
nodeProxy.href.value.startsWith('evernote://')) ?
`[[${node.innerHTML}]]` :
`[[${removeBrackets(node.innerHTML)}]]` :
(yarleOptions.outputFormat === OutputFormat.ObsidianMD) ?
`![[${node.innerHTML}]]` :
`[${node.innerHTML}](${nodeProxy.href.value})`;
`![[${removeBrackets(node.innerHTML)}]]` :
`[${removeBrackets(node.innerHTML)}](${nodeProxy.href.value})`;
}
},
};
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;
};
6 changes: 6 additions & 0 deletions test/data/test-bracketlinks.enex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export export-date="20200917T165819Z" application="Evernote" version="Evernote Mac 7.14 (458244)">
<note><title>test - bracketlinks</title><content><![CDATA[<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>
The computational theories of Albus </span><span style="border: 0px; vertical-align: baseline;"><a href="http://www.sciencedirect.com/science/article/pii/S0166223607000434#bib47" style="border: 0px; vertical-align: baseline; font-family: Arial, Helvetica, &quot;Lucida Sans Unicode&quot;, &quot;Microsoft Sans Serif&quot;, &quot;Segoe UI Symbol&quot;, STIXGeneral, &quot;Cambria Math&quot;, &quot;Arial Unicode MS&quot;, sans-serif; font-weight: 100; color: rgb(49, 108, 157); text-decoration: none;">47</a></span><span style="color: rgb(46, 46, 46); font-family: Arial, Helvetica, &quot;Lucida Sans Unicode&quot;, &quot;Microsoft Sans Serif&quot;, &quot;Segoe UI Symbol&quot;, STIXGeneral, &quot;Cambria Math&quot;, &quot;Arial Unicode MS&quot;, sans-serif; font-weight: 100;"> and Marr </span><span style="border: 0px; vertical-align: baseline;"><a href="http://www.sciencedirect.com/science/article/pii/S0166223607000434#bib48" style="border: 0px; vertical-align: baseline; font-family: Arial, Helvetica, &quot;Lucida Sans Unicode&quot;, &quot;Microsoft Sans Serif&quot;, &quot;Segoe UI Symbol&quot;, STIXGeneral, &quot;Cambria Math&quot;, &quot;Arial Unicode MS&quot;, sans-serif; font-weight: 100; color: rgb(49, 108, 157); text-decoration: none;">[48]</a></span><span style="color: rgb(46, 46, 46); font-family: Arial, Helvetica, &quot;Lucida Sans Unicode&quot;, &quot;Microsoft Sans Serif&quot;, &quot;Segoe UI Symbol&quot;, STIXGeneral, &quot;Cambria Math&quot;, &quot;Arial Unicode MS&quot;, sans-serif; font-weight: 100;"></en-note>]]></content><created>20141118T161055Z</created><updated>20200917T164643Z</updated><note-attributes><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes></note>
</en-export>
7 changes: 7 additions & 0 deletions test/data/test-bracketlinks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# test - bracketlinks
The computational theories of Albus [47](http://www.sciencedirect.com/science/article/pii/S0166223607000434#bib47) and Marr [48](http://www.sciencedirect.com/science/article/pii/S0166223607000434#bib48)

Created at: 2014-11-18T16:10:55+00:00
Updated at: 2020-09-17T17:46:43+01:00


43 changes: 43 additions & 0 deletions test/yarle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,49 @@ describe('dropTheRope ', async () => {
assert.equal(true, errorHappened);
});

it.skip('Enex file with note huge cell', async () => {
const options: YarleOptions = {
enexFile: './test/data/backgroundGenes.enex',
outputDir: 'out',
isMetadataNeeded: true,
};
await yarle.dropTheRope(options);
assert.equal(
fs.existsSync(
`${__dirname}/../out/simpleNotes/test-justText/test -note with text only.md`,
),
true,
);
assert.equal(
fs.readFileSync(
`${__dirname}/../out/simpleNotes/test-justText/test -note with text only.md`,
'utf8',
),
fs.readFileSync(`${__dirname}/data/test-justText.md`, 'utf8'),
);
});
it('Enex file with note WithHyperlinkRefs', async () => {
const options: YarleOptions = {
enexFile: './test/data/test-bracketlinks.enex',
outputDir: 'out',
isMetadataNeeded: true,
};
await yarle.dropTheRope(options);
assert.equal(
fs.existsSync(
`${__dirname}/../out/simpleNotes/test-bracketlinks/test - bracketlinks.md`,
),
true,
);
assert.equal(
fs.readFileSync(
`${__dirname}/../out/simpleNotes/test-bracketlinks/test - bracketlinks.md`,
'utf8',
),
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

0 comments on commit 8945ea7

Please sign in to comment.