mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-11-03 21:37:05 +00:00 
			
		
		
		
	Mastodon: Add line breaks when new paragraphs are present on posts content
This commit is contained in:
		@@ -5,12 +5,19 @@ url_re = re.compile('<a\s*href=[\'|"](.*?)[\'"].*?>')
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class HTMLFilter(HTMLParser):
 | 
					class HTMLFilter(HTMLParser):
 | 
				
			||||||
    text = ""
 | 
					    text = ""
 | 
				
			||||||
 | 
					    first_paragraph = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def handle_data(self, data):
 | 
					    def handle_data(self, data):
 | 
				
			||||||
        self.text += data
 | 
					        self.text += data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def handle_starttag(self, tag, attrs):
 | 
					    def handle_starttag(self, tag, attrs):
 | 
				
			||||||
        if tag == "br":
 | 
					        if tag == "br":
 | 
				
			||||||
            self.text = self.text+"\n"
 | 
					            self.text = self.text+"\n"
 | 
				
			||||||
 | 
					        elif tag == "p":
 | 
				
			||||||
 | 
					            if self.first_paragraph:
 | 
				
			||||||
 | 
					                self.first_paragraph = False
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                self.text = self.text+"\n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def html_filter(data):
 | 
					def html_filter(data):
 | 
				
			||||||
    f = HTMLFilter()
 | 
					    f = HTMLFilter()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user