From 065e57bd1ffe40e52261a84908c37d2420247ad9 Mon Sep 17 00:00:00 2001 From: Hex Date: Sun, 27 Apr 2025 23:30:22 -0400 Subject: [PATCH] make closing tag show errors and add param format desc for color tag --- lib/ruby-bbcode/templates/bbcode_errors_template.rb | 3 ++- lib/tags/tags.rb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ruby-bbcode/templates/bbcode_errors_template.rb b/lib/ruby-bbcode/templates/bbcode_errors_template.rb index fd4dbfb..cec8ac4 100644 --- a/lib/ruby-bbcode/templates/bbcode_errors_template.rb +++ b/lib/ruby-bbcode/templates/bbcode_errors_template.rb @@ -15,8 +15,9 @@ def initialize(node) @node = node @tag_definition = node.definition # tag_definition @opening_part = "[#{node[:tag]}#{node.allow_params? ? '%param%' : ''}]" + add_whitespace(node[:opening_whitespace]) - @opening_part = "#{@opening_part}" unless @node[:errors].empty? + @opening_part = "#{@opening_part.gsub('[', "[").gsub(']', "]")}" unless @node[:errors].empty? @closing_part = "[/#{node[:tag]}]" + add_whitespace(node[:closing_whitespace]) + @closing_part = "#{@closing_part.gsub('[', "[").gsub(']', "]")}" unless @node[:errors].empty? end def self.convert_text(node, _parent_node) diff --git a/lib/tags/tags.rb b/lib/tags/tags.rb index 710ee3c..07d8627 100644 --- a/lib/tags/tags.rb +++ b/lib/tags/tags.rb @@ -114,8 +114,9 @@ module Tags html_open: '', html_close: '', description: 'Change the color of the text', example: '[color=red]This is red[/color]', - allow_quick_param: true, allow_between_as_param: false, + self_closable: true, allow_quick_param: true, allow_between_as_param: false, quick_param_format: /(([a-z]+)|(#[0-9a-f]{6}))/i, + quick_param_format_description: 'The parameter \'%param%\' is incorrect, a hex code or lowercase color name is expected', param_tokens: [{ token: :color }] }, :youtube => { @@ -156,5 +157,9 @@ module Tags def self.tag_list @@tags end + + def self.add_tags(additional_tags = {}) + @@tags.merge(additional_tags) + end end end