parent
dae29f9fd6
commit
788b8bf39a
@ -1,7 +1,29 @@
|
||||
from inscriptis import get_text
|
||||
import os
|
||||
|
||||
|
||||
class Article:
|
||||
def __init__(self, articleObj):
|
||||
self.text = get_text(articleObj["summary"]["content"])
|
||||
self.title = articleObj["title"]
|
||||
terminal_width, terminal_height = os.get_terminal_size()
|
||||
terminal_width -= 60
|
||||
start_of_chunk = 0
|
||||
end_of_chunk = 0
|
||||
rows_passed = 0
|
||||
self.chunks = []
|
||||
i = 0
|
||||
column_position = 0
|
||||
for s in self.text:
|
||||
i += 1
|
||||
column_position += 1
|
||||
if column_position > terminal_width or s == "\n":
|
||||
rows_passed += 1
|
||||
column_position = 0
|
||||
if rows_passed > terminal_height - 2:
|
||||
end_of_chunk = i
|
||||
self.chunks.append(self.text[start_of_chunk:end_of_chunk])
|
||||
start_of_chunk = end_of_chunk
|
||||
rows_passed = 0
|
||||
if end_of_chunk <= i:
|
||||
self.chunks.append(self.text[start_of_chunk:i])
|
||||
|
||||
Loading…
Reference in new issue