mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:41:03 +08:00
DEV: Apply syntax_tree formatting to script/*
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'uri'
|
||||
require "uri"
|
||||
|
||||
class CreateTitle
|
||||
|
||||
def self.from_body(body)
|
||||
title = remove_mentions body
|
||||
title = remove_urls title
|
||||
@ -24,11 +23,11 @@ class CreateTitle
|
||||
private
|
||||
|
||||
def self.remove_mentions(text)
|
||||
text.gsub(/@[\w]*/, '')
|
||||
text.gsub(/@[\w]*/, "")
|
||||
end
|
||||
|
||||
def self.remove_urls(text)
|
||||
text.gsub(URI::regexp(['http', 'https', 'mailto', 'ftp', 'ldap', 'ldaps']), '')
|
||||
text.gsub(URI.regexp(%w[http https mailto ftp ldap ldaps]), "")
|
||||
end
|
||||
|
||||
def self.remove_stray_punctuation(text)
|
||||
@ -42,7 +41,7 @@ class CreateTitle
|
||||
end
|
||||
|
||||
def self.complete_sentences(text)
|
||||
/(^.*[\S]{2,}[.!?:]+)\W/.match(text[0...80] + ' ')
|
||||
/(^.*[\S]{2,}[.!?:]+)\W/.match(text[0...80] + " ")
|
||||
end
|
||||
|
||||
def self.complete_words(text)
|
||||
|
Reference in New Issue
Block a user