argenos / nldates-obsidian

Work with dates in natural language in Obsidian
MIT License
490 stars 44 forks source link

"Parse as link" doesn't respect wikilink settings. #63

Open iamrecursion opened 2 years ago

iamrecursion commented 2 years ago

When inserting a link from parsed text via the "Parse natural language date (as link)" command, it fails to respect the user's settings as to whether wiki links or markdown links should be used (like standard linking does). It looks like getParseCommand should use the logic from generateMarkdownLink, but doesn't.

tuchandra commented 2 years ago

For anyone else experiencing this, I fixed it locally in my own vault; it's a one-line change as the issue description suggests (thanks!).

I would make a PR, but I am not a plugin developer myself and am not sure if there's additional context I'm missing (with the aliases, with any other user settings we need to respect, etc.), or contribution guidelines to follow. The same line should still work in the TypeScript source version, though.

// <vault path>/.obsidian/plugins/nldates-obsidian/main.js
// getParseCommand, new contents for second half starting at the declaration of newStr

var newStr = "[[" + date.formattedString + "]]";
if (mode == "link") {
    // new version
    newStr = generateMarkdownLink(plugin.app, date.formattedString, selectedText);

    // original version
    // newStr = "[" + selectedText + "](" + date.formattedString + ")";
}

// ... everything after remains the same
// else if (mode == "clean") {