lib/trainbbcode.rb in trainbbcode-0.2.4 vs lib/trainbbcode.rb in trainbbcode-0.2.5
- old
+ new
@@ -5,11 +5,11 @@
def conf(config)
require 'rubygems'
begin
require 'uv'
#UV Settings
- config[:syntax_output] ||= "html"
+ config[:syntax_output] ||= "HTML"
config[:syntax_line_numbers] ||= true
config[:syntax_theme] ||= "twilight"
rescue LoadError
config[:syntax_highlighting]=false
end
@@ -20,21 +20,17 @@
#Instanize the config variable
@config=config
end
def parse(s)
#Run the UV Parser (if enabled) to sort out any code
- unless @config[:syntax_highlighting] == false
- s=uv s
- end
+ s=uv s unless @config[:syntax_highlighting] == false
#Remove the < and > which will disable all HTML
s=s.gsub("<","<").gsub(">",">") unless @config[:disable_html] == false
#Convert new lines to <br />'s
s=s.gsub(/\n/,'<br />') unless @config[:newline_enabled] == false
#[nobbc] tags
- unless @config[:nobbc_enabled] == false
- s=nobbc s
- end
+ s=nobbc s unless @config[:nobbc_enabled] == false
#Loading Custom Tags
begin
if @config[:custom_tags] then
@config[:custom_tags].each do |tag|
s=s.gsub(tag[0],tag[1]) unless tag[2] == false
@@ -81,10 +77,17 @@
#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]]
+ [/\[acronym=(.*?)\](.*?)\[\/acronym\]/,'<acronym title="\1">\2</acronym>',@config[:acronym_enabled]],
+ #Tables
+ #Table Tag
+ [/\[table\](.*?)\[\/table\]/,'<table width="' + @config[:table_width]+ '">\1</table>',@config[:table_enabled]],
+ #Table Elements
+ [/\[tr\](.*?)\[\/tr\]/,'<tr>\1</tr>',@config[:table_enabled]],
+ [/\[td\](.*?)\[\/td\]/,'<td>\1</td>',@config[:table_enabled]],
+ [/\[th\](.*?)\[\/th\]/,'<th>\1</th>',@config[:table_enabled]]
]
end
def nobbc(s)
find=s.scan(/\[nobbc\](.*?)\[\/nobbc\]/)
find.each do |f|