joplin icon indicating copy to clipboard operation
joplin copied to clipboard

During Markdown export, folders that differ only by one special character are lost

Open JackGruber opened this issue 7 months ago • 2 comments

Operating system

Windows

Joplin version

2.13.6

Desktop version info

Joplin 2.13.6 (dev, win32)

Client ID: 7ff86a7f457d478e9dd5868ba2227a09 Sync Version: 3 Profile Version: 44 Keychain Supported: Yes

Revision: e7dd981

Current behaviour

  1. Create a notebook Test>1 with some random note
  2. Create a notebook Test<1 with some random note
  3. Create a notebook Test?1 with some random note in the notebook Test>1
  4. Select File > Export all > MD Markdown or MD Markdown + Front Matter
  5. Select destination folder

grafik

All notes are exported to the same folder Test_1 and the other folder is lost thereby also the structure of the notes. grafik

Content of the First Test_1 folder: grafik

Expected behaviour

All folders should be preserved, possibly with the addition of a number like the frist folder would be Test_1 and the next one Test_1_1

Logs

No response

JackGruber avatar Dec 03 '23 09:12 JackGruber

I tried to create a cleaver solution by keeping track of what file were being created, associating it with item.id to avoid using a folder that didn't belong to that id but my solution wasn't working, and to be honest I was still a little lost on what was happening.

So I thought about an alternative, which would be to change the unsafe chars to something else other than underscore:

https://github.com/laurent22/joplin/blob/07ee20a0ff13fff779617beb39a79d5ba19fbc3c/packages/lib/path-utils.ts#L38-L45

	for (let i = 0; i < e.length; i++) {
		const c = e[i];
		if (friendlySafeFilename_blackListChars.indexOf(c) >= 0) {
			output += `%${c.charCodeAt(0)}`;
		} else {
			output += c;
		}
	}

The problem is that we lose the "friendly name" factor from the friendlySafeFilename function: image

Maybe we can find middle ground?

pedr avatar Jan 29 '24 20:01 pedr

Looking at how Obsidian handles special characters, I made this test on Linux. I want to test on Windows too.

  • They don't allow \ / : in folder name
  • If you try to use them anyway, the characters are removed from the folder name ("Folder \ name" will turn to "Folder name")
  • If there is already a folder with the same name it gets renamed to "Untitled", "Untitled 1", "Untitlted 2", etc
  • Besides these characters, there are others that limit usage but are allowed, see image:

tst

On Windows, the not-allowed character list is different, would be interesting to see how they sync both folders from different OS.

pedr avatar Feb 02 '24 17:02 pedr