Use Marked to open nvALT internal links
I am using Marked to preview nvALT markdown notes, and I am using nvALT's internal linking syntax like this:
- [[my-file-foo]]
- [[my-file-bar]]
These appear clickable in nvALT and take you to that note in nvALT. But in Marked, they render as plain text and not links. How can I make these links clickable in Marked 2? Ideally, clicking them should open the markdown file in either Marked 2 or even in nvALT.
For some context, I am managing a library of markdown files that link to each other, and we are trying to get Marked/GitHub/nvALT to play together nicely, with respect to showing either clickable regular markdown links or clickable internal nvALT links. Users often use nvALT to view and edit the markdown files. Since nvALT does not make regular markdown links clickable, we are trying to use nvALT internal links and make them clickable in Marked 2 / Github... which is also annoying. Unless there a scheme that makes regular markdown links clickable in nvALT (in the raw non-preview mode)?
Thanks!
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on 20 Mar, 2018 08:31 PM
nvALT's editor parses wiki links out, and the preview does it with JavaScript (unless you're using a custom template). The JS that makes it happen looks like this:
A custom preprocessor that simply injected that into every preview would essentially add nvALT wiki support to Marked. However, it probably wouldn't help on GitHub. You'd need to write your own script that made the same regex conversion in the second line of the above script to the actual Markdown before pushing it to GitHub (though that could be added to a post-commit hook...).
-Brett
2 Posted by David on 28 Mar, 2018 04:12 PM
Any suggestion of how could this be implemented in Pandoc? I use it as a custom processor in Marked 2, and having functional wiki links would make my note-taking system just perfect.
Support Staff 3 Posted by Brett on 28 Mar, 2018 07:20 PM
David,
Add a preprocessor that does a simple search and replace. In Ruby for example:
4 Posted by David on 14 Jul, 2018 09:02 PM
Thanks, Brett. The preprocessor seems to crash every time there are non-ASCII characters. Any tip?
Thank you again,
d
Support Staff 5 Posted by Brett on 16 Jul, 2018 03:41 PM
You can force UTF-8 mode in recent versions of Ruby by changing the hash bang to this (first line of file):
For complete UTF-8 compatibility across Ruby versions, here's a full script:
6 Posted by David Colmenare... on 16 Jul, 2018 03:59 PM
Hi Brett, thank you so much! Works like a charm out of the box!
One last question, that you can of course ignore. Is there's a way to make Marked open the linked file? Clicking the wiki-link opens the file in Nvalt.
Best,
david
Support Staff 7 Posted by Brett on 16 Jul, 2018 04:03 PM
Well, the script is adding a link to nvalt://note_name, so it functions
the way an nvALT wiki link would. If you want to link to the actual MD
file, you'd want to change the `nvalt://` part to the path to the base
notes folder, e.g. `file:///Users/your_user/Dropbox/nvALT/`. When you
click one of those links, Marked will ask you how you want to handle it,
and you can have it open in the same window, new window, or let Finder
handle it. Note that opening in the same window does not give you a back
button, it just completely replaces the current file.
-Brett
8 Posted by David Colmenare... on 16 Jul, 2018 04:18 PM
The problem is that the link does not have an .md extension, so Marked can’t find the file...
Support Staff 9 Posted by Brett on 16 Jul, 2018 04:29 PM
Change this:
to
10 Posted by David Colmenare... on 16 Jul, 2018 04:32 PM
Perfect! Thanks a ton!
d
Brett closed this discussion on 22 Jul, 2018 01:31 PM.