Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 065e57b

Browse files
committed
make closing tag show errors and add param format desc for color tag
1 parent b59f362 commit 065e57b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/ruby-bbcode/templates/bbcode_errors_template.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def initialize(node)
1515
@node = node
1616
@tag_definition = node.definition # tag_definition
1717
@opening_part = "[#{node[:tag]}#{node.allow_params? ? '%param%' : ''}]" + add_whitespace(node[:opening_whitespace])
18-
@opening_part = "<span class='bbcode_error' #{BBCodeErrorsTemplate.error_attribute(@node[:errors])}>#{@opening_part}</span>" unless @node[:errors].empty?
18+
@opening_part = "<span class='bbcode_error' #{BBCodeErrorsTemplate.error_attribute(@node[:errors])}>#{@opening_part.gsub('[', "&#91;").gsub(']', "&#93;")}</span>" unless @node[:errors].empty?
1919
@closing_part = "[/#{node[:tag]}]" + add_whitespace(node[:closing_whitespace])
20+
@closing_part = "<span class='bbcode_error' #{BBCodeErrorsTemplate.error_attribute(@node[:errors])}>#{@closing_part.gsub('[', "&#91;").gsub(']', "&#93;")}</span>" unless @node[:errors].empty?
2021
end
2122

2223
def self.convert_text(node, _parent_node)

lib/tags/tags.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ module Tags
114114
html_open: '<span style="color: %color%;">', html_close: '</span>',
115115
description: 'Change the color of the text',
116116
example: '[color=red]This is red[/color]',
117-
allow_quick_param: true, allow_between_as_param: false,
117+
self_closable: true, allow_quick_param: true, allow_between_as_param: false,
118118
quick_param_format: /(([a-z]+)|(#[0-9a-f]{6}))/i,
119+
quick_param_format_description: 'The parameter \'%param%\' is incorrect, a hex code or lowercase color name is expected',
119120
param_tokens: [{ token: :color }]
120121
},
121122
:youtube => {
@@ -156,5 +157,9 @@ module Tags
156157
def self.tag_list
157158
@@tags
158159
end
160+
161+
def self.add_tags(additional_tags = {})
162+
@@tags.merge(additional_tags)
163+
end
159164
end
160165
end

0 commit comments

Comments
 (0)