Using Maruku with Marked

david.pw.smith's Avatar

david.pw.smith

19 Apr, 2012 11:37 PM

Hi there,

I run a website using jekyll, and only have maruku available on my remote server. As such I'd like to have Marked use Maruku so that I can see what I'll be getting, but try as I might, I can't get it to work. Currently I have the path to Maruku and the argument --html specified, but although Marked sees the file, and has the correct word count, the output is null both in the preview and in the html. Any pointers?

  1. Support Staff 1 Posted by Brett on 20 Apr, 2012 12:14 AM

    Brett's Avatar

    First, take a look at system.log in Console.app while you refresh the preview and see if any com.brettterpstra.marky errors show up there. That might help you find the issue pretty quickly.

    If Marked has a problem with finding the file or running it, it reverts to the built-in processor, so the fact that you're getting a blank preview means something's going on with Maruku. Are you running rvm at all? Marked doesn't currently honor rvm settings, so it's likely running your system default (which may not be compatible with your version of maruku).

    Let me know about the console and rvm, we can troubleshoot from there.

  2. 2 Posted by david.pw.smith on 20 Apr, 2012 01:04 AM

    david.pw.smith's Avatar

    Ah, you've hit the nail on the head with the RVM thing. I'm not the most ruby-fluent of customers, I'm more interested in jekyll for its allowing me to use markdown and html with nothing in the way!

    I have fixed the problem using a combination of this:

    #!/usr/bin/env ruby  
    
    require 'rubygems'
    require 'maruku'
    
    def markdown(text)  
      html = Maruku.new(text).to_html_document
    end
    
    puts markdown(STDIN.read)
    

    and this, borrowed from here:

    #!/bin/bash
    
    export GEM_PATH=~/.rvm/gems/ruby-1.9.3-p0:~/.rvm/gems/ruby-1.9.3-p0@global
    export GEM_HOME=~/.rvm/gems/ruby-1.9.3-p0
    
    cat - | ~/maruku-markdown.rb
    

    Thanks for your time, I'll perhaps have a go at whacking this into some sort of more universal format and then stick a link on here.

    Dave

  3. Support Staff 3 Posted by Brett on 20 Apr, 2012 01:44 AM

    Brett's Avatar

    Haven't tested it, but you could try something like this to narrow it down to one script:

     #!/usr/bin/env ruby  
    
    require 'rubygems'
    require 'maruku'
    
    ENV['GEM_PATH']="~/.rvm/gems/ruby-1.9.3-p0:~/.rvm/gems/ruby-1.9.3-p0@global"
    ENV['GEM_HOME']="~/.rvm/gems/ruby-1.9.3-p0"
    
    def markdown(text)  
      html = Maruku.new(text).to_html_document
    end
    
    puts markdown(STDIN.read)
    

    If that works, let me know and I'll add a page to the knowledgebase for it.

  4. 4 Posted by david.pw.smith on 20 Apr, 2012 08:54 AM

    david.pw.smith's Avatar

    That doesn't work, I'm afraid, and I think those two lines would be redundant, since those environment variables are set in /usr/bin/env. It seems like Marked (or OSX?) doesn't follow the variables set in the shebang /usr/bin/env...

  5. Support Staff 5 Posted by Brett on 20 Apr, 2012 12:00 PM

    Brett's Avatar

    It should, but it's basically spawning an entirely new shell outside of your user login, so it's possible it's loading a blank environment. If what you have is working, great, I'll mention the two-file trick in the FAQ instead, then :).

  6. david.pw.smith closed this discussion on 14 Jan, 2015 06:06 PM.

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