From 2f8ac8838da4af3de8885b0b4ee88729eb9f4ca0 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Fri, 19 Jul 2019 19:28:56 -0500 Subject: [PATCH] revise tag conversion --- app/services/post_status_service.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index ea7a2c2c3..3bb580508 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -104,15 +104,13 @@ class PostStatusService < BaseService # move tags out of body so we can format them later def extract_tags - chunks = [] - @text.split(/^((?:#[\w:._·\-]+\s*)+)/).each do |chunk| - if chunk.match?(/\A#[\w:._·\-]/) - @tags |= chunk.strip.gsub('#', '').split(/\s+/) - else - chunks << chunk - end - end - @text = chunks.join + @text.gsub!(/^##/, "\uf666") + @text.gsub!('##', "\uf669") + @tags |= Extractor.extract_hashtags(@text) + @text.strip! + @text.gsub!(/^(?:#[\w:._·\-]+\s*)+|(?:#[\w:._·\-]+\s*)+\Z/, '') + @text.gsub!("\uf669", "##") + @text.gsub!("\uf666", "#") end def preprocess_attributes!