Created
February 2, 2011 21:22
-
-
Save carlism/808467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ostruct' | |
class Article < OpenStruct | |
def initialize(hash=nil, &blk) | |
super(hash) | |
instance_eval &blk if blk | |
end | |
def method_missing(method, *args) | |
super "#{method}=".to_sym, args | |
end | |
end | |
@file = Article.new do | |
title "Test Article Title" | |
date "February 2, 2011 at 03:37:04 PM" | |
kind "Article" | |
# I'm using HAML, so I need to tell the HAML engine that this is Markdown that needs to be parsed. | |
content <<-EOS | |
:markdown | |
Markdown is intended to be as easy-to-read and easy-to-write as is feasible. Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4], [Grutatext] [5], and [EtText] [6] -- the single biggest source of inspiration for Markdown's syntax is the format of plain text email. [1]: http://docutils.sourceforge.net/mirror/setext.html [2]: http://www.aaronsw.com/2002/atx/ [3]: http://textism.com/tools/textile/ [4]: http://docutils.sourceforge.net/rst.html [5]: http://www.triptico.com/software/grutatxt.html [6]: http://ettext.taint.org/doc/ To this end, Markdown's syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like \*emphasis\*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you've ever used email. | |
EOS | |
tags "Test, Markdown" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load "article.rb" | |
puts @file.title | |
puts @file.kind | |
puts @file.date | |
puts @file.tags | |
puts @file.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment