aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenadha <benawiadha@gmail.com>2021-12-18 08:52:07 +0700
committerbenadha <benawiadha@gmail.com>2021-12-18 08:52:07 +0700
commit5fdd9d185ab88bb9fc859b147b4a85b68202712d (patch)
treefeaf818af6892b231e81b6d5a7c4845ecbba6e7f
parent96e9c343b0ebad1211f6909f9f5199df44cd6730 (diff)
downloadepy-5fdd9d185ab88bb9fc859b147b4a85b68202712d.tar.gz
Fixed unavailable curses.A_ITALIC and update version
-rw-r--r--.gitignore2
-rwxr-xr-xepy.py39
-rw-r--r--setup.py2
3 files changed, 27 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 9aa4ec5..56045ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
__pycache__/*
epy_reader.egg-info/*
+.venv
+.idea
diff --git a/epy.py b/epy.py
index d4ea184..6b131b7 100755
--- a/epy.py
+++ b/epy.py
@@ -14,7 +14,7 @@ Options:
"""
-__version__ = "2021.11.12"
+__version__ = "2021.12.18"
__license__ = "GPL-3.0"
__author__ = "Benawi Adha"
__email__ = "benawiadha@gmail.com"
@@ -584,6 +584,15 @@ class HTMLtoLines(HTMLParser):
bold = {"b", "strong"}
# hide = {"script", "style", "head", ", "sub}
+ attr_bold = curses.A_BOLD
+ try:
+ attr_italic = curses.A_ITALIC
+ except AttributeError:
+ try:
+ attr_italic = curses.A_UNDERLINE
+ except AttributeError:
+ attr_italic = curses.A_NORMAL
+
def __init__(self, sects={""}):
HTMLParser.__init__(self)
self.text = [""]
@@ -774,7 +783,7 @@ class HTMLtoLines(HTMLParser):
text += [i.center(textwidth)] + [""]
formatting += [
InlineStyle(
- row=starting_line + j, col=0, n_letters=len(text[j]), attr=curses.A_BOLD
+ row=starting_line + j, col=0, n_letters=len(text[j]), attr=self.attr_bold
)
for j in range(startline, len(text))
]
@@ -797,7 +806,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + len(text) - 1,
col=0,
n_letters=len(text[-1]),
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
]
text += [""]
@@ -829,7 +838,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_start[0],
col=tmp_start[1],
n_letters=tmp_end[1] - tmp_start[1],
- attr=curses.A_ITALIC,
+ attr=self.attr_italic,
)
)
elif tmp_start[0] == tmp_end[0] - 1:
@@ -838,7 +847,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_start[0],
col=tmp_start[1],
n_letters=len(text[tmp_start[0]]) - tmp_start[1] + 1,
- attr=curses.A_ITALIC,
+ attr=self.attr_italic,
)
)
formatting.append(
@@ -846,7 +855,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_end[0],
col=0,
n_letters=tmp_end[1],
- attr=curses.A_ITALIC,
+ attr=self.attr_italic,
)
)
# elif tmp_start[0]-tmp_end[1] > 1:
@@ -856,7 +865,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_start[0],
col=tmp_start[1],
n_letters=len(text[tmp_start[0]]) - tmp_start[1] + 1,
- attr=curses.A_ITALIC,
+ attr=self.attr_italic,
)
)
for l in range(tmp_start[0] + 1, tmp_end[0]):
@@ -865,7 +874,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + l,
col=0,
n_letters=len(text[l]),
- attr=curses.A_ITALIC,
+ attr=self.attr_italic,
)
)
formatting.append(
@@ -873,7 +882,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_end[0],
col=0,
n_letters=tmp_end[1],
- attr=curses.A_ITALIC,
+ attr=self.attr_italic,
)
)
tmp_filtered = [j for j in tmpbold if j[0] == n]
@@ -899,7 +908,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_start[0],
col=tmp_start[1],
n_letters=tmp_end[1] - tmp_start[1],
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
)
elif tmp_start[0] == tmp_end[0] - 1:
@@ -908,7 +917,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_start[0],
col=tmp_start[1],
n_letters=len(text[tmp_start[0]]) - tmp_start[1] + 1,
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
)
formatting.append(
@@ -916,7 +925,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_end[0],
col=0,
n_letters=tmp_end[1],
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
)
# elif tmp_start[0]-tmp_end[1] > 1:
@@ -926,7 +935,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_start[0],
col=tmp_start[1],
n_letters=len(text[tmp_start[0]]) - tmp_start[1] + 1,
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
)
for l in range(tmp_start[0] + 1, tmp_end[0]):
@@ -935,7 +944,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + l,
col=0,
n_letters=len(text[l]),
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
)
formatting.append(
@@ -943,7 +952,7 @@ class HTMLtoLines(HTMLParser):
row=starting_line + tmp_end[0],
col=0,
n_letters=tmp_end[1],
- attr=curses.A_BOLD,
+ attr=self.attr_bold,
)
)
diff --git a/setup.py b/setup.py
index ecf1246..86a00a9 100644
--- a/setup.py
+++ b/setup.py
@@ -10,7 +10,7 @@ if sys.platform == "win32":
setup(
name="epy-reader",
- version="2021.11.12",
+ version="2021.12.18",
description="Terminal/CLI Ebook (epub, fb2, mobi, azw3) Reader",
long_description=long_description,
long_description_content_type="text/markdown",