-
Notifications
You must be signed in to change notification settings - Fork 68
Make wiki-links work in VSCode's Markdown preview #183
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| // Transformation that only gets applied to the page name (ex: the "test-file.md" part of [[test-file.md | Description goes here]]). | ||
| export function postProcessPageName(pageName: string) { | ||
| function postProcessPageName(pageName: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these function name changes just cleanup to match the names in pluginSettings?
| } | ||
|
|
||
| // Transformation that only gets applied to the link label (ex: the " Description goes here" part of [[test-file.md | Description goes here]]) | ||
| export function postProcessLabel(label: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these export removed?
| postProcessPageName: postProcessPageName, | ||
| postProcessLabel: postProcessLabel, | ||
| uriSuffix: `.${NoteWorkspace.defaultFileExtension()}`, | ||
| description_then_file: NoteWorkspace.pipedWikiLinksSyntax() == 'desc|file', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the new version work with the piped syntax desc|file?
| "watch": "tsc -watch -p ./" | ||
| }, | ||
| "dependencies": { | ||
| "@thomaskoppelaar/markdown-it-wikilinks": "^1.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to understand other implications of this change. Your goal is to make it so the wiki links are clickable inside the vscode markdown preview -- but does this break any other use cases? Eg, is this going to break things somehow for html generated for other purposes / for viewing outside of the Markdown Prview?
|
Also, is it possible to add tests for any of this stuff? |
|
How much more work would it be to take the "cleaner approach" re "cleaner approach would be to use a version of markdown-it-wikilinks that sets the data-href attribute" ? |
I'd be happy to, but because I am not familiar with testing a markdown-it plugin, it will take some time before it's done.
Probably the hardest part is to make sure that the version of markdown-it-wikilinks like The current PR, instead, makes a minimal change to the code in |
|
I see. OK, well, I leave it to you to decide which approach to take, but either way it would be good to add tests to this. And maybe put a few screenshots / a screencast in the PR to demonstrate what this looks like / how it works. Thanks. |
Thank you for the excellent extension! I like Markdown Notes so much that I recommended it to my colleagues, but I also want to see this improved a bit.
Summary
This PR addresses #6 and makes wiki-links work in Markdown preview.
What's changed
The first change was necessary because
Therefore, to get the desired behavior, we need to fill href with a path relative to the document or the workspace folder.
Regarding the second change, it seems necessary for links in the preview window to work as expected.
Implementation details
Regarding the second change, I chose to copy, paste and modify the code from markdown-it-wikilinks, which is a markdown-it plugin that renders wiki-links. A cleaner approach would be to use a version of markdown-it-wikilinks that sets the data-href attribute (e.g. @shdwcat/markdown-it-wikilinks, see also thomaskoppelaar/markdown-it-wikilinks#1). I made this choice because I just wanted to have it work as quickly as possible without worrying about any side effects caused by changing dependent packages.
Limitations
A rendered wiki-link would be incorrect if
"vscodeMarkdownNotes.workspaceFilenameConvention": "relativePaths"or the wiki-link itself is a relative path.