Browse Source

Don't clean HTML too much

tags/v0.2.0
aeris 1 year ago
parent
commit
91be33ac99
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      lib/cross-post/twitter.rb

+ 8
- 1
lib/cross-post/twitter.rb View File

@@ -31,8 +31,15 @@ class CrossPost
31 31
 			parts.each { |p| last = @client.update p, in_reply_to_status: last }
32 32
 		end
33 33
 
34
+		WHITESPACE_TAGS = {
35
+				'br'  => { before: "\n", after: '' },
36
+				'div' => { before: "\n", after: "\n" },
37
+				'p'   => { before: "\n", after: "\n" }
38
+		}.freeze
39
+
34 40
 		def post_status(status)
35
-			content = Sanitize.clean(status.content).strip
41
+			content = status.content
42
+			content = Sanitize.clean(content, whitespace_elements: WHITESPACE_TAGS).strip
36 43
 			content = CGI.unescape_html content
37 44
 			media   = status.media_attachments.collect { |f| open f.url }
38 45
 

Loading…
Cancel
Save