Zettelkasten Forum


Navigating Zettelkasten links in Marked 2

Has anyone found a way to get Marked 2 to navigate wikilinks? E.g. I would like to be able to view a note from my Zettelkasten in Marked, click a link referencing another note, and have Marked open that note.

Comments

  • I haven't implemented this, but I think your best bet is (a) a pre-processor that replaces wiki links with Markdown links, or (b) JavaScript to achieve a similar effect but in the template/output. You can use thearchive://match/<WIKI LINK HERE> to simulate clicking a wiki link from outside of the app.

    Author at Zettelkasten.de • https://christiantietze.de/

  • Hi there,

    I do this using a preprocessor, just as @ctietze suggests.

    Try the following ruby script, which strips the wiki link syntax, and adds the Markdown links. I had some help from the Marked developer when figuring this out, so credit goes to Brett Terpstra for this:

    #!/usr/bin/ruby
    require 'uri'
    
    def class_exists?(class_name)
      klass = Module.const_get(class_name)
      return klass.is_a?(Class)
    rescue NameError
      return false
    end
    
    if class_exists? 'Encoding'
      Encoding.default_external = Encoding::UTF_8 if Encoding.respond_to?('default_external')
      Encoding.default_internal = Encoding::UTF_8 if Encoding.respond_to?('default_internal')
    end
    
    begin
      input = STDIN.read.force_encoding('utf-8')
    rescue
      input = STDIN.read
    end
    
    input.gsub!(/\[\[(.*?)\]\]/) do |m|
      match = Regexp.last_match
      "[#{match[1]}](thearchive://match/#{URI.escape(match[1])}.txt)"
    end
    
    print input
    

    Hope it helps!

  • Just to add, you won’t need the .txt here! A relic from a prior version…

  • @mjknght said:
    Hi there,

    I do this using a preprocessor, just as @ctietze suggests.

    Amazing! Thanks for the script - It works

Sign In or Register to comment.