Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unrecognized guid/links added #612

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/utils/apply-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,31 @@ export const applyLinks = (options: YarleOptions, outputNotebookFolders: Array<s

}
}


}



}
const unrecognizable = "Unrecognizable";

for (const targetFile of allconvertedFiles) {
const fileContent = fs.readFileSync(targetFile, 'UTF-8');

// TODO APPLY EVERNOTE LINK
const evernoteInternalLinkPlaceholderRegExp = new RegExp('<YARLE_EVERNOTE_LINK_PLACEHOLDER>', 'g');
let updatedContent = fileContent.replace(evernoteInternalLinkPlaceholderRegExp, unrecognizable);


// TODO APPLY EVERNOTE GUID
const evernoteGuidPlaceholderRegExp = new RegExp('<YARLE_EVERNOTE_GUID_PLACEHOLDER>', 'g');
updatedContent = updatedContent.replace(evernoteGuidPlaceholderRegExp, unrecognizable);

if (fileContent !== updatedContent) {
updateFileContentSafely(targetFile, updatedContent);

}
}
};

9 changes: 9 additions & 0 deletions test/data/two-untitled-notes-with-toc.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Untitled Note



noteOne


Evernote Link: Unrecognizable
Evernote GUID: Unrecognizable
37 changes: 37 additions & 0 deletions test/data/two-untitled-notes-with-toc.enex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export4.dtd">
<en-export export-date="20240226T092626Z" application="Evernote" version="10.74.1">
<note>
<title>Table of Contents</title>
<created>20240226T092601Z</created>
<updated>20240226T092610Z</updated>
<note-attributes>
</note-attributes>
<content>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div><a href="evernote:///view/244421476/s470/51d20bcc-9067-a174-11db-8654e3b7275e/d8ce9322-b866-453a-90b3-81923b70c474/" rel="noopener noreferrer" rev="en_rl_none">Untitled</a></div><div><a href="evernote:///view/244421476/s470/204864a5-3e65-ed00-8bad-1073ff6b65d9/d8ce9322-b866-453a-90b3-81923b70c474/" rel="noopener noreferrer" rev="en_rl_none">Untitled</a></div></en-note> ]]>
</content>
</note>
<note>
<title>Untitled Note</title>
<created>20240226T091903Z</created>
<updated>20240226T092317Z</updated>
<note-attributes>
</note-attributes>
<content>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>noteTwo</div></en-note> ]]>
</content>
</note>
<note>
<title>Untitled Note</title>
<created>20240226T092256Z</created>
<updated>20240226T092306Z</updated>
<note-attributes>
</note-attributes>
<content>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note><div>noteOne</div></en-note> ]]>
</content>
</note>
</en-export>
9 changes: 9 additions & 0 deletions test/data/two-untitled-notes-with-toc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Untitled Note



noteTwo


Evernote Link: Unrecognizable
Evernote GUID: Unrecognizable
89 changes: 88 additions & 1 deletion test/yarle-special-cases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ dateFormat: undefined,

it('Multiple enex files with interEnex links', async () => {
const options: YarleOptions = {
dateFormat: undefined,
dateFormat: undefined,
enexSources: [ `${process.cwd()}${path.sep}test${path.sep}data${path.sep}LinkedInterNotebooks` ],
outputDir: 'out',
isMetadataNeeded: true,
Expand Down Expand Up @@ -1035,6 +1035,93 @@ dateFormat: undefined,
fs.readFileSync(`${__dirname}/data/LinkedInterNotebooks/test-internotebook_links_B/Note in Notebook B.md`, 'utf8'),
);

});

it('Multiple untitled note - unregognized guid/link', async () => {
const options: YarleOptions = {
templateFile: `${testDataFolder}evernotelink-template.templ`,
enexSources: [ `${testDataFolder}two-untitled-notes-with-toc.enex` ],
"isMetadataNeeded": true,
"isNotebookNameNeeded": false,
"isZettelkastenNeeded": false,
"useZettelIdAsFilename": false,
"plainTextNotesOnly": false,
"skipLocation": true,
"skipCreationTime": true,
"skipUpdateTime": true,
"skipSourceUrl": true,
"skipWebClips": false,
"skipTags": true,
"useHashTags": true,
"outputFormat": OutputFormat.ObsidianMD,
"taskOutputFormat": TaskOutputFormat.ObsidianMD,
"skipEnexFileNameFromOutputPath": false,
"keepMDCharactersOfENNotes": false,
"monospaceIsCodeBlock": false,
"keepOriginalHtml": true,
"resourcesDir": "_resources",
"trimStartingTabs": false,
"convertPlainHtmlNewlines": false,
"encryptionPasswords": [
""
],
"logseqSettings": {
"journalNotes": false
},
"obsidianSettings": {
"omitLinkDisplayName": false
},
"dateFormat": "YYYY-MM-DD HH:mm",
"keepImageSize": OutputFormat.ObsidianMD,
"keepOriginalAmountOfNewlines": true,
"addExtensionToInternalLinks": false,
"generateNakedUrls": true,
"urlEncodeFileNamesAndLinks": false,
"haveEnexLevelResources": false,
"haveGlobalResources": false,
"useUniqueUnknownFileNames": true,
"useLevenshteinForLinks": false,
"sanitizeResourceNameSpaces": false,
"replacementChar": "_",
"replacementCharacterMap": {
"<": "_",
">": "_",
":": "_",
"\"": "_",
"/": "_",
"\\": "_",
"|": "_",
"?": "_",
"*": "_"
}

};
await dropTheRopeRunner.run(options);

assert.equal(
fs.existsSync(`${__dirname}/../out/notes/two-untitled-notes-with-toc/Untitled Note.1.md`),
true,
);
assert.equal(
fs.existsSync(`${__dirname}/../out/notes/two-untitled-notes-with-toc/Untitled Note.md`),
true,
);

assert.equal(
eol.auto(fs.readFileSync(
`${__dirname}/../out/notes/two-untitled-notes-with-toc/Untitled Note.md`,
'utf8',
)),
fs.readFileSync(`${__dirname}/data/two-untitled-notes-with-toc.md`, 'utf8'),
);
assert.equal(
eol.auto(fs.readFileSync(
`${__dirname}/../out/notes/two-untitled-notes-with-toc/Untitled Note.1.md`,
'utf8',
)),
fs.readFileSync(`${__dirname}/data/two-untitled-notes-with-toc.1.md`, 'utf8'),
);

});
it('Enex file with PDF attachment', async () => {
const options: YarleOptions = {
Expand Down
Loading