Skip to content

Commit

Permalink
fix bbcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirishima21 committed Feb 7, 2018
1 parent 04ce039 commit 780d6b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 4 additions & 3 deletions app/lib/formatter.rb
Expand Up @@ -33,14 +33,14 @@ def format(status, **options)


mdFormatter = Formatter_Markdown.new(html) mdFormatter = Formatter_Markdown.new(html)
html = mdFormatter.formatted html = mdFormatter.formatted

html = "RT @#{prepend_reblog} #{html}" if prepend_reblog html = "RT @#{prepend_reblog} #{html}" if prepend_reblog
html = encode_and_link_urls(html, linkable_accounts) html = encode_and_link_urls(html, linkable_accounts)
html = encode_custom_emojis(html, status.emojis) if options[:custom_emojify] html = encode_custom_emojis(html, status.emojis) if options[:custom_emojify]
html = simple_format(html, {}, sanitize: false) html = simple_format(html, {}, sanitize: false)
html = html.delete("\n") html = html.delete("\n")
html = format_bbcode(html) html = format_bbcode(html)

mdLinkDecoder = MDLinkDecoder.new(html) mdLinkDecoder = MDLinkDecoder.new(html)
html = mdLinkDecoder.decode html = mdLinkDecoder.decode


Expand Down Expand Up @@ -222,7 +222,8 @@ def link_to_hashtag(entity)


def link_html(url) def link_html(url)
url = Addressable::URI.parse(url).to_s url = Addressable::URI.parse(url).to_s
prefix = url.match(/\Ahttps?:\/\/(www\.)?/).to_s url = "#{url}" + " "
prefix = url.match(/\Ahttps?:\/\/(www\.)?+[^<>"\[\] ]\z/).to_s
text = url[prefix.length, 30] text = url[prefix.length, 30]
suffix = url[prefix.length + 30..-1] suffix = url[prefix.length + 30..-1]
cutoff = url[prefix.length..-1].length > 30 cutoff = url[prefix.length..-1].length > 30
Expand Down
8 changes: 5 additions & 3 deletions app/lib/formatter_markdown.rb
Expand Up @@ -139,10 +139,12 @@ def highlight(text)
def encode(html) def encode(html)
HTMLEntities.new.encode(html) HTMLEntities.new.encode(html)
end end
end


def encode(html) def autolink(link, link_type)
HTMLEntities.new.encode(html) links = link.gsub(/\[\//," [/")
%(#{links})
end

end end


end end
Expand Down
6 changes: 0 additions & 6 deletions app/lib/sanitize_config.rb
Expand Up @@ -14,12 +14,6 @@ module Config
next true if e =~ /^(h|p|u|dt|e)-/ # microformats classes next true if e =~ /^(h|p|u|dt|e)-/ # microformats classes
next true if e =~ /^(mention|hashtag)$/ # semantic classes next true if e =~ /^(mention|hashtag)$/ # semantic classes
next true if e =~ /^(ellipsis|invisible)$/ # link formatting classes next true if e =~ /^(ellipsis|invisible)$/ # link formatting classes
next true if e =~ /^fa$/ # font awesome
next true if e =~ /^fa-spin$/ # font awesome
next true if e =~ /^pulse-loading$/ # font awesome
next true if e =~ /^fa-flip-(horizontal|vertical)$/ # font awesome
next true if e =~ /^fa-(2x|3x|4x|5x)$/ # font awesome
# もともとreturnだったところをnextにした。 /^fa$/を含むそれより下はBBcodeなので変更いらないかも
end end


node['class'] = class_list.join(' ') node['class'] = class_list.join(' ')
Expand Down

0 comments on commit 780d6b3

Please sign in to comment.