use html unescape instead of implementing it ourselves
This commit is contained in:
parent
ca1cd780a3
commit
10a576838b
16
offpunk.py
16
offpunk.py
|
@ -44,6 +44,7 @@ import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import html
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import setproctitle
|
import setproctitle
|
||||||
|
@ -78,9 +79,18 @@ def term_width():
|
||||||
width = cur
|
width = cur
|
||||||
return width
|
return width
|
||||||
|
|
||||||
|
def test_wrap_method(line,width, initial_indent="", subsequent_indent=""):
|
||||||
|
#TODO : implement indents
|
||||||
|
lines = []
|
||||||
|
while len(line) > width:
|
||||||
|
lines.append(line[:width])
|
||||||
|
line = line[width:]
|
||||||
|
lines.append(line)
|
||||||
|
return lines
|
||||||
|
#ansi = ansiwrap.wrap(line,width,initial_indent=initial_indent,subsequent_indent=subsequent_indent)
|
||||||
|
#return ansi
|
||||||
# return wrapped text as a list of lines
|
# return wrapped text as a list of lines
|
||||||
def wraplines(*args,**kwargs):
|
def wraplines(*args,**kwargs):
|
||||||
# print("will wrap with %s and %s"%(str(args),str(kwargs)))
|
|
||||||
if "center" in kwargs:
|
if "center" in kwargs:
|
||||||
center = kwargs.pop("center")
|
center = kwargs.pop("center")
|
||||||
else:
|
else:
|
||||||
|
@ -96,7 +106,6 @@ def wraplines(*args,**kwargs):
|
||||||
margin = 0
|
margin = 0
|
||||||
for l in lines :
|
for l in lines :
|
||||||
lines2.append(margin*" "+l)
|
lines2.append(margin*" "+l)
|
||||||
#line = 30*" " + line
|
|
||||||
return lines2
|
return lines2
|
||||||
# return wrapped text as one string
|
# return wrapped text as one string
|
||||||
def wrapparagraph(*args,**kwargs):
|
def wrapparagraph(*args,**kwargs):
|
||||||
|
@ -787,8 +796,7 @@ class HtmlRenderer(AbstractRenderer):
|
||||||
toreturn = string.replace("\n", " ").replace("\t"," ").strip()
|
toreturn = string.replace("\n", " ").replace("\t"," ").strip()
|
||||||
while " " in toreturn:
|
while " " in toreturn:
|
||||||
toreturn = toreturn.replace(" "," ")
|
toreturn = toreturn.replace(" "," ")
|
||||||
toreturn = toreturn.replace(" ","\xa0").replace(" ","\xa0")
|
toreturn = html.unescape(toreturn)
|
||||||
toreturn = toreturn.replace("…","\u2026").replace("&mldr","\u2026")
|
|
||||||
if endspace and not toreturn.endswith(" ") and not toreturn.endswith("\xa0"):
|
if endspace and not toreturn.endswith(" ") and not toreturn.endswith("\xa0"):
|
||||||
toreturn += " "
|
toreturn += " "
|
||||||
if startspace and not toreturn.startswith(" ") and not toreturn.startswith("\xa0"):
|
if startspace and not toreturn.startswith(" ") and not toreturn.startswith("\xa0"):
|
||||||
|
|
Loading…
Reference in New Issue