Import Markdown Files with Links?

Hi! I’m on Windows, if that matters. I just bought Scrivener (yay!) and am trying to just get the links working. AKA turning [[This]] into a clickable link! I did go into settings and toggle on the Automatically Detect Links thing, but it only does that for new text, not existing… so I am stuck with what is likely hundreds of instances of [[this]]. I can manually do it, I guess, but dear god, there are so. many.

I looked at the existing thread but uh… it’s a bit over my head :sweat_smile: All I know is that Obsidian (the app I’m importing from) uses markdown files in folders, and if I drag and drop the main folder into the binder, it auto-converts everything to .rtf files. Works great for everything except the links.

I’d be very grateful for any help!

Welcome to Scrivener!

Before getting too far into your query, there are a few resources I like to point new Scriv+Markdown users to:

All right, so to get into what you’re looking at, post-import, and how you can make that work for you, there are four key things to note:

  1. The double-bracket notation you’ve been using isn’t standard Markdown. It’s a convention some multi-file programs use, like Obsidian, but none of the conversion engines Scrivener uses (MultiMarkdown and Pandoc) will do anything useful with it.
  2. That isn’t a huge problem though, because single bracket notation is a Markdown standard used by these engines. You will find this approach used extensively in our user manuals (you can download the Scrivener manual as a .zip). At its simplest, [Name of Section] will become a cross reference to ## Name of Section (the number of hashes is irrelevant).
  3. When you imported your .md files, their filenames would have come into the binder using the same name you used in the [[Link Text]]. That is self-evident, but what you might not know yet is that the compiler can generate headings based on your draft outline, giving you those hashes you need from the above point.

So in a sense, you may already be set up with one small tweak: adding a compile replacement rule to convert double brackets to single:

Replacement setup...
  1. Open File ▸ Compile....

  2. Switch the Compile for option, at the very top, MultiMarkdown to HTML for a simple test. If you have Pandoc installed, you might want to try DOCX instead.

  3. In the left sidebar, select either “Basic MultiMarkdown” or “Basic Pandoc”, depending on which conversion engine you intend to use.

  4. For the purposes of this test, click the Assign Section Layouts button and for each entry in the left sidebar, assign it to the “Text Section with Heading” Layout, in the right column. You don’t have to worry about heading hash levels, the compiler will sort that out for you based on outline structure.

  5. Now click on the Replacements tab on the right (it looks like “ab → ac”), click the + button, and add the following:

    Replace: [[$@]]
    With: [$@].

    The $@ token is, as you might expect, a wildcard. So we’ll be replacing the text found within double-brackets with single bracets.

  6. Click the Compile button, and open the result in your word processor, browser, depending on what type of format you went with.

You should find all of your bracketed text are now proper links between sections in the output file.

Now you could, if you wanted, use the Project Replace feature to fix them all at once instead of using a Replacement. That won’t turn them into clickable links in Scrivener itself, but there is a nice feature there that might make doing this for everything a bit redundant. If you select the text between the brackets and right-click, it will look for a binder item that matches the title and offer it as a navigation option toward the top of the contextual menu. Linking without linking, basically, and maybe that will be good enough for all of these “legacy” links.

Going forward, you’ll note that in the user manual projects I very often do have hyperlinks inside the brackets. They don’t do anything when compiling, which is fine by me, it gives me control over when I want a link for myself vs a link for readers. If it is for the latter, then I type [[[Name of Binder Item]]]. Scrivener strips out two on each side, leaving the single-bracket behind which makes it a proper Markdown cross-reference link. You’ll also note that Markdown links have an alternate form that can be useful in many situations, [where this is the text visible to the reader][Binder Item Title].

You could maybe use a macro to fix all of the existing links, I bet AutoHotKey could make quick work of that since the bracket detection is all typing based. The macro would just need to find a [[, delete it, type it, look for the next ]] delete it, type it, and poof, now you have a link (or maybe have it type three like I suggested, so it stays a link readers see too).

On the other hand you could just make links inside the brackets whenever you come across one and want to jump to it. Distribute the work over years instead of doing it all at once, and only as needed.

2 Likes

Whoa, thank you so much!! This is very complicated but I’m very grateful you broke it down :sweat_smile:

I think I’ll just use the Replace with compile! Hopefully I do it right… I guess I’ll update if it doesn’t work!

1 Like

Well, update… I just tried it. It for some reason only compiled a single note, but as I was following the steps I realized I didn’t provide enough information! What I meant was that I would like for the links to work within Scrivener itself - essentially to transfer my worldbuilding from Obsidian (folders within folders, documents all linked to each other) to Scrivener and clean it up there.

I am very much so not code-savvy or type of person, so uh… this feels… very complicated to me :distorted_face: (also, that’s an emoji now?? I love it) Basic obsidian-style markdown is about all I’ve been able to handle thus far :sob:

Is this something I can really… do? If not, the linked-without-linking thing may just have to be sufficient!

1 Like

The main thing I wished to convey is that, in my experience anyway and for things like this, it is often better to only fix or update what you come across, as part of using the text as a tool. The compulsion to fix everything all at once may seem more tidy, but there is a good question to be had for whether you will actually click on every link more than once, making all of that effort worth it. If you instead spread the work out so that you’re only fixing the links you actually use, as you use them, then your time is spent more productively.

It’s not an approach that works for everything, but given how we are speaking of something purely internal, a convenience for you, that I’ve demonstrated doesn’t impact the export quality one bit, it is perfect for that kind of self-optimisation.


What I meant was that I would like for the links to work within Scrivener itself - essentially to transfer my worldbuilding from Obsidian (folders within folders, documents all linked to each other) to Scrivener and clean it up there.

Yeah, sorry I did understand that, but I wanted to make sure you had something functional as well, when exporting. I should have perhaps lead with the tips on linking in the editor before getting into export/compile stuff. If this project is more of an internal note repository to you, than something that will eventually become a document that other people read (with these links becomming cross-references), then maybe that stuff can all be set aside for now. It’s good to know in abstract though, that you can do such things! File it away for later.

Make sure all of your imported notes ended up in the Draft folder. You can check for that by selecting the Draft folder and tapping the Left arrow on your keyboard to collapse it. Does everything that should be compiled vanish? If not, select those notes with Shift-click, and drag and drop them onto the Draft to add them to it.

Otherwise, your compile settings might be set to something unusual in the Contents tab, if you’ve gone that far in tinkering about already. For example the “Current Selection” choice will often result in just one section compiling.

1 Like