flannel 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ begin
7
7
  Jeweler::Tasks.new do |gem|
8
8
  gem.name = "flannel"
9
9
  gem.summary = %Q{A soft comfortable worn in markup language for Ruby}
10
+ gem.description = %Q{Flannel is a markup language that is not intended for your web app. It's for your local use, to write a blog entry in your text editor or a number of other uses.}
10
11
  gem.email = "jamal.hansen@gmail.com"
11
12
  gem.homepage = "http://github.com/rubyyot/flannel"
12
13
  gem.authors = ["Jamal Hansen"]
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 12
4
+ :patch: 13
5
5
  :build:
@@ -5,12 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flannel}
8
- s.version = "0.2.12"
8
+ s.version = "0.2.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jamal Hansen"]
12
- s.date = %q{2010-02-25}
12
+ s.date = %q{2010-02-26}
13
13
  s.default_executable = %q{quilt-it}
14
+ s.description = %q{Flannel is a markup language that is not intended for your web app. It's for your local use, to write a blog entry in your text editor or a number of other uses.}
14
15
  s.email = %q{jamal.hansen@gmail.com}
15
16
  s.executables = ["quilt-it"]
16
17
  s.extra_rdoc_files = [
@@ -40,7 +40,7 @@ grammar Block
40
40
  end
41
41
 
42
42
  rule block_type
43
- ( feed / preformatted / list / header / blockquote / paragraph ) {
43
+ ( feed / preformatted / list / header / blockquote / dlist / image / paragraph ) {
44
44
  def content
45
45
  [:block_type, text_value.to_sym ]
46
46
  end
@@ -87,6 +87,10 @@ grammar Block
87
87
  "feed" { def content; text_value; end }
88
88
  end
89
89
 
90
+ rule image
91
+ "image" { def content; text_value; end }
92
+ end
93
+
90
94
  rule preformatted
91
95
  "preformatted" { def content; text_value; end }
92
96
  end
@@ -95,6 +99,10 @@ grammar Block
95
99
  "list" { def content; text_value; end }
96
100
  end
97
101
 
102
+ rule dlist
103
+ "dlist" { def content; text_value; end }
104
+ end
105
+
98
106
  rule block_id
99
107
  " "+ [a-z\-_]+ {
100
108
  def content
@@ -6,6 +6,7 @@ module Flannel
6
6
  @tags ={:preformatted => "pre",
7
7
  :feed => "ul",
8
8
  :list => "ul",
9
+ :dlist => "dl",
9
10
  :header_1 => "h1", #old style
10
11
  :header_2 => "h2",
11
12
  :header_3 => "h3",
@@ -50,6 +51,8 @@ module Flannel
50
51
  steps << lambda { |text| html_escape text}
51
52
  when :feed
52
53
  steps << lambda { |text| parse_feed text }
54
+ when :image
55
+ steps << lambda { |text| create_img text }
53
56
  else
54
57
  steps << lambda { |text| build_wiki_links text }
55
58
  steps << lambda { |text| convert_external_links text }
@@ -59,6 +62,10 @@ module Flannel
59
62
  steps << lambda { |text| format_list text }
60
63
  end
61
64
 
65
+ if style == :dlist
66
+ steps << lambda { |text| format_dlist text }
67
+ end
68
+
62
69
  steps << lambda { |text| wrap(text, @tags[style], id) }
63
70
 
64
71
  steps
@@ -74,6 +81,14 @@ module Flannel
74
81
  text.gsub(/-\w(.*?)\w>/) { |match| %{<a href="#{wiki_link match}">#{format_link_display(match)}</a>}}
75
82
  end
76
83
 
84
+ def create_img text
85
+ desc, url = text.split(/\n/, 2)
86
+
87
+ return text unless url
88
+
89
+ "<img src='#{url}' alt='#{desc}' title='#{desc}' />"
90
+ end
91
+
77
92
  def wiki_link topic
78
93
  permalink topic[1..-2]
79
94
  end
@@ -113,6 +128,17 @@ module Flannel
113
128
  text.split(/\n/).reject { |item| item == "" }.map { |item| wrap(item.chomp, "li") }.join("\n")
114
129
  end
115
130
 
131
+ def format_dlist text
132
+ text.split(/\n/).reject { |item| item == "" }.map { |item| split_definition(item) }.join("\n")
133
+ end
134
+
135
+ def split_definition item
136
+ term, definition = item.split(/\-/, 2).map{ |term| term.strip }
137
+
138
+ return item unless definition
139
+ "<dt>#{term}</dt><dd>#{definition}</dd>"
140
+ end
141
+
116
142
  def parse_feed text
117
143
  parser = Flannel::FeedParser.new Flannel.cache
118
144
  parser.sub_feeds text
@@ -71,5 +71,17 @@ class BlockParserStylesTest < Test::Unit::TestCase
71
71
  assert_doc doc, :header_six, nil, "text"
72
72
  end
73
73
 
74
+ def test_definition_list
75
+ doc = @parser.parse(":dlist:\ntext-foo")
76
+
77
+ assert_doc doc, :dlist, nil, "text-foo"
78
+ end
79
+
80
+ def test_image
81
+ doc = @parser.parse(":image:\nThis is an image\n/images/pickle.jpg")
82
+
83
+ assert_doc doc, :image, nil, "This is an image\n/images/pickle.jpg"
84
+ end
85
+
74
86
  end
75
87
 
@@ -61,6 +61,20 @@ class HtmlFormatterTest < Test::Unit::TestCase
61
61
  assert_equal "<pre>&lt;p&gt;&amp; foo&lt;/p&gt;</pre>", result
62
62
  end
63
63
  end
64
+
65
+ context "definition list" do
66
+ should "format definition list" do
67
+ result = @formatter.do("flannel - a wonderful markup dsl\nruby - a wonderful programming language", :dlist)
68
+ assert_equal "<dl><dt>flannel</dt><dd>a wonderful markup dsl</dd>\n<dt>ruby</dt><dd>a wonderful programming language</dd></dl>", result
69
+ end
70
+ end
71
+
72
+ context "image" do
73
+ should "format image" do
74
+ result = @formatter.do("This is a picture of a cat\n/images/cat.png", :image)
75
+ assert_equal "<img src='/images/cat.png' alt='This is a picture of a cat' title='This is a picture of a cat' />", result
76
+ end
77
+ end
64
78
 
65
79
  context "making permalinks" do
66
80
  should "replace spaces with dashes" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 12
9
- version: 0.2.12
8
+ - 13
9
+ version: 0.2.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jamal Hansen
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-25 00:00:00 -06:00
17
+ date: 2010-02-26 00:00:00 -06:00
18
18
  default_executable: quilt-it
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: "0"
66
66
  type: :development
67
67
  version_requirements: *id004
68
- description:
68
+ description: Flannel is a markup language that is not intended for your web app. It's for your local use, to write a blog entry in your text editor or a number of other uses.
69
69
  email: jamal.hansen@gmail.com
70
70
  executables:
71
71
  - quilt-it