Skip to content

display cite key for Markdown links #271

@goi42

Description

@goi42

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions