nathanhoad-moredown 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/moredown.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rdiscount'
2
2
 
3
3
  class Moredown < RDiscount
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
 
6
6
  # Don't use inline CSS for styling
7
7
  attr_accessor :has_stylesheet
@@ -55,18 +55,25 @@ class Moredown < RDiscount
55
55
  def to_html
56
56
  html = super
57
57
 
58
- # youtube
59
- html.gsub!(/<img src="youtube:(.*)?" alt="(.*)?" \/>/) do |match|
60
- flash_tag "http://www.youtube.com/v/#{$1}", :width => 425, :height => 350
61
- end
62
-
63
- # flash movies
64
- html.gsub!(/<img src="flash:(.*?)"\s?(?:title="(.*?)")? alt="(.*)" \/>/) do |match|
65
- if $2
66
- sizes = $2.split(' ')
58
+ # flash movies (including youtube)
59
+ html.gsub!(/<img src="(flash|youtube):(.*?)"\s?(?:title="(.*?)")? alt="(.*)" \/>/) do |match|
60
+ # grab width and height
61
+ if $3
62
+ sizes = $3.split(' ')
67
63
  sizes = { :width => sizes[0], :height => sizes[1] }
64
+ else
65
+ sizes = {}
68
66
  end
69
- flash_tag $1, (sizes || {})
67
+
68
+ # check the source
69
+ if $1.downcase == "youtube"
70
+ url = "http://www.youtube.com/v/#{$2}"
71
+ sizes = { :width => 425, :height => 350 }.merge sizes
72
+ else
73
+ url = $2
74
+ end
75
+
76
+ flash_tag url, sizes
70
77
  end
71
78
 
72
79
  # image alignments
@@ -110,7 +117,7 @@ class Moredown < RDiscount
110
117
  end
111
118
 
112
119
  # html seems to need to go after the swfobject javascript
113
- html = "<script type=\"text/javascript\" src=\"#{@swfobject[:src]}\"></script><script type=\"text/javascript\">\n//<![CDATA[\n#{swfobjects}//]]>\n</script>\n#{html}"
120
+ html = "<script type=\"text/javascript\" src=\"#{@swfobject[:src]}\"></script><script type=\"text/javascript\">\n/*<![CDATA[*/\n#{swfobjects}/*]]>*/\n</script>\n#{html}"
114
121
  end
115
122
 
116
123
  html
data/moredown.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'moredown'
3
- s.version = '1.0.3'
3
+ s.version = '1.0.4'
4
4
  s.summary = "Fast Implementation of Gruber's Markdown in C"
5
- s.date = '2009-09-08'
5
+ s.date = '2009-09-12'
6
6
  s.email = 'nathan@nathanhoad.net'
7
7
  s.homepage = 'http://github.com/nathanhoad/moredown'
8
8
  s.has_rdoc = true
@@ -23,6 +23,10 @@ class MoredownTest < Test::Unit::TestCase
23
23
  html = "<p><object id=\"swf-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/12345678\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/v/12345678\" width=\"425\" height=\"350\"><!--<![endif]--><a href=\"http://www.youtube.com/v/12345678\"><img src=\"http://img.youtube.com/vi/12345678/default.jpg\" alt=\"\" /></a><!--[if !IE]>--></object><!--<![endif]--></object></p>\n"
24
24
  assert_equal html, Moredown.text_to_html(text)
25
25
 
26
+ text = "![Video](youtube:12345678 \"200 100\")"
27
+ html = 'width="200" height="100"'
28
+ assert Moredown.text_to_html(text).include?(html), "Width should be 200 and height should be 100"
29
+
26
30
  text = <<TEXT
27
31
  Here is a video:
28
32
 
@@ -138,8 +142,8 @@ TEXT
138
142
  assert_equal html, Moredown.text_to_html(text)
139
143
 
140
144
  text = '![Flash](flash:movieclip.swf "800 600")'
141
- html = "<p><object id=\"swf-1\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"800\" height=\"600\"><param name=\"movie\" value=\"movieclip.swf\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"movieclip.swf\" width=\"800\" height=\"600\"><!--<![endif]-->Flash is not available.<!--[if !IE]>--></object><!--<![endif]--></object></p>\n"
142
- assert_equal html, Moredown.text_to_html(text)
145
+ html = 'width="800" height="600"'
146
+ assert Moredown.text_to_html(text).include?(html), "Width should be 800 and height should be 600"
143
147
  end
144
148
 
145
149
  def test_swfobject
@@ -151,10 +155,10 @@ TEXT
151
155
 
152
156
  And that's all."
153
157
  html = "<script type=\"text/javascript\" src=\"./swfobject.js\"></script><script type=\"text/javascript\">
154
- //<![CDATA[
158
+ /*<![CDATA[*/
155
159
  swfobject.registerObject(\"swf-1\", \"10\");
156
160
  swfobject.registerObject(\"swf-2\", \"10\");
157
- //]]>
161
+ /*]]>*/
158
162
  </script>
159
163
  <p>Here is some flash:</p>
160
164
 
@@ -163,6 +167,6 @@ swfobject.registerObject(\"swf-2\", \"10\");
163
167
  <p><object id=\"swf-2\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"400\" height=\"300\"><param name=\"movie\" value=\"movieclip.swf\" /><!--[if !IE]>--><object type=\"application/x-shockwave-flash\" data=\"movieclip.swf\" width=\"400\" height=\"300\"><!--<![endif]-->No Flash<!--[if !IE]>--></object><!--<![endif]--></object></p>
164
168
 
165
169
  <p>And that's all.</p>\n"
166
- assert_equal html, Moredown.text_to_html(text, :swfobject => { :js_src => './swfobject.js', :version => '10', :fallback => 'No Flash' })
170
+ assert_equal html, Moredown.text_to_html(text, :swfobject => { :src => './swfobject.js', :version => '10', :fallback => 'No Flash' })
167
171
  end
168
172
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nathanhoad-moredown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hoad
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-09-08 00:00:00 -07:00
14
+ date: 2009-09-12 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies: []
17
17
 
@@ -54,6 +54,7 @@ files:
54
54
  - test/rdiscount_test.rb
55
55
  has_rdoc: true
56
56
  homepage: http://github.com/nathanhoad/moredown
57
+ licenses:
57
58
  post_install_message:
58
59
  rdoc_options: []
59
60
 
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  requirements: []
75
76
 
76
77
  rubyforge_project:
77
- rubygems_version: 1.2.0
78
+ rubygems_version: 1.3.5
78
79
  signing_key:
79
80
  specification_version: 2
80
81
  summary: Fast Implementation of Gruber's Markdown in C