From 45408c3c01a830e6bfd1941994bbeb94582a45f0 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Mon, 15 Jul 2019 13:48:37 -0500 Subject: [PATCH] revise bbcode markup --- app/lib/formatter.rb | 223 +++++++++++++++++++++++-------------------- 1 file changed, 121 insertions(+), 102 deletions(-) diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index 62047e4bd..3c6965a1b 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -31,137 +31,156 @@ class Formatter include ActionView::Helpers::TextHelper BBCODE_TAGS = { - :url => { - :html_open => '', :html_close => '', - :description => '', :example => '', - :allow_quick_param => true, :allow_between_as_param => false, - :quick_param_format => /(\S+)/, - :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', - :param_tokens => [{:token => :url}] + url: { + html_open: '', html_close: '', + description: '', example: '', + require_between: true, + allow_quick_param: true, allow_between_as_param: true, + quick_param_format: %r{^((((https?|ftps?|sftp|ircs?|telnets?|dat)://)|/).+)$}, + quick_param_format_description: '', + param_tokens: [{token: :url}] }, - :ul => { - :html_open => '', - :description => '', :example => '', + list: { + html_open: '', + description: '', example: '', + only_allow: [:li, '*'.to_sym], + block_tag: true, }, - :ol => { - :html_open => '
    ', :html_close => '
', - :description => '', :example => '', + ul: { + html_open: '', + description: '', example: '', + only_allow: [:li, '*'.to_sym], + block_tag: true, }, - :li => { - :html_open => '
  • ', :html_close => '
  • ', - :description => '', :example => '', + ol: { + html_open: '
      ', html_close: '
    ', + description: '', example: '', + only_allow: [:li, '*'.to_sym], + block_tag: true, }, - :sub => { - :html_open => '', :html_close => '', - :description => '', :example => '', + li: { + html_open: '
  • ', html_close: '
  • ', + description: '', example: '', + block_tag: true, + only_in: %i[list ul ol] }, - :sup => { - :html_open => '', :html_close => '', - :description => '', :example => '', + '*': { + html_open: '
  • ', html_close: '
  • ', + description: '', example: '', + self_closable: true, block_tag: true, + only_in: %i[list ul ol] }, - :h1 => { - :html_open => '

    ', :html_close => '

    ', - :description => '', :example => '', + sub: { + html_open: '', html_close: '', + description: '', example: '', }, - :h2 => { - :html_open => '

    ', :html_close => '

    ', - :description => '', :example => '', + sup: { + html_open: '', html_close: '', + description: '', example: '', }, - :h3 => { - :html_open => '

    ', :html_close => '

    ', - :description => '', :example => '', + h1: { + html_open: '

    ', html_close: '

    ', + description: '', example: '', }, - :h4 => { - :html_open => '

    ', :html_close => '

    ', - :description => '', :example => '', + h2: { + html_open: '

    ', html_close: '

    ', + description: '', example: '', }, - :h5 => { - :html_open => '
    ', :html_close => '
    ', - :description => '', :example => '', + h3: { + html_open: '

    ', html_close: '

    ', + description: '', example: '', }, - :h6 => { - :html_open => '
    ', :html_close => '
    ', - :description => '', :example => '', + h4: { + html_open: '

    ', html_close: '

    ', + description: '', example: '', }, - :abbr => { - :html_open => '', :html_close => '', - :description => '', :example => '', + h5: { + html_open: '
    ', html_close: '
    ', + description: '', example: '', }, - :hr => { - :html_open => '
    ', :html_close => '', - :description => '', :example => '', + h6: { + html_open: '
    ', html_close: '
    ', + description: '', example: '', }, - :b => { - :html_open => '', :html_close => '', - :description => '', :example => '', + abbr: { + html_open: '', html_close: '', + description: '', example: '', }, - :i => { - :html_open => '', :html_close => '', - :description => '', :example => '', + hr: { + html_open: '
    ', html_close: '', + description: '', example: '', }, - :flip => { - :html_open => '', :html_close => '', - :description => '', :example => '', - :allow_quick_param => true, :allow_between_as_param => false, - :quick_param_format => /(h|v)/, - :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', - :param_tokens => [{:token => :direction}] + b: { + html_open: '', html_close: '', + description: '', example: '', + }, + i: { + html_open: '', html_close: '', + description: '', example: '', + }, + flip: { + html_open: '', html_close: '', + description: '', example: '', + allow_quick_param: true, allow_between_as_param: false, + quick_param_format: /(h|v)/, + param_tokens: [{token: :direction}] }, - :size => { - :html_open => '', :html_close => '', - :description => '', :example => '', - :allow_quick_param => true, :allow_between_as_param => false, - :quick_param_format => /([1-6])/, - :quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', - :param_tokens => [{:token => :size}] + size: { + html_open: '', html_close: '', + description: '', example: '', + allow_quick_param: true, allow_between_as_param: false, + quick_param_format: /([1-6])/, + param_tokens: [{token: :size}] }, - :quote => { - :html_open => '
    ', :html_close => '
    ', - :description => '', :example => '', + quote: { + html_open: '
    ', html_close: '
    ', + description: '', example: '', + block_tag: true, }, - :kbd => { - :html_open => '
    ', :html_close => '
    ', - :description => '', :example => '', + kbd: { + html_open: '
    ', html_close: '
    ', + description: '', example: '', }, - :code => { - :html_open => '
    ', :html_close => '
    ', - :description => '', :example => '', + code: { + html_open: '
    ', html_close: '
    ', + description: '', example: '', + block_tag: true, }, - :u => { - :html_open => '', :html_close => '', - :description => '', :example => '', + u: { + html_open: '', html_close: '', + description: '', example: '', }, - :s => { - :html_open => '', :html_close => '', - :description => '', :example => '', + s: { + html_open: '', html_close: '', + description: '', example: '', }, - :del => { - :html_open => '', :html_close => '', - :description => '', :example => '', + del: { + html_open: '', html_close: '', + description: '', example: '', }, - :left => { - :html_open => '', :html_close => '', - :description => '', :example => '', + left: { + html_open: '', html_close: '', + description: '', example: '', }, - :center => { - :html_open => '', :html_close => '', - :description => '', :example => '', + center: { + html_open: '', html_close: '', + description: '', example: '', }, - :right => { - :html_open => '', :html_close => '', - :description => '', :example => '', + right: { + html_open: '', html_close: '', + description: '', example: '', }, - :lfloat => { - :html_open => '', :html_close => '', - :description => '', :example => '', + lfloat: { + html_open: '', html_close: '', + description: '', example: '', }, - :rfloat => { - :html_open => '', :html_close => '', - :description => '', :example => '', + rfloat: { + html_open: '', html_close: '', + description: '', example: '', }, - :spoiler => { - :html_open => '', :html_close => '', - :description => '', :example => '', + spoiler: { + html_open: '', html_close: '', + description: '', example: '', }, }