intellireading-cli 2.0.0__tar.gz → 2.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,387 @@
1
+ Metadata-Version: 2.4
2
+ Name: intellireading-cli
3
+ Version: 2.1.1
4
+ Summary: Intellireading-cli is a Python library with a set of tools to improve your reading experience
5
+ Project-URL: Documentation, https://go.hugobatista.com/gh/intellireading-cli#readme
6
+ Project-URL: Issues, https://go.hugobatista.com/gh/intellireading-cli/issues
7
+ Project-URL: Source, https://go.hugobatista.com/gh/intellireading-cli
8
+ Project-URL: Homepage, https://go.hugobatista.com/gh/intellireading-cli
9
+ Project-URL: Repository, https://go.hugobatista.com/gh/intellireading-cli.git
10
+ Author: Hugo Batista <intellireading at hugobatista.com>
11
+ License-Expression: GPL-3.0
12
+ License-File: LICENSE
13
+ Keywords: adhd,calibre,dyslexia,ebook,epub,kepub,kindle,kobo,speed-reading
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Education
17
+ Classifier: Intended Audience :: End Users/Desktop
18
+ Classifier: Intended Audience :: Information Technology
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Intended Audience :: System Administrators
21
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: Implementation :: CPython
26
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
27
+ Classifier: Topic :: Education :: Computer Aided Instruction (CAI)
28
+ Classifier: Topic :: Software Development
29
+ Classifier: Topic :: Text Processing :: Markup :: XML
30
+ Classifier: Topic :: Utilities
31
+ Requires-Python: >=3.13
32
+ Requires-Dist: click>=8.1.7
33
+ Requires-Dist: lxml>=4.9.2
34
+ Requires-Dist: regex>=2024.11.6
35
+ Description-Content-Type: text/markdown
36
+
37
+ ![Intellireading.com](https://go.hugobatista.com/ghraw/intellireading-www/main/public/img/intellireading.png)
38
+ # Standalone tool and library
39
+
40
+ [![PyPI - Version](https://img.shields.io/pypi/v/intellireading-cli.svg)](https://pypi.org/project/intellireading-cli)
41
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/intellireading-cli.svg)](https://pypi.org/project/intellireading-cli)
42
+ [![Deploy to ghcr.io](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/build-and-publish-to-ghcr.yml/badge.svg)](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/build-and-publish-to-ghcr.yml)
43
+ [![Lint](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/lint.yml/badge.svg)](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/lint.yml)
44
+ [![Test](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/test.yml/badge.svg)](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/test.yml)
45
+ [![GitMCP](https://img.shields.io/endpoint?url=https://gitmcp.io/badge/hugobatista/intellireading-cli)](https://gitmcp.io/hugobatista/intellireading-cli)
46
+
47
+ Intellireading is a CLI tool with commands to accelerate your reading experience. It can also be used as a Python library.
48
+ Currently, it supports metaguiding an EPUB, KEPUB, XHTML, or HTML file (more features coming):
49
+ ```console
50
+ > intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub
51
+ ```
52
+ Example of a text converted to a metaguided text:
53
+ ![Intellireading.com](https://go.hugobatista.com/ghraw/intellireading-www/main/public/img/sample.png)
54
+
55
+
56
+ This repo is part of the [Intellireading](https://intellireading.com/) project, which aims to help people with dyslexia, ADHD, or anyone who wants to improve their reading focus and speed.
57
+
58
+ ## [Other Intellireading Code Repositories](https://go.hugobatista.com/ghstars/lists/intellireading)
59
+ - [Intellireading website](https://go.hugobatista.com/gh/intellireading-www), which allows anyone to convert an Epub to the metaguided version.
60
+ - [API Server](https://go.hugobatista.com/gh/intellireading-api_server), that support the Intellireading website.
61
+ - [CLI Tool](https://go.hugobatista.com/gh/intellireading-cli). A standalone tool and library that can be used to metaguide epub files.
62
+ - [Calibre Plugins](https://go.hugobatista.com/gh/intellireading-calibre-plugins). A set of plugins that can be used to metaguide epub files using Calibre.
63
+
64
+
65
+ ## What is EPUB Metaguiding?
66
+ **Metagu**iding **i**s **a** **techn**ique **th**at **ca**n **b**e **us**ed **t**o **impr**ove **yo**ur **read**ing **foc**us **an**d **spe**ed **(some**times **cal**led **Bio**nic **Readi**ng). **I**t **i**s **bas**ed **o**n **th**e **id**ea **th**at **yo**u **ca**n **us**e **a** **vis**ual **gui**de **t**o **he**lp **yo**ur **ey**es **foc**us **o**n **th**e **te**xt **yo**u **ar**e **read**ing. **I**n **th**is **cas**e, **th**e **vis**ual **gui**de **i**s **do**ne **b**y **bold**ing **a** **pa**rt **o**f **th**e **tex**t, **crea**ting **vis**ual **anch**ors **th**at **yo**ur **ey**es **ca**n **us**e **t**o **foc**us **o**n **th**e **tex**t. **Th**is **i**s **simi**lar **t**o **th**e **wa**y **a** **fin**ger **ca**n **b**e **us**ed **t**o **gui**de **yo**ur **ey**es **alo**ng **a** **li**ne **o**f **tex**t, **whi**ch **ha**s **be**en **sho**wn **t**o **impr**ove **read**ing **spe**ed **an**d **foc**us. ([**stu**dy: **"Do**es **finger-t**racking **poi**nt **t**o **chi**ld **read**ing **strate**gies"](https://ceur-ws.org/Vol-2769/paper_60.pdf))
67
+
68
+ **Howe**ver, **unl**ike **a** **fing**er, **th**e **vis**ual **gui**de **i**s **no**t **distra**cting, **an**d **i**t **ca**n **b**e **us**ed **t**o **gui**de **yo**ur **ey**es **alo**ng **mult**iple **lin**es **o**f **te**xt **a**t **onc**e. **Th**is **all**ows **yo**u **t**o **re**ad **fast**er, **an**d **wi**th **le**ss **effo**rt.
69
+
70
+ **Metagu**iding **i**s **partic**ulary **use**ful **fo**r **peo**ple **wi**th **dysl**exia **o**r **ADH**D, **bu**t **i**t **ca**n **b**e **us**ed **b**y **any**one **wh**o **wan**ts **t**o **impr**ove **the**ir **read**ing **foc**us **an**d **spe**ed. **Fo**r **mo**re **inform**ation, **vis**it **th**e [**Intelli**reading **webs**ite.](https://intellireading.com/)
71
+
72
+ ## Features
73
+
74
+ Intellireading commands can be used to:
75
+ - **Metaguide an EPUB file**: Metaguide an EPUB file, transforming it into a metaguided EPUB file, by transforming all XHTML files in the EPUB file into metaguided XHTML files.
76
+ - **Metaguide an XHTML file**: Metaguide an XHTML file, transforming it into a metaguided XHTML file.
77
+ - **Metaguide a directory**: Metaguide all files in a directory, transforming all EPUB, XHTML, and HTML files into metaguided files.
78
+
79
+ ## Installation
80
+
81
+ Intellireading is a command line tool that can be used in Windows, Linux, and MacOS. It is written in Python and can be used as a module or as a standalone tool, as long as you have Python >3.7 installed (or Docker).
82
+
83
+ ### pip
84
+ To install it, you can use pip:
85
+ ```console
86
+ > pip install intellireading-cli
87
+ > intellireading --help
88
+ ```
89
+
90
+ ### From source code
91
+ You can also install it from the source code:
92
+ ```console
93
+ > git clone https://go.hugobatista.com/gh/intellireading-cli.git
94
+ > cd intellireading-cli
95
+ > pip install .
96
+ > intellireading --help
97
+ ```
98
+
99
+ ### Docker
100
+ Alternatively, you can use the Docker image:
101
+
102
+ #### Help command
103
+ ```console
104
+ > docker pull ghcr.io/hugobatista/intellireading-cli:latest
105
+ > docker run -it --rm ghcr.io/hugobatista/intellireading-cli --help
106
+ ```
107
+
108
+ #### Metaguide an EPUB file
109
+ ##### Linux/MacOS
110
+ ```console
111
+ > docker run -it --rm -v $(pwd)/tests:/tests ghcr.io/hugobatista/intellireading-cli metaguide-epub --input_file '/tests/test_files/input.epub' --output_file '/tests/test_files/output.epub'
112
+ ```
113
+ ##### Windows
114
+ ```powershell
115
+ > docker run -it --rm -v ${pwd}/tests:/tests ghcr.io/hugobatista/intellireading-cli metaguide-epub --input_file '/tests/test_files/input.epub' --output_file '/tests/test_files/output.epub'
116
+ ```
117
+
118
+ ## CLI Usage
119
+
120
+ All available commands and options can be seen by using the `--help` option.
121
+ ```console
122
+ > intellireading --help
123
+ ```
124
+
125
+ To get help on a specific command, use the `--help` option with the command name. For example, to get help on the `metaguide-epub` command, use the following command:
126
+ ```console
127
+ > intellireading metaguide-epub --help
128
+ ```
129
+
130
+ Intellireading is based on [Click](https://github.com/pallets/click/), taking advantage of its features, such as chaining commands and options.
131
+
132
+ ### CLI Examples
133
+
134
+ #### Metaguide an EPUB file
135
+ To metaguide an EPUB file, use the `metaguide-epub` command. The command requires the path to the EPUB file and the output file. The output file will be a metaguided epub file.
136
+
137
+ ```console
138
+ > intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub
139
+ ```
140
+
141
+ #### Metaguide a XHTML file
142
+ To metaguide an XHTML file, use the `metaguide-xhtml` command. The command requires the path to the XHTML file and the output file. The output file will be a metaguided xhtml file.
143
+
144
+ ```console
145
+ > intellireading metaguide-xhtml --input_file mybook.xhtml --output_file mybook_metaguided.xhtml
146
+ ```
147
+
148
+ #### Metaguide all files in a directory
149
+ To metaguide all files in a directory, use the `metaguide-dir` command. The command requires the path to the directory and the output directory. The output directory will contain all metaguided files, including epub, xhtml and html files.
150
+
151
+ ```console
152
+ > intellireading metaguide-dir --input_dir mydir --output_dir mydir_metaguided
153
+ ```
154
+
155
+ ## Experimental Features
156
+ Some features are still experimental and may not work as expected. Use them with caution.
157
+
158
+ ### Remove metaguiding
159
+ The remove metaguiding feature allows you to remove metaguiding from previous metaguided files. This implementation is still experimental and may not work as expected, since it is not possible to recover the original text. The current implementation tries to remove the metaguiding by removing the bold tags from the text, but that may imply in some original text format loss.
160
+
161
+ #### Remove metaguiding from an EPUB file
162
+ To remove metaguiding from an EPUB file, use the --remove_metaguiding flag. The command requires the path to the EPUB file and the output file. The output file will be an epub file without metaguiding.
163
+
164
+ ```console
165
+ > intellireading metaguide-epub --remove_metaguiding --input_file mybook_metaguided.epub --output_file mybook.epub
166
+ ```
167
+
168
+ #### Remove metaguiding from a XHTML file
169
+ To remove metaguiding from a XHTML file, use the --remove_metaguiding flag. The command requires the path to the XHTML file and the output file. The output file will be an xhtml file without metaguiding.
170
+
171
+ ```console
172
+ > intellireading metaguide-xhtml --remove_metaguiding --input_file mybook_metaguided.xhtml --output_file mybook.xhtml
173
+ ```
174
+
175
+ #### Remove metaguiding from all files in a directory
176
+ To remove metaguiding from all files in a directory, use the --remove_metaguiding flag. The command requires the path to the directory and the output directory. The output directory will contain all files without metaguiding, including epub, xhtml and html files.
177
+
178
+ ```console
179
+ > intellireading metaguide-dir --remove_metaguiding --input_dir mydir_metaguided --output_dir mydir
180
+ ```
181
+
182
+ ## Python Library API
183
+
184
+ The intellireading-cli package can be used as a Python library for programmatic access to metaguiding functionality. This is useful for integrating metaguiding into web applications, batch processing scripts, or other Python projects.
185
+
186
+ ### Quick Start
187
+
188
+ ```python
189
+ from intellireading.client import (
190
+ metaguide_epub_file,
191
+ metaguide_xhtml_file,
192
+ metaguide_epub_stream,
193
+ metaguide_xhtml_stream,
194
+ metaguide_dir,
195
+ is_file_metaguided
196
+ )
197
+
198
+ # Metaguide an EPUB file
199
+ metaguide_epub_file("input.epub", "output.epub")
200
+
201
+ # Metaguide an XHTML file
202
+ metaguide_xhtml_file("input.html", "output.html")
203
+ ```
204
+
205
+ ### Core Functions
206
+
207
+ #### EPUB Functions
208
+
209
+ **`metaguide_epub_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False)`**
210
+
211
+ Metaguides an EPUB file by applying visual anchoring to text content within all XHTML files in the EPUB.
212
+
213
+ ```python
214
+ from intellireading.client import metaguide_epub_file
215
+
216
+ # Basic metaguiding
217
+ metaguide_epub_file("mybook.epub", "mybook_metaguided.epub")
218
+
219
+ # Remove metaguiding (experimental)
220
+ metaguide_epub_file(
221
+ "mybook_metaguided.epub",
222
+ "mybook_original.epub",
223
+ remove_metaguiding=True
224
+ )
225
+ ```
226
+
227
+ **`metaguide_epub_stream(input_stream: BytesIO, *, remove_metaguiding: bool = False) -> BytesIO`**
228
+
229
+ Metaguides an EPUB from a byte stream, useful for in-memory processing or web applications.
230
+
231
+ ```python
232
+ from io import BytesIO
233
+ from intellireading.client import metaguide_epub_stream
234
+
235
+ # Read EPUB into memory
236
+ with open("input.epub", "rb") as f:
237
+ input_stream = BytesIO(f.read())
238
+
239
+ # Metaguide the stream
240
+ output_stream = metaguide_epub_stream(input_stream)
241
+
242
+ # Write to file
243
+ with open("output.epub", "wb") as f:
244
+ f.write(output_stream.read())
245
+ ```
246
+
247
+ #### XHTML Functions
248
+
249
+ **`metaguide_xhtml_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False)`**
250
+
251
+ Metaguides an XHTML/HTML file by applying visual anchoring to text content. Supports `.xhtml`, `.html`, and `.htm` files.
252
+
253
+ ```python
254
+ from intellireading.client import metaguide_xhtml_file
255
+
256
+ # Metaguide an HTML file
257
+ metaguide_xhtml_file("article.html", "article_metaguided.html")
258
+
259
+ # Remove metaguiding
260
+ metaguide_xhtml_file(
261
+ "article_metaguided.html",
262
+ "article_restored.html",
263
+ remove_metaguiding=True
264
+ )
265
+ ```
266
+
267
+ **`metaguide_xhtml_stream(input_file_stream: BytesIO, *, remove_metaguiding: bool = False) -> BytesIO`**
268
+
269
+ Metaguides an XHTML/HTML file from a byte stream.
270
+
271
+ ```python
272
+ from io import BytesIO
273
+ from intellireading.client import metaguide_xhtml_stream
274
+
275
+ # Process HTML content from string
276
+ html_content = """
277
+ <!DOCTYPE html>
278
+ <html>
279
+ <body>
280
+ <p>This is a sample paragraph that will be metaguided.</p>
281
+ </body>
282
+ </html>
283
+ """
284
+
285
+ input_stream = BytesIO(html_content.encode('utf-8'))
286
+ output_stream = metaguide_xhtml_stream(input_stream)
287
+ metaguided_content = output_stream.read().decode('utf-8')
288
+ ```
289
+
290
+ #### Directory Functions
291
+
292
+ **`metaguide_dir(input_dir: str, output_dir: str, *, remove_metaguiding: bool = False)`**
293
+
294
+ Metaguides all EPUB and XHTML/HTML files found in a directory recursively.
295
+
296
+ ```python
297
+ from intellireading.client import metaguide_dir
298
+
299
+ # Metaguide all books in the directory
300
+ metaguide_dir("books", "books_metaguided")
301
+
302
+ # Remove metaguiding from all files
303
+ metaguide_dir("books_metaguided", "books_restored", remove_metaguiding=True)
304
+ ```
305
+
306
+ #### Utility Functions
307
+
308
+ **`is_file_metaguided(filepath: str) -> bool`**
309
+
310
+ Checks if an EPUB file has already been metaguided.
311
+
312
+ ```python
313
+ from intellireading.client import is_file_metaguided, metaguide_epub_file
314
+
315
+ # Check if file is already metaguided
316
+ if not is_file_metaguided("mybook.epub"):
317
+ metaguide_epub_file("mybook.epub", "mybook_metaguided.epub")
318
+ print("File metaguided successfully")
319
+ else:
320
+ print("File is already metaguided")
321
+ ```
322
+
323
+ ### Integration Examples
324
+
325
+ #### Web Application (Flask)
326
+
327
+ ```python
328
+ from flask import Flask, request, send_file
329
+ from io import BytesIO
330
+ from intellireading.client import metaguide_epub_stream
331
+
332
+ app = Flask(__name__)
333
+
334
+ @app.route('/metaguide', methods=['POST'])
335
+ def metaguide_upload():
336
+ file = request.files['epub']
337
+ if file and file.filename.endswith('.epub'):
338
+ input_stream = BytesIO(file.read())
339
+ output_stream = metaguide_epub_stream(input_stream)
340
+
341
+ return send_file(
342
+ output_stream,
343
+ as_attachment=True,
344
+ download_name=f"metaguided_{file.filename}",
345
+ mimetype='application/epub+zip'
346
+ )
347
+ return "Invalid file", 400
348
+ ```
349
+
350
+ #### Batch Processing
351
+
352
+ ```python
353
+ import os
354
+ from intellireading.client import metaguide_dir, is_file_metaguided
355
+
356
+ def batch_process_library(library_path):
357
+ """Process an entire library of EPUB files"""
358
+ processed_path = os.path.join(library_path, "metaguided")
359
+
360
+ # Process all files
361
+ metaguide_dir(library_path, processed_path)
362
+
363
+ # Verify results
364
+ for root, dirs, files in os.walk(processed_path):
365
+ for file in files:
366
+ if file.endswith('.epub'):
367
+ filepath = os.path.join(root, file)
368
+ if is_file_metaguided(filepath):
369
+ print(f"✓ Successfully metaguided: {file}")
370
+
371
+ batch_process_library("/path/to/my/books")
372
+ ```
373
+
374
+ ### Error Handling
375
+
376
+ ```python
377
+ from intellireading.client import metaguide_epub_file
378
+
379
+ try:
380
+ metaguide_epub_file("mybook.epub", "output.epub")
381
+ except ValueError as e:
382
+ print(f"Invalid file: {e}")
383
+ except FileNotFoundError as e:
384
+ print(f"File not found: {e}")
385
+ except Exception as e:
386
+ print(f"Unexpected error: {e}")
387
+ ```