docs: add documentation for various classes in app/logical.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# Sanitizes the HTML used in notes. Only safe HTML tags, HTML attributes, and
|
||||
# CSS properties are allowed.
|
||||
module NoteSanitizer
|
||||
ALLOWED_ELEMENTS = %w[
|
||||
code center tn h1 h2 h3 h4 h5 h6 a span div blockquote br p ul li ol em
|
||||
@@ -50,6 +52,9 @@ module NoteSanitizer
|
||||
vertical-align
|
||||
]
|
||||
|
||||
# Sanitize a string of HTML.
|
||||
# @param text [String] the HTML to sanitize
|
||||
# @return [String] the sanitized HTML
|
||||
def self.sanitize(text)
|
||||
text.gsub!(/<( |-|3|:|>|\Z)/, "<\\1")
|
||||
|
||||
@@ -76,6 +81,8 @@ module NoteSanitizer
|
||||
)
|
||||
end
|
||||
|
||||
# Convert absolute Danbooru links inside notes to relative links.
|
||||
# https://danbooru.donmai.us/posts/1 is converted to /posts/1.
|
||||
def self.relativize_links(node:, **env)
|
||||
return unless node.name == "a" && node["href"].present?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user