mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop, Cli: Fixes #3473: Fix filename when exporting notebook as Markdown
This commit is contained in:
parent
073bd80f89
commit
8a5e6875f0
@ -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);
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user