Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing words on long lines for Chinese language. #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions epr.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import sys
import re
import os
import textwrap
from rich import cells
import json
import tempfile
import shutil
Expand Down Expand Up @@ -319,18 +319,18 @@ def get_lines(self, width=0):
if n in self.idhead:
text += [i.rjust(width//2 + len(i)//2)] + [""]
elif n in self.idinde:
text += [" "+j for j in textwrap.wrap(i, width - 3)] + [""]
text += [" "+j for j in cells.chop_cells(i, width - 3)] + [""]
elif n in self.idbull:
tmp = textwrap.wrap(i, width - 3)
tmp = cells.chop_cells(i, width - 3)
text += [" - "+j if j == tmp[0] else " "+j for j in tmp] + [""]
elif n in self.idpref:
tmp = i.splitlines()
wraptmp = []
for line in tmp:
wraptmp += [j for j in textwrap.wrap(line, width - 6)]
wraptmp += [j for j in cells.chop_cells(line, width - 6)]
text += [" "+j for j in wraptmp] + [""]
else:
text += textwrap.wrap(i, width) + [""]
text += cells.chop_cells(i, width) + [""]
return text, self.imgs


Expand Down Expand Up @@ -504,7 +504,7 @@ def meta(stdscr, ebook):
for i in ebook.get_meta():
data = re.sub("<[^>]*>", "", i[1])
data = re.sub("\t", "", data)
mdata += textwrap.wrap(i[0].upper() + ": " + data, wi - 6)
mdata += cells.chop_cells(i[0].upper() + ": " + data, wi - 6)
src_lines = mdata
totlines = len(src_lines)

Expand Down