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

display cite key for Markdown links #271

Open
goi42 opened this issue Aug 28, 2024 · 0 comments · May be fixed by #272
Open

display cite key for Markdown links #271

goi42 opened this issue Aug 28, 2024 · 0 comments · May be fixed by #272

Comments

@goi42
Copy link

goi42 commented Aug 28, 2024

Right now, if the cite key contains unsafe characters for a path, the displayed title for the Markdown link has those characters replaced with _. This is not necessary and obscures the actual cite key. Details below.


The function getTitleForCitekey creates a title for the literature note, in part by replacing unsafe characters in the cite key:

getTitleForCitekey(citekey: string): string {
const unsafeTitle = this.literatureNoteTitleTemplate(
this.library.getTemplateVariablesForCitekey(citekey),
);
return unsafeTitle.replace(DISALLOWED_FILENAME_CHARACTERS_RE, '_');
}

The function insertLiteratureNoteLink uses this title to create the link to the note:

const title = this.getTitleForCitekey(citekey);
let linkText: string;
if (useMarkdown) {
const uri = encodeURI(
this.app.metadataCache.fileToLinktext(file, '', false),
);
linkText = `[${title}](${uri})`;
} else {
linkText = `[[${title}]]`;
}

This is correct for Wiki style links, which must use the path name, but this is not necessary for Markdown links, which could use the actual cite key as the displayed title while still using the safe title for the path name.

goi42 added a commit to goi42/obsidian-citation-plugin that referenced this issue Aug 28, 2024
@goi42 goi42 linked a pull request Aug 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant