mgmeyers / obsidian-zotero-integration

Insert and import citations, bibliographies, notes, and PDF annotations from Zotero into Obsidian.
GNU General Public License v3.0
1.02k stars 55 forks source link

title as filename will remove question mark #340

Open SoftCoderCritic opened 8 months ago

SoftCoderCritic commented 8 months ago

image When using the title as part of the filename, I've noticed that question marks are unexpectedly removed. I'm curious if there's a specific rule for stripping out certain characters (like ":", "/", which are not allowed in file paths) from the title or this is a little bug?

For context, my template is just {{title}}.md, and I haven't implemented any character replacement. Is this behavior expected, or is there a workaround to include such characters in filenames?

Your plugin has been incredibly helpful, thanks for the nice work!

SoftCoderCritic commented 8 months ago

btw, i found the : will be replaced by - by default, just wondering if there is a place we can define these behaviors.

MSHelm commented 7 months ago

I also did struggle a bit with it. It comes down to replacing special characters that the plugin needs to do to get valid file names. This is a bit hidden in the code, but an be found here: https://github.com/mgmeyers/obsidian-zotero-integration/blob/f57a9551b2ba6b3090ebaebf41db796765ee980b/src/bbt/helpers.ts#L26-L40 For my citations I reproduced this behavior in my templates using {{title | replace(r/\s*[*?]+\s*/, " ") | trim | replace(r/\s*[:"<>|]+\s*/, " - ") | trim}}