lib/trainbbcode.rb in trainbbcode-0.2.2 vs lib/trainbbcode.rb in trainbbcode-0.2.3
- old
+ new
@@ -61,10 +61,11 @@
#Underline
[/\[u\](.*?)\[\/u\]/,'<u>\1</u>',@config[:underline_enabled]],
#Url
[/\[url\](.*?)\[\/url\]/,'<a href="\1" target="' + @config[:url_target] +'">\1</a>',@config[:url_enabled]],
[/\[url=(.*?)\](.*?)\[\/url\]/,'<a href="\1" target="' + @config[:url_target] + '">\2</a>',@config[:url_enabled]],
+ [/\[url=(.*?) target=(.*?)\](.*?)\[\/url\]/,'<a href="\1" target="\2">\3</a>',@config[:url_enabled]],
#Image
[/\[img\](.*?)\[\/img\]/,'<img src="\1" alt="'+ @config[:image_alt] + '" />',@config[:image_enabled]],
[/\[img alt=(.*?)\](.*?)\[\/img\]/,'<img src="\2" alt="\1" />',@config[:image_enabled]],
#Un-Ordered List
[/\[ul\](.*?)\[\/ul\]/,'<ul>\1</ul>',@config[:list_enabled]],
@@ -74,20 +75,25 @@
[/\[li\](.*?)\[\/li\]/,'<li>\1</li>',@config[:list_enabled]],
#Quote
[/\[quote\](.*?)\[\/quote\]/,'<blockquote>\1</blockquote>',@config[:quote_enabled]],
[/\[quote=(.*?)\](.*?)\[\/quote\]/,'<blockquote><i>Posted by <b>\1</b></i><br />\2</blockquote>',@config[:quote_enabled]],
#Color
- [/\[color=(.*?)\](.*?)\[\/color\]/,'<span style="color:\1;">\2</span>',@config[:color_enabled]]
+ [/\[color=(.*?)\](.*?)\[\/color\]/,'<span style="color:\1;">\2</span>',@config[:color_enabled]],
+ #Alignment
+ [/\[center\](.*?)\[\/center\]/,'<div style="text-align:center">\1</div>',@config[:alignment_enabled]],
+ [/\[left\](.*?)\[\/left\]/,'<div style="text-align:left">\1</div>',@config[:alignment_enabled]],
+ [/\[right\](.*?)\[\/right\]/,'<div style="text-align:right">\1</div>',@config[:alignment_enabled]],
+ #Acronym
+ [/\[acronym=(.*?)\](.*?)\[\/acronym\]/,'<acronym title="\1">\2</acronym>',@config[:acronym_enabled]]
]
end
def nobbc(s)
find=s.scan(/\[nobbc\](.*?)\[\/nobbc\]/)
find.each do |f|
replace=f[0].gsub("[","[").gsub("]","]")
- s=s.gsub(f[0],replace)
+ s=s.gsub("[nobbc]#{f[0]}[/nobbc]",replace)
end
- s=s.gsub("[nobbc]","").gsub("[/nobbc]","")
return s
end
def css
output="<style type=\"text/css\">
blockquote{
@@ -97,20 +103,22 @@
output+=Uv.themes.map{|theme| %Q(<link rel="stylesheet" type="text/css" href="css/#{theme}.css" />\n)}
return output
end
def uv(s)
find=s.scan(/\[code lang=(.*?)\](.*?)\[\/code\]/)
- finde.each do |f|
+ find.each do |f|
+ #parse=nobbc "[nobbc]" + f[1] + "[/nobbc]"
r=Uv.parse(f[1], @config[:syntax_output], f[0], @config[:syntax_line_numbers], @config[:syntax_theme])
end
s=s.gsub(/\[code lang=(.*?)\]/,'').gsub("[/code]",'')
return s
end
end
#Add .tbbc to Strings
class String
- def tbbc
+ def tbbc(conf = nil)
bbc=TBBC.new
+ bbc.conf(conf) if conf
bbc.parse(self)
end
end