mirror of https://gitlab.com/bashrc2/epicyon
Set image width if it exists
parent
e13cec3bbc
commit
caafb4648c
14
content.py
14
content.py
|
@ -31,6 +31,20 @@ def removeHtmlTag(htmlStr: str, tag: str) -> str:
|
|||
return htmlStr
|
||||
|
||||
|
||||
def setHtmlTag(htmlStr: str, tag: str, value: str) -> str:
|
||||
"""Removes a given tag from a html string
|
||||
"""
|
||||
matchStr = ' ' + tag + '="'
|
||||
if matchStr not in htmlStr:
|
||||
return htmlStr
|
||||
sections = htmlStr.split(matchStr, 1)
|
||||
if '"' not in sections[1]:
|
||||
return htmlStr
|
||||
htmlStr = sections[0] + matchStr + value + '"' + \
|
||||
sections[1].split('"', 1)[1]
|
||||
return htmlStr
|
||||
|
||||
|
||||
def removeQuotesWithinQuotes(content: str) -> str:
|
||||
"""Removes any blockquote inside blockquote
|
||||
"""
|
||||
|
|
|
@ -12,6 +12,7 @@ import datetime
|
|||
from collections import OrderedDict
|
||||
from newswire import getDictFromNewswire
|
||||
from posts import createNewsPost
|
||||
from content import setHtmlTag
|
||||
from content import removeHtmlTag
|
||||
from content import dangerousMarkup
|
||||
from utils import loadJson
|
||||
|
@ -134,7 +135,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
|
|||
|
||||
# remove image dimensions
|
||||
if '<img' in rssDescription:
|
||||
rssDescription = removeHtmlTag(rssDescription, 'width')
|
||||
rssDescription = setHtmlTag(rssDescription, 'width', '10vw')
|
||||
rssDescription = removeHtmlTag(rssDescription, 'height')
|
||||
|
||||
followersOnly = False
|
||||
|
|
Loading…
Reference in New Issue