Skip to content

Instantly share code, notes, and snippets.

@sidonath
Created November 18, 2009 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidonath/238298 to your computer and use it in GitHub Desktop.
Save sidonath/238298 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'osax'
require 'maruku'
doc = Appscript.app('WriteRoom').documents[0]
path = doc.file.get.path
file = File.join(
File.dirname(path),
File.basename(path).gsub(File.extname(path), '.html'))
# add some style to a dull HTML
md = <<-MARKDOWN
CSS: ../main.css
MARKDOWN
# append the content and convert
md += doc.text_contents.get
m = Maruku.new(md)
# save and open HTML file in browser
File.open(file, 'w') { |f| f.write(m.to_html_document) }
exec "open #{file}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment