mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: add HTML replacements
This adds support for Watched Words to allow replacement with HTML content rather than always replacing with text. Can be useful when automatically replacing with the '<abbr>' tag for example. Discussion - https://meta.discourse.org/t/replace-text-with-more-than-just-links/305672
This commit is contained in:
@@ -31,12 +31,11 @@ class WordWatcher
|
||||
.where(action: WatchedWord.actions[action.to_sym])
|
||||
.limit(WatchedWord::MAX_WORDS_PER_ACTION)
|
||||
.order(:id)
|
||||
.pluck(:word, :replacement, :case_sensitive)
|
||||
.to_h do |w, r, c|
|
||||
[
|
||||
word_to_regexp(w, match_word: false),
|
||||
{ word: w, replacement: r, case_sensitive: c }.compact,
|
||||
]
|
||||
.pluck(:word, :replacement, :case_sensitive, :html)
|
||||
.to_h do |w, r, c, h|
|
||||
opts = { word: w, replacement: r, case_sensitive: c }.compact
|
||||
opts[:html] = true if h
|
||||
[word_to_regexp(w, match_word: false), opts]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user