From 8a5e6875f0e51cbbead4e0b78e51b237b6926c74 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 12 Jul 2020 19:13:08 +0100 Subject: [PATCH] Desktop, Cli: Fixes #3473: Fix filename when exporting notebook as Markdown --- CliClient/tests/services_InteropService.js | 17 +++++++++++++++++ .../lib/services/InteropService_Exporter_Md.js | 6 +++--- Tools/release-electron.js | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CliClient/tests/services_InteropService.js b/CliClient/tests/services_InteropService.js index 2a6bb9bd6..eeec0d446 100644 --- a/CliClient/tests/services_InteropService.js +++ b/CliClient/tests/services_InteropService.js @@ -427,4 +427,21 @@ describe('services_InteropService', function() { expect(await shim.fsDriver().exists(`${outDir}/ジョプリン/ジョプリン.md`)).toBe(true); })); + it('should export a notebook as MD', asyncTest(async () => { + const folder1 = await Folder.save({ title: 'testexportfolder' }); + await Note.save({ title: 'textexportnote1', parent_id: folder1.id }); + await Note.save({ title: 'textexportnote2', parent_id: folder1.id }); + + const service = new InteropService(); + + await service.export({ + path: exportDir(), + format: 'md', + sourceFolderIds: [folder1.id], + }); + + expect(await shim.fsDriver().exists(`${exportDir()}/testexportfolder/textexportnote1.md`)).toBe(true); + expect(await shim.fsDriver().exists(`${exportDir()}/testexportfolder/textexportnote2.md`)).toBe(true); + })); + }); diff --git a/ReactNativeClient/lib/services/InteropService_Exporter_Md.js b/ReactNativeClient/lib/services/InteropService_Exporter_Md.js index 370d696b3..dacd97df0 100644 --- a/ReactNativeClient/lib/services/InteropService_Exporter_Md.js +++ b/ReactNativeClient/lib/services/InteropService_Exporter_Md.js @@ -15,7 +15,7 @@ class InteropService_Exporter_Md extends InteropService_Exporter_Base { await shim.fsDriver().mkdir(this.resourceDir_); } - async makeDirPath_(item, pathPart = null) { + async makeDirPath_(item, pathPart = null, findUniqueFilename = true) { let output = ''; while (true) { if (item.type_ === BaseModel.TYPE_FOLDER) { @@ -23,7 +23,7 @@ class InteropService_Exporter_Md extends InteropService_Exporter_Base { output = `${pathPart}/${output}`; } else { output = `${friendlySafeFilename(item.title, null, true)}/${output}`; - output = await shim.fsDriver().findUniqueFilename(output); + if (findUniqueFilename) output = await shim.fsDriver().findUniqueFilename(output); } } if (!item.parent_id) return output; @@ -86,7 +86,7 @@ class InteropService_Exporter_Md extends InteropService_Exporter_Base { if (!note) continue; - let notePath = `${await this.makeDirPath_(note)}${friendlySafeFilename(note.title, null, true)}.md`; + let notePath = `${await this.makeDirPath_(note, null, false)}${friendlySafeFilename(note.title, null, true)}.md`; notePath = await shim.fsDriver().findUniqueFilename(`${this.destDir_}/${notePath}`, Object.values(context.notePaths)); context.notePaths[note.id] = notePath; } diff --git a/Tools/release-electron.js b/Tools/release-electron.js index c2a11cca4..941edc25a 100644 --- a/Tools/release-electron.js +++ b/Tools/release-electron.js @@ -29,6 +29,7 @@ async function main() { console.info(`Created GitHub release: ${release.html_url}`); console.info('GitHub release page: https://github.com/laurent22/joplin/releases'); + console.info(`To create changelog: node Tools/git-changelog.js ${version}`); } main().catch((error) => {