rubb 0.9.2 → 0.9.3

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/README.rdoc CHANGED
@@ -26,9 +26,9 @@ RuBB supports the following BBCode tags:
26
26
  [size=10]text[/size] => <span style="font-size: 10px;">text</span>
27
27
  [color=#ff0000]text[/color] => <span style="color: #ff0000;">text</span>
28
28
 
29
- [left]text[/left] => <span style="text-align: left;">text</span>
30
- [center]text[/center] => <span style="text-align: center;">text</span>
31
- [right]text[/right] => <span style="text-align: right;">text</span>
29
+ [left]text[/left] => <div style="text-align: left;">text</div>
30
+ [center]text[/center] => <div style="text-align: center;">text</div>
31
+ [right]text[/right] => <div style="text-align: right;">text</div>
32
32
 
33
33
  [quote]text[/quote] => <blockquote><p>text</p></blockquote>
34
34
  [quote=someone]text[/quote] => <blockquote><dl><dt>someone</dt><dd><p>text</p></dd></dl></blockquote>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
@@ -2,14 +2,16 @@ module RuBB
2
2
  class Node
3
3
  class Styled < Node
4
4
  attr_accessor :style_hash
5
+ attr_accessor :html_tag_name
5
6
 
6
7
  def initialize(options={})
7
8
  super(options)
8
9
  @style_hash = options[:style_hash] || {}
10
+ @html_tag_name = options[:html_tag_name] || 'span'
9
11
  end
10
12
 
11
13
  def to_html
12
- html = '<span style="'
14
+ html = "<#{@html_tag_name} style=\""
13
15
  @style_hash.each do |k,v|
14
16
  if(v) # if v is not nil
15
17
  v = v[/\A([^;]*);/,1] if v.include?(';') # ignore semicolons and any trailing text
@@ -20,7 +22,7 @@ module RuBB
20
22
  @children.each do |child|
21
23
  html += child ? child.to_html : ''
22
24
  end
23
- html + "</span>"
25
+ html + "</#{@html_tag_name}>"
24
26
  end
25
27
  end
26
28
  end
data/lib/rubb/parser.rb CHANGED
@@ -41,15 +41,17 @@ module RuBB
41
41
  when 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td'
42
42
  Node::Simple.new(:html_tag_name => current_tag_name)
43
43
  when 'size'
44
- Node::Styled.new(:style_hash => {'font-size' => (extra_params[:param] ? extra_params[:param].to_f.to_s + 'px' : nil)})
44
+ Node::Styled.new(:html_tag_name => 'span',
45
+ :style_hash => {'font-size' => (extra_params[:param] ? extra_params[:param].to_f.to_s + 'px' : nil)})
45
46
  when 'color'
46
- Node::Styled.new(:style_hash => {'color' => (extra_params[:param] ? extra_params[:param].to_s : nil)})
47
+ Node::Styled.new(:html_tag_name => 'span',
48
+ :style_hash => {'color' => (extra_params[:param] ? extra_params[:param].to_s : nil)})
47
49
  when 'left'
48
- Node::Styled.new(:style_hash => {'text-align' => 'left'})
50
+ Node::Styled.new(:html_tag_name => 'div', :style_hash => {'text-align' => 'left'})
49
51
  when 'center'
50
- Node::Styled.new(:style_hash => {'text-align' => 'center'})
52
+ Node::Styled.new(:html_tag_name => 'div', :style_hash => {'text-align' => 'center'})
51
53
  when 'right'
52
- Node::Styled.new(:style_hash => {'text-align' => 'right'})
54
+ Node::Styled.new(:html_tag_name => 'div', :style_hash => {'text-align' => 'right'})
53
55
  when 'quote'
54
56
  Node::Quote.new(:who => (extra_params[:param] ? extra_params[:param].to_s : ''))
55
57
  when 'url'
data/rubb.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubb}
8
- s.version = "0.9.2"
8
+ s.version = "0.9.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Jihoon Kim"]
data/test/test_rubb.rb CHANGED
@@ -49,19 +49,19 @@ class RuBBTest < Test::Unit::TestCase
49
49
 
50
50
  def test_left
51
51
  bb = '[left]hello[/left]'
52
- html = '<span style="text-align: left;">hello</span>'
52
+ html = '<div style="text-align: left;">hello</div>'
53
53
  assert_equal html, bb.bb_to_html
54
54
  end
55
55
 
56
56
  def test_center
57
57
  bb = '[center]hello[/center]'
58
- html = '<span style="text-align: center;">hello</span>'
58
+ html = '<div style="text-align: center;">hello</div>'
59
59
  assert_equal html, bb.bb_to_html
60
60
  end
61
61
 
62
62
  def test_right
63
63
  bb = '[right]hello[/right]'
64
- html = '<span style="text-align: right;">hello</span>'
64
+ html = '<div style="text-align: right;">hello</div>'
65
65
  assert_equal html, bb.bb_to_html
66
66
  end
67
67
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 2
9
- version: 0.9.2
8
+ - 3
9
+ version: 0.9.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Jihoon Kim