revise bbcode markup

staging
multiple creatures 2019-07-15 13:48:37 -05:00
parent 436f7984d9
commit 45408c3c01
1 changed files with 121 additions and 102 deletions

View File

@ -31,137 +31,156 @@ class Formatter
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
BBCODE_TAGS = { BBCODE_TAGS = {
:url => { url: {
:html_open => '<a href="%url%" rel="noopener nofollow" target="_blank">', :html_close => '</a>', html_open: '<a href="%url%" rel="noopener nofollow" target="_blank">', html_close: '</a>',
:description => '', :example => '', description: '', example: '',
:allow_quick_param => true, :allow_between_as_param => false, require_between: true,
:quick_param_format => /(\S+)/, allow_quick_param: true, allow_between_as_param: true,
:quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', quick_param_format: %r{^((((https?|ftps?|sftp|ircs?|telnets?|dat)://)|/).+)$},
:param_tokens => [{:token => :url}] quick_param_format_description: '',
param_tokens: [{token: :url}]
}, },
:ul => { list: {
:html_open => '<ul>', :html_close => '</ul>', html_open: '<ul>', html_close: '</ul>',
:description => '', :example => '', description: '', example: '',
only_allow: [:li, '*'.to_sym],
block_tag: true,
}, },
:ol => { ul: {
:html_open => '<ol>', :html_close => '</ol>', html_open: '<ul>', html_close: '</ul>',
:description => '', :example => '', description: '', example: '',
only_allow: [:li, '*'.to_sym],
block_tag: true,
}, },
:li => { ol: {
:html_open => '<li>', :html_close => '</li>', html_open: '<ol>', html_close: '</ol>',
:description => '', :example => '', description: '', example: '',
only_allow: [:li, '*'.to_sym],
block_tag: true,
}, },
:sub => { li: {
:html_open => '<sub>', :html_close => '</sub>', html_open: '<li>', html_close: '</li>',
:description => '', :example => '', description: '', example: '',
block_tag: true,
only_in: %i[list ul ol]
}, },
:sup => { '*': {
:html_open => '<sup>', :html_close => '</sup>', html_open: '<li>', html_close: '</li>',
:description => '', :example => '', description: '', example: '',
self_closable: true, block_tag: true,
only_in: %i[list ul ol]
}, },
:h1 => { sub: {
:html_open => '<h1>', :html_close => '</h1>', html_open: '<sub>', html_close: '</sub>',
:description => '', :example => '', description: '', example: '',
}, },
:h2 => { sup: {
:html_open => '<h2>', :html_close => '</h2>', html_open: '<sup>', html_close: '</sup>',
:description => '', :example => '', description: '', example: '',
}, },
:h3 => { h1: {
:html_open => '<h3>', :html_close => '</h3>', html_open: '<h1>', html_close: '</h1>',
:description => '', :example => '', description: '', example: '',
}, },
:h4 => { h2: {
:html_open => '<h4>', :html_close => '</h4>', html_open: '<h2>', html_close: '</h2>',
:description => '', :example => '', description: '', example: '',
}, },
:h5 => { h3: {
:html_open => '<h5>', :html_close => '</h5>', html_open: '<h3>', html_close: '</h3>',
:description => '', :example => '', description: '', example: '',
}, },
:h6 => { h4: {
:html_open => '<h6>', :html_close => '</h6>', html_open: '<h4>', html_close: '</h4>',
:description => '', :example => '', description: '', example: '',
}, },
:abbr => { h5: {
:html_open => '<abbr>', :html_close => '</abbr>', html_open: '<h5>', html_close: '</h5>',
:description => '', :example => '', description: '', example: '',
}, },
:hr => { h6: {
:html_open => '<hr>', :html_close => '</hr>', html_open: '<h6>', html_close: '</h6>',
:description => '', :example => '', description: '', example: '',
}, },
:b => { abbr: {
:html_open => '<strong>', :html_close => '</strong>', html_open: '<abbr>', html_close: '</abbr>',
:description => '', :example => '', description: '', example: '',
}, },
:i => { hr: {
:html_open => '<em>', :html_close => '</em>', html_open: '<hr>', html_close: '</hr>',
:description => '', :example => '', description: '', example: '',
}, },
:flip => { b: {
:html_open => '<span class="bbcode__flip-%direction%">', :html_close => '</span>', html_open: '<strong>', html_close: '</strong>',
:description => '', :example => '', description: '', example: '',
:allow_quick_param => true, :allow_between_as_param => false, },
:quick_param_format => /(h|v)/, i: {
:quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', html_open: '<em>', html_close: '</em>',
:param_tokens => [{:token => :direction}] description: '', example: '',
},
flip: {
html_open: '<span class="bbcode__flip-%direction%">', html_close: '</span>',
description: '', example: '',
allow_quick_param: true, allow_between_as_param: false,
quick_param_format: /(h|v)/,
param_tokens: [{token: :direction}]
}, },
:size => { size: {
:html_open => '<span class="bbcode__size-%size%">', :html_close => '</span>', html_open: '<span class="bbcode__size-%size%">', html_close: '</span>',
:description => '', :example => '', description: '', example: '',
:allow_quick_param => true, :allow_between_as_param => false, allow_quick_param: true, allow_between_as_param: false,
:quick_param_format => /([1-6])/, quick_param_format: /([1-6])/,
:quick_param_format_description => 'The size parameter \'%param%\' is incorrect, a number is expected', param_tokens: [{token: :size}]
:param_tokens => [{:token => :size}]
}, },
:quote => { quote: {
:html_open => '<blockquote>', :html_close => '</blockquote>', html_open: '<blockquote>', html_close: '</blockquote>',
:description => '', :example => '', description: '', example: '',
block_tag: true,
}, },
:kbd => { kbd: {
:html_open => '<pre><code>', :html_close => '</code></pre>', html_open: '<pre><code>', html_close: '</code></pre>',
:description => '', :example => '', description: '', example: '',
}, },
:code => { code: {
:html_open => '<pre>', :html_close => '</pre>', html_open: '<pre>', html_close: '</pre>',
:description => '', :example => '', description: '', example: '',
block_tag: true,
}, },
:u => { u: {
:html_open => '<u>', :html_close => '</u>', html_open: '<u>', html_close: '</u>',
:description => '', :example => '', description: '', example: '',
}, },
:s => { s: {
:html_open => '<s>', :html_close => '</s>', html_open: '<s>', html_close: '</s>',
:description => '', :example => '', description: '', example: '',
}, },
:del => { del: {
:html_open => '<del>', :html_close => '</del>', html_open: '<del>', html_close: '</del>',
:description => '', :example => '', description: '', example: '',
}, },
:left => { left: {
:html_open => '<span class="bbcode__left">', :html_close => '</span>', html_open: '<span class="bbcode__left">', html_close: '</span>',
:description => '', :example => '', description: '', example: '',
}, },
:center => { center: {
:html_open => '<span class="bbcode__center">', :html_close => '</span>', html_open: '<span class="bbcode__center">', html_close: '</span>',
:description => '', :example => '', description: '', example: '',
}, },
:right => { right: {
:html_open => '<span class="bbcode__right">', :html_close => '</span>', html_open: '<span class="bbcode__right">', html_close: '</span>',
:description => '', :example => '', description: '', example: '',
}, },
:lfloat => { lfloat: {
:html_open => '<span class="bbcode__lfloat">', :html_close => '</span>', html_open: '<span class="bbcode__lfloat">', html_close: '</span>',
:description => '', :example => '', description: '', example: '',
}, },
:rfloat => { rfloat: {
:html_open => '<span class="bbcode__rfloat">', :html_close => '</span>', html_open: '<span class="bbcode__rfloat">', html_close: '</span>',
:description => '', :example => '', description: '', example: '',
}, },
:spoiler => { spoiler: {
:html_open => '<span class="bbcode__spoiler-wrapper"><span class="bbcode__spoiler">', :html_close => '</span></span>', html_open: '<span class="bbcode__spoiler-wrapper"><span class="bbcode__spoiler">', html_close: '</span></span>',
:description => '', :example => '', description: '', example: '',
}, },
} }