intellireading-cli 2.1.1__tar.gz → 2.2.0__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.
- intellireading_cli-2.2.0/.gitignore +21 -0
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0}/PKG-INFO +100 -28
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0}/README.md +98 -26
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0}/pyproject.toml +71 -51
- intellireading_cli-2.2.0/src/intellireading/__init__.py +0 -0
- intellireading_cli-2.2.0/src/intellireading/client/__about_cli__.py +1 -0
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0/src}/intellireading/client/__init__.py +6 -0
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0/src}/intellireading/client/app.py +4 -2
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0/src}/intellireading/client/commands.py +126 -11
- intellireading_cli-2.2.0/src/intellireading/client/metaguiding.py +1428 -0
- intellireading_cli-2.1.1/.gitignore +0 -8
- intellireading_cli-2.1.1/intellireading/client/__about_cli__.py +0 -1
- intellireading_cli-2.1.1/intellireading/client/metaguiding.py +0 -523
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0}/LICENSE +0 -0
- {intellireading_cli-2.1.1 → intellireading_cli-2.2.0/src}/intellireading/client/__main__.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
.venv/
|
|
5
|
+
*.json
|
|
6
|
+
!renovate.json
|
|
7
|
+
.debug
|
|
8
|
+
.coverage
|
|
9
|
+
coverage/
|
|
10
|
+
coverage.xml
|
|
11
|
+
htmlcov/
|
|
12
|
+
dist/
|
|
13
|
+
build/
|
|
14
|
+
*.egg-info/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
.ruff_cache/
|
|
18
|
+
app/
|
|
19
|
+
.env
|
|
20
|
+
tests/test_files/output
|
|
21
|
+
bin/act
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: intellireading-cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Intellireading-cli is a Python library with a set of tools to improve your reading experience
|
|
5
5
|
Project-URL: Documentation, https://go.hugobatista.com/gh/intellireading-cli#readme
|
|
6
6
|
Project-URL: Issues, https://go.hugobatista.com/gh/intellireading-cli/issues
|
|
@@ -42,6 +42,7 @@ Description-Content-Type: text/markdown
|
|
|
42
42
|
[](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/build-and-publish-to-ghcr.yml)
|
|
43
43
|
[](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/lint.yml)
|
|
44
44
|
[](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/test.yml)
|
|
45
|
+
[](https://docs.renovatebot.com)
|
|
45
46
|
[](https://gitmcp.io/hugobatista/intellireading-cli)
|
|
46
47
|
|
|
47
48
|
Intellireading is a CLI tool with commands to accelerate your reading experience. It can also be used as a Python library.
|
|
@@ -152,6 +153,54 @@ To metaguide all files in a directory, use the `metaguide-dir` command. The comm
|
|
|
152
153
|
> intellireading metaguide-dir --input_dir mydir --output_dir mydir_metaguided
|
|
153
154
|
```
|
|
154
155
|
|
|
156
|
+
#### Control the fixation level
|
|
157
|
+
The `--fixation` option controls how much of each word is bolded. It accepts values from `1` (least bold) to `5` (most bold) and defaults to `3`, which is the historical behaviour of IntelliReading.
|
|
158
|
+
|
|
159
|
+
The option is available on `metaguide-epub`, `metaguide-xhtml`, and `metaguide-dir`:
|
|
160
|
+
|
|
161
|
+
```console
|
|
162
|
+
> intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub --fixation 5
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The public contract is the range `1`–`5`, the default `3`, and the fact that higher levels never bold less of each word (and usually bold more). The exact split point for each word is an implementation detail and may change.
|
|
166
|
+
|
|
167
|
+
The fixation level only applies to new conversions. EPUB files that are already metaguided are copied unchanged. To apply a different level to an already metaguided EPUB, use `--remove_metaguiding` first and then metaguide the result again. Standalone XHTML files have no metaguided marker, so avoid running metaguiding twice on the same XHTML file.
|
|
168
|
+
|
|
169
|
+
#### Control the bold style
|
|
170
|
+
The `--bold_style` option controls how the bold part of each word is rendered. It accepts:
|
|
171
|
+
|
|
172
|
+
- `tag` (default) — uses `<b>` and the font's real bold face;
|
|
173
|
+
- `shadow` — uses `<b class="ir-bold">` plus a CSS `text-shadow`, which keeps the original font metrics;
|
|
174
|
+
- `stroke` — uses `<b class="ir-bold">` plus a CSS `-webkit-text-stroke`, which also keeps the original font metrics.
|
|
175
|
+
|
|
176
|
+
The visual modes (`shadow` and `stroke`) are intended for Kobo kepubs and other WebKit-based readers. They avoid the page count changes that real bold can cause on Kobo, because the text keeps the same width and line breaks. On readers that do not support those CSS properties, the text may render without emphasis; use `tag` for maximum compatibility.
|
|
177
|
+
|
|
178
|
+
The option is available on `metaguide-epub`, `metaguide-xhtml`, and `metaguide-dir`:
|
|
179
|
+
|
|
180
|
+
```console
|
|
181
|
+
> intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub --bold_style shadow
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Control the bold intensity
|
|
185
|
+
The `--bold_intensity` option controls how strong the visual bold effect is when `--bold_style` is `shadow` or `stroke`. It accepts values from `1` (subtle) to `5` (strongest) and defaults to `3`.
|
|
186
|
+
|
|
187
|
+
```console
|
|
188
|
+
> intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub --bold_style shadow --bold_intensity 5
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The intensity only affects the visual modes. With `--bold_style tag` the option is ignored, because the real bold face is used.
|
|
192
|
+
|
|
193
|
+
#### What gets metaguided
|
|
194
|
+
Metaguiding only changes prose text inside the document body. The following content is preserved byte-for-byte:
|
|
195
|
+
|
|
196
|
+
- `<style>` and `<script>` elements (CSS and JavaScript)
|
|
197
|
+
- `<pre>` and `<code>` elements (preformatted text and code samples)
|
|
198
|
+
- `<text>` and `<tspan>` elements in SVG
|
|
199
|
+
- CDATA sections
|
|
200
|
+
- HTML comments
|
|
201
|
+
|
|
202
|
+
This keeps stylesheets, scripts and embedded SVG content valid. Elements that are not listed above (for example MathML text elements or `<textarea>`) are still metaguided, so bold tags may be inserted into them. Removal of metaguiding keeps its previous behaviour and can still clean up bold tags added to these regions by older versions.
|
|
203
|
+
|
|
155
204
|
## Experimental Features
|
|
156
205
|
Some features are still experimental and may not work as expected. Use them with caution.
|
|
157
206
|
|
|
@@ -192,7 +241,7 @@ from intellireading.client import (
|
|
|
192
241
|
metaguide_epub_stream,
|
|
193
242
|
metaguide_xhtml_stream,
|
|
194
243
|
metaguide_dir,
|
|
195
|
-
is_file_metaguided
|
|
244
|
+
is_file_metaguided,
|
|
196
245
|
)
|
|
197
246
|
|
|
198
247
|
# Metaguide an EPUB file
|
|
@@ -206,7 +255,7 @@ metaguide_xhtml_file("input.html", "output.html")
|
|
|
206
255
|
|
|
207
256
|
#### EPUB Functions
|
|
208
257
|
|
|
209
|
-
**`metaguide_epub_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False)`**
|
|
258
|
+
**`metaguide_epub_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3)`**
|
|
210
259
|
|
|
211
260
|
Metaguides an EPUB file by applying visual anchoring to text content within all XHTML files in the EPUB.
|
|
212
261
|
|
|
@@ -216,15 +265,20 @@ from intellireading.client import metaguide_epub_file
|
|
|
216
265
|
# Basic metaguiding
|
|
217
266
|
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub")
|
|
218
267
|
|
|
268
|
+
# Bold more of each word (levels go from 1 to 5, default is 3)
|
|
269
|
+
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub", fixation=5)
|
|
270
|
+
|
|
271
|
+
# Use visual bold (keeps the original font metrics and page count on Kobo kepubs)
|
|
272
|
+
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub", bold_style="shadow")
|
|
273
|
+
|
|
274
|
+
# Use a stronger visual bold effect (intensity goes from 1 to 5, default is 3)
|
|
275
|
+
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub", bold_style="shadow", bold_intensity=5)
|
|
276
|
+
|
|
219
277
|
# Remove metaguiding (experimental)
|
|
220
|
-
metaguide_epub_file(
|
|
221
|
-
"mybook_metaguided.epub",
|
|
222
|
-
"mybook_original.epub",
|
|
223
|
-
remove_metaguiding=True
|
|
224
|
-
)
|
|
278
|
+
metaguide_epub_file("mybook_metaguided.epub", "mybook_original.epub", remove_metaguiding=True)
|
|
225
279
|
```
|
|
226
280
|
|
|
227
|
-
**`metaguide_epub_stream(input_stream: BytesIO, *, remove_metaguiding: bool = False) -> BytesIO`**
|
|
281
|
+
**`metaguide_epub_stream(input_stream: BytesIO, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3) -> BytesIO`**
|
|
228
282
|
|
|
229
283
|
Metaguides an EPUB from a byte stream, useful for in-memory processing or web applications.
|
|
230
284
|
|
|
@@ -246,7 +300,7 @@ with open("output.epub", "wb") as f:
|
|
|
246
300
|
|
|
247
301
|
#### XHTML Functions
|
|
248
302
|
|
|
249
|
-
**`metaguide_xhtml_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False)`**
|
|
303
|
+
**`metaguide_xhtml_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3)`**
|
|
250
304
|
|
|
251
305
|
Metaguides an XHTML/HTML file by applying visual anchoring to text content. Supports `.xhtml`, `.html`, and `.htm` files.
|
|
252
306
|
|
|
@@ -257,14 +311,10 @@ from intellireading.client import metaguide_xhtml_file
|
|
|
257
311
|
metaguide_xhtml_file("article.html", "article_metaguided.html")
|
|
258
312
|
|
|
259
313
|
# Remove metaguiding
|
|
260
|
-
metaguide_xhtml_file(
|
|
261
|
-
"article_metaguided.html",
|
|
262
|
-
"article_restored.html",
|
|
263
|
-
remove_metaguiding=True
|
|
264
|
-
)
|
|
314
|
+
metaguide_xhtml_file("article_metaguided.html", "article_restored.html", remove_metaguiding=True)
|
|
265
315
|
```
|
|
266
316
|
|
|
267
|
-
**`metaguide_xhtml_stream(input_file_stream: BytesIO, *, remove_metaguiding: bool = False) -> BytesIO`**
|
|
317
|
+
**`metaguide_xhtml_stream(input_file_stream: BytesIO, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3) -> BytesIO`**
|
|
268
318
|
|
|
269
319
|
Metaguides an XHTML/HTML file from a byte stream.
|
|
270
320
|
|
|
@@ -282,14 +332,14 @@ html_content = """
|
|
|
282
332
|
</html>
|
|
283
333
|
"""
|
|
284
334
|
|
|
285
|
-
input_stream = BytesIO(html_content.encode(
|
|
335
|
+
input_stream = BytesIO(html_content.encode("utf-8"))
|
|
286
336
|
output_stream = metaguide_xhtml_stream(input_stream)
|
|
287
|
-
metaguided_content = output_stream.read().decode(
|
|
337
|
+
metaguided_content = output_stream.read().decode("utf-8")
|
|
288
338
|
```
|
|
289
339
|
|
|
290
340
|
#### Directory Functions
|
|
291
341
|
|
|
292
|
-
**`metaguide_dir(input_dir: str, output_dir: str, *, remove_metaguiding: bool = False)`**
|
|
342
|
+
**`metaguide_dir(input_dir: str, output_dir: str, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3)`**
|
|
293
343
|
|
|
294
344
|
Metaguides all EPUB and XHTML/HTML files found in a directory recursively.
|
|
295
345
|
|
|
@@ -331,18 +381,19 @@ from intellireading.client import metaguide_epub_stream
|
|
|
331
381
|
|
|
332
382
|
app = Flask(__name__)
|
|
333
383
|
|
|
334
|
-
|
|
384
|
+
|
|
385
|
+
@app.route("/metaguide", methods=["POST"])
|
|
335
386
|
def metaguide_upload():
|
|
336
|
-
file = request.files[
|
|
337
|
-
if file and file.filename.endswith(
|
|
387
|
+
file = request.files["epub"]
|
|
388
|
+
if file and file.filename.endswith(".epub"):
|
|
338
389
|
input_stream = BytesIO(file.read())
|
|
339
390
|
output_stream = metaguide_epub_stream(input_stream)
|
|
340
|
-
|
|
391
|
+
|
|
341
392
|
return send_file(
|
|
342
393
|
output_stream,
|
|
343
394
|
as_attachment=True,
|
|
344
395
|
download_name=f"metaguided_{file.filename}",
|
|
345
|
-
mimetype=
|
|
396
|
+
mimetype="application/epub+zip",
|
|
346
397
|
)
|
|
347
398
|
return "Invalid file", 400
|
|
348
399
|
```
|
|
@@ -353,21 +404,23 @@ def metaguide_upload():
|
|
|
353
404
|
import os
|
|
354
405
|
from intellireading.client import metaguide_dir, is_file_metaguided
|
|
355
406
|
|
|
407
|
+
|
|
356
408
|
def batch_process_library(library_path):
|
|
357
409
|
"""Process an entire library of EPUB files"""
|
|
358
410
|
processed_path = os.path.join(library_path, "metaguided")
|
|
359
|
-
|
|
411
|
+
|
|
360
412
|
# Process all files
|
|
361
413
|
metaguide_dir(library_path, processed_path)
|
|
362
|
-
|
|
414
|
+
|
|
363
415
|
# Verify results
|
|
364
416
|
for root, dirs, files in os.walk(processed_path):
|
|
365
417
|
for file in files:
|
|
366
|
-
if file.endswith(
|
|
418
|
+
if file.endswith(".epub"):
|
|
367
419
|
filepath = os.path.join(root, file)
|
|
368
420
|
if is_file_metaguided(filepath):
|
|
369
421
|
print(f"✓ Successfully metaguided: {file}")
|
|
370
422
|
|
|
423
|
+
|
|
371
424
|
batch_process_library("/path/to/my/books")
|
|
372
425
|
```
|
|
373
426
|
|
|
@@ -385,3 +438,22 @@ except FileNotFoundError as e:
|
|
|
385
438
|
except Exception as e:
|
|
386
439
|
print(f"Unexpected error: {e}")
|
|
387
440
|
```
|
|
441
|
+
|
|
442
|
+
## Dependency updates
|
|
443
|
+
|
|
444
|
+
Dependencies are updated automatically by [Renovate](https://docs.renovatebot.com).
|
|
445
|
+
The configuration lives in [`renovate.json`](renovate.json).
|
|
446
|
+
|
|
447
|
+
Updates that pass the 30-day minimum release age are proposed as pull requests.
|
|
448
|
+
Major updates are labelled `major-update`, security updates are labelled `security`,
|
|
449
|
+
and `ghcr.io/astral-sh/uv` version bumps wait for approval in the Dependency Dashboard.
|
|
450
|
+
|
|
451
|
+
To run Renovate locally as a dry run:
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
act workflow_dispatch -W .github/workflows/renovate.yml \
|
|
455
|
+
--env RENOVATE_DRY_RUN=full \
|
|
456
|
+
--env RENOVATE_REPOSITORIES=hugobatista/intellireading-cli \
|
|
457
|
+
--env LOG_LEVEL=info \
|
|
458
|
+
-s RENOVATE_TOKEN=<token>
|
|
459
|
+
```
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/build-and-publish-to-ghcr.yml)
|
|
7
7
|
[](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/lint.yml)
|
|
8
8
|
[](https://go.hugobatista.com/gh/intellireading-cli/actions/workflows/test.yml)
|
|
9
|
+
[](https://docs.renovatebot.com)
|
|
9
10
|
[](https://gitmcp.io/hugobatista/intellireading-cli)
|
|
10
11
|
|
|
11
12
|
Intellireading is a CLI tool with commands to accelerate your reading experience. It can also be used as a Python library.
|
|
@@ -116,6 +117,54 @@ To metaguide all files in a directory, use the `metaguide-dir` command. The comm
|
|
|
116
117
|
> intellireading metaguide-dir --input_dir mydir --output_dir mydir_metaguided
|
|
117
118
|
```
|
|
118
119
|
|
|
120
|
+
#### Control the fixation level
|
|
121
|
+
The `--fixation` option controls how much of each word is bolded. It accepts values from `1` (least bold) to `5` (most bold) and defaults to `3`, which is the historical behaviour of IntelliReading.
|
|
122
|
+
|
|
123
|
+
The option is available on `metaguide-epub`, `metaguide-xhtml`, and `metaguide-dir`:
|
|
124
|
+
|
|
125
|
+
```console
|
|
126
|
+
> intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub --fixation 5
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The public contract is the range `1`–`5`, the default `3`, and the fact that higher levels never bold less of each word (and usually bold more). The exact split point for each word is an implementation detail and may change.
|
|
130
|
+
|
|
131
|
+
The fixation level only applies to new conversions. EPUB files that are already metaguided are copied unchanged. To apply a different level to an already metaguided EPUB, use `--remove_metaguiding` first and then metaguide the result again. Standalone XHTML files have no metaguided marker, so avoid running metaguiding twice on the same XHTML file.
|
|
132
|
+
|
|
133
|
+
#### Control the bold style
|
|
134
|
+
The `--bold_style` option controls how the bold part of each word is rendered. It accepts:
|
|
135
|
+
|
|
136
|
+
- `tag` (default) — uses `<b>` and the font's real bold face;
|
|
137
|
+
- `shadow` — uses `<b class="ir-bold">` plus a CSS `text-shadow`, which keeps the original font metrics;
|
|
138
|
+
- `stroke` — uses `<b class="ir-bold">` plus a CSS `-webkit-text-stroke`, which also keeps the original font metrics.
|
|
139
|
+
|
|
140
|
+
The visual modes (`shadow` and `stroke`) are intended for Kobo kepubs and other WebKit-based readers. They avoid the page count changes that real bold can cause on Kobo, because the text keeps the same width and line breaks. On readers that do not support those CSS properties, the text may render without emphasis; use `tag` for maximum compatibility.
|
|
141
|
+
|
|
142
|
+
The option is available on `metaguide-epub`, `metaguide-xhtml`, and `metaguide-dir`:
|
|
143
|
+
|
|
144
|
+
```console
|
|
145
|
+
> intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub --bold_style shadow
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### Control the bold intensity
|
|
149
|
+
The `--bold_intensity` option controls how strong the visual bold effect is when `--bold_style` is `shadow` or `stroke`. It accepts values from `1` (subtle) to `5` (strongest) and defaults to `3`.
|
|
150
|
+
|
|
151
|
+
```console
|
|
152
|
+
> intellireading metaguide-epub --input_file mybook.epub --output_file mybook_metaguided.epub --bold_style shadow --bold_intensity 5
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The intensity only affects the visual modes. With `--bold_style tag` the option is ignored, because the real bold face is used.
|
|
156
|
+
|
|
157
|
+
#### What gets metaguided
|
|
158
|
+
Metaguiding only changes prose text inside the document body. The following content is preserved byte-for-byte:
|
|
159
|
+
|
|
160
|
+
- `<style>` and `<script>` elements (CSS and JavaScript)
|
|
161
|
+
- `<pre>` and `<code>` elements (preformatted text and code samples)
|
|
162
|
+
- `<text>` and `<tspan>` elements in SVG
|
|
163
|
+
- CDATA sections
|
|
164
|
+
- HTML comments
|
|
165
|
+
|
|
166
|
+
This keeps stylesheets, scripts and embedded SVG content valid. Elements that are not listed above (for example MathML text elements or `<textarea>`) are still metaguided, so bold tags may be inserted into them. Removal of metaguiding keeps its previous behaviour and can still clean up bold tags added to these regions by older versions.
|
|
167
|
+
|
|
119
168
|
## Experimental Features
|
|
120
169
|
Some features are still experimental and may not work as expected. Use them with caution.
|
|
121
170
|
|
|
@@ -156,7 +205,7 @@ from intellireading.client import (
|
|
|
156
205
|
metaguide_epub_stream,
|
|
157
206
|
metaguide_xhtml_stream,
|
|
158
207
|
metaguide_dir,
|
|
159
|
-
is_file_metaguided
|
|
208
|
+
is_file_metaguided,
|
|
160
209
|
)
|
|
161
210
|
|
|
162
211
|
# Metaguide an EPUB file
|
|
@@ -170,7 +219,7 @@ metaguide_xhtml_file("input.html", "output.html")
|
|
|
170
219
|
|
|
171
220
|
#### EPUB Functions
|
|
172
221
|
|
|
173
|
-
**`metaguide_epub_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False)`**
|
|
222
|
+
**`metaguide_epub_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3)`**
|
|
174
223
|
|
|
175
224
|
Metaguides an EPUB file by applying visual anchoring to text content within all XHTML files in the EPUB.
|
|
176
225
|
|
|
@@ -180,15 +229,20 @@ from intellireading.client import metaguide_epub_file
|
|
|
180
229
|
# Basic metaguiding
|
|
181
230
|
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub")
|
|
182
231
|
|
|
232
|
+
# Bold more of each word (levels go from 1 to 5, default is 3)
|
|
233
|
+
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub", fixation=5)
|
|
234
|
+
|
|
235
|
+
# Use visual bold (keeps the original font metrics and page count on Kobo kepubs)
|
|
236
|
+
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub", bold_style="shadow")
|
|
237
|
+
|
|
238
|
+
# Use a stronger visual bold effect (intensity goes from 1 to 5, default is 3)
|
|
239
|
+
metaguide_epub_file("mybook.epub", "mybook_metaguided.epub", bold_style="shadow", bold_intensity=5)
|
|
240
|
+
|
|
183
241
|
# Remove metaguiding (experimental)
|
|
184
|
-
metaguide_epub_file(
|
|
185
|
-
"mybook_metaguided.epub",
|
|
186
|
-
"mybook_original.epub",
|
|
187
|
-
remove_metaguiding=True
|
|
188
|
-
)
|
|
242
|
+
metaguide_epub_file("mybook_metaguided.epub", "mybook_original.epub", remove_metaguiding=True)
|
|
189
243
|
```
|
|
190
244
|
|
|
191
|
-
**`metaguide_epub_stream(input_stream: BytesIO, *, remove_metaguiding: bool = False) -> BytesIO`**
|
|
245
|
+
**`metaguide_epub_stream(input_stream: BytesIO, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3) -> BytesIO`**
|
|
192
246
|
|
|
193
247
|
Metaguides an EPUB from a byte stream, useful for in-memory processing or web applications.
|
|
194
248
|
|
|
@@ -210,7 +264,7 @@ with open("output.epub", "wb") as f:
|
|
|
210
264
|
|
|
211
265
|
#### XHTML Functions
|
|
212
266
|
|
|
213
|
-
**`metaguide_xhtml_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False)`**
|
|
267
|
+
**`metaguide_xhtml_file(input_file: str, output_file: str, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3)`**
|
|
214
268
|
|
|
215
269
|
Metaguides an XHTML/HTML file by applying visual anchoring to text content. Supports `.xhtml`, `.html`, and `.htm` files.
|
|
216
270
|
|
|
@@ -221,14 +275,10 @@ from intellireading.client import metaguide_xhtml_file
|
|
|
221
275
|
metaguide_xhtml_file("article.html", "article_metaguided.html")
|
|
222
276
|
|
|
223
277
|
# Remove metaguiding
|
|
224
|
-
metaguide_xhtml_file(
|
|
225
|
-
"article_metaguided.html",
|
|
226
|
-
"article_restored.html",
|
|
227
|
-
remove_metaguiding=True
|
|
228
|
-
)
|
|
278
|
+
metaguide_xhtml_file("article_metaguided.html", "article_restored.html", remove_metaguiding=True)
|
|
229
279
|
```
|
|
230
280
|
|
|
231
|
-
**`metaguide_xhtml_stream(input_file_stream: BytesIO, *, remove_metaguiding: bool = False) -> BytesIO`**
|
|
281
|
+
**`metaguide_xhtml_stream(input_file_stream: BytesIO, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3) -> BytesIO`**
|
|
232
282
|
|
|
233
283
|
Metaguides an XHTML/HTML file from a byte stream.
|
|
234
284
|
|
|
@@ -246,14 +296,14 @@ html_content = """
|
|
|
246
296
|
</html>
|
|
247
297
|
"""
|
|
248
298
|
|
|
249
|
-
input_stream = BytesIO(html_content.encode(
|
|
299
|
+
input_stream = BytesIO(html_content.encode("utf-8"))
|
|
250
300
|
output_stream = metaguide_xhtml_stream(input_stream)
|
|
251
|
-
metaguided_content = output_stream.read().decode(
|
|
301
|
+
metaguided_content = output_stream.read().decode("utf-8")
|
|
252
302
|
```
|
|
253
303
|
|
|
254
304
|
#### Directory Functions
|
|
255
305
|
|
|
256
|
-
**`metaguide_dir(input_dir: str, output_dir: str, *, remove_metaguiding: bool = False)`**
|
|
306
|
+
**`metaguide_dir(input_dir: str, output_dir: str, *, remove_metaguiding: bool = False, fixation: int = 3, bold_style: str = "tag", bold_intensity: int = 3)`**
|
|
257
307
|
|
|
258
308
|
Metaguides all EPUB and XHTML/HTML files found in a directory recursively.
|
|
259
309
|
|
|
@@ -295,18 +345,19 @@ from intellireading.client import metaguide_epub_stream
|
|
|
295
345
|
|
|
296
346
|
app = Flask(__name__)
|
|
297
347
|
|
|
298
|
-
|
|
348
|
+
|
|
349
|
+
@app.route("/metaguide", methods=["POST"])
|
|
299
350
|
def metaguide_upload():
|
|
300
|
-
file = request.files[
|
|
301
|
-
if file and file.filename.endswith(
|
|
351
|
+
file = request.files["epub"]
|
|
352
|
+
if file and file.filename.endswith(".epub"):
|
|
302
353
|
input_stream = BytesIO(file.read())
|
|
303
354
|
output_stream = metaguide_epub_stream(input_stream)
|
|
304
|
-
|
|
355
|
+
|
|
305
356
|
return send_file(
|
|
306
357
|
output_stream,
|
|
307
358
|
as_attachment=True,
|
|
308
359
|
download_name=f"metaguided_{file.filename}",
|
|
309
|
-
mimetype=
|
|
360
|
+
mimetype="application/epub+zip",
|
|
310
361
|
)
|
|
311
362
|
return "Invalid file", 400
|
|
312
363
|
```
|
|
@@ -317,21 +368,23 @@ def metaguide_upload():
|
|
|
317
368
|
import os
|
|
318
369
|
from intellireading.client import metaguide_dir, is_file_metaguided
|
|
319
370
|
|
|
371
|
+
|
|
320
372
|
def batch_process_library(library_path):
|
|
321
373
|
"""Process an entire library of EPUB files"""
|
|
322
374
|
processed_path = os.path.join(library_path, "metaguided")
|
|
323
|
-
|
|
375
|
+
|
|
324
376
|
# Process all files
|
|
325
377
|
metaguide_dir(library_path, processed_path)
|
|
326
|
-
|
|
378
|
+
|
|
327
379
|
# Verify results
|
|
328
380
|
for root, dirs, files in os.walk(processed_path):
|
|
329
381
|
for file in files:
|
|
330
|
-
if file.endswith(
|
|
382
|
+
if file.endswith(".epub"):
|
|
331
383
|
filepath = os.path.join(root, file)
|
|
332
384
|
if is_file_metaguided(filepath):
|
|
333
385
|
print(f"✓ Successfully metaguided: {file}")
|
|
334
386
|
|
|
387
|
+
|
|
335
388
|
batch_process_library("/path/to/my/books")
|
|
336
389
|
```
|
|
337
390
|
|
|
@@ -349,3 +402,22 @@ except FileNotFoundError as e:
|
|
|
349
402
|
except Exception as e:
|
|
350
403
|
print(f"Unexpected error: {e}")
|
|
351
404
|
```
|
|
405
|
+
|
|
406
|
+
## Dependency updates
|
|
407
|
+
|
|
408
|
+
Dependencies are updated automatically by [Renovate](https://docs.renovatebot.com).
|
|
409
|
+
The configuration lives in [`renovate.json`](renovate.json).
|
|
410
|
+
|
|
411
|
+
Updates that pass the 30-day minimum release age are proposed as pull requests.
|
|
412
|
+
Major updates are labelled `major-update`, security updates are labelled `security`,
|
|
413
|
+
and `ghcr.io/astral-sh/uv` version bumps wait for approval in the Dependency Dashboard.
|
|
414
|
+
|
|
415
|
+
To run Renovate locally as a dry run:
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
act workflow_dispatch -W .github/workflows/renovate.yml \
|
|
419
|
+
--env RENOVATE_DRY_RUN=full \
|
|
420
|
+
--env RENOVATE_REPOSITORIES=hugobatista/intellireading-cli \
|
|
421
|
+
--env LOG_LEVEL=info \
|
|
422
|
+
-s RENOVATE_TOKEN=<token>
|
|
423
|
+
```
|
|
@@ -41,6 +41,32 @@ dependencies = [
|
|
|
41
41
|
[project.scripts]
|
|
42
42
|
intellireading = "intellireading.client:entrypoint"
|
|
43
43
|
|
|
44
|
+
[tool.uv]
|
|
45
|
+
required-version = ">=0.11.18"
|
|
46
|
+
exclude-newer = "5 days"
|
|
47
|
+
|
|
48
|
+
[[tool.uv.index]]
|
|
49
|
+
name = "pypi"
|
|
50
|
+
url = "https://pypi.org/simple"
|
|
51
|
+
explicit = true
|
|
52
|
+
|
|
53
|
+
[dependency-groups]
|
|
54
|
+
lint = [
|
|
55
|
+
"mypy>=1.0.0",
|
|
56
|
+
"ruff>=0.0.243",
|
|
57
|
+
"types-regex",
|
|
58
|
+
]
|
|
59
|
+
test = [
|
|
60
|
+
"coverage[toml]>=6.5",
|
|
61
|
+
"pytest",
|
|
62
|
+
"pytest-cov",
|
|
63
|
+
]
|
|
64
|
+
dev = [
|
|
65
|
+
"hatch>=1.16.5",
|
|
66
|
+
{include-group = "lint"},
|
|
67
|
+
{include-group = "test"},
|
|
68
|
+
]
|
|
69
|
+
|
|
44
70
|
[project.urls]
|
|
45
71
|
Documentation = "https://go.hugobatista.com/gh/intellireading-cli#readme"
|
|
46
72
|
Issues = "https://go.hugobatista.com/gh/intellireading-cli/issues"
|
|
@@ -57,61 +83,24 @@ packages = ["src/intellireading"]
|
|
|
57
83
|
exclude = ["tests"]
|
|
58
84
|
|
|
59
85
|
[tool.hatch.build.targets.sdist]
|
|
60
|
-
|
|
61
|
-
exclude = ["tests"]
|
|
86
|
+
only-include = ["src/intellireading", "README.md"]
|
|
62
87
|
|
|
63
88
|
[tool.hatch.envs.default]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"coverage[toml]>=6.5",
|
|
67
|
-
"pytest",
|
|
68
|
-
]
|
|
69
|
-
[tool.hatch.envs.default.scripts]
|
|
70
|
-
test = "pytest {args:tests} -v"
|
|
71
|
-
test-cov = "coverage run -m pytest {args:tests} -v"
|
|
72
|
-
cov-report = [
|
|
73
|
-
"- coverage combine",
|
|
74
|
-
"coverage report",
|
|
75
|
-
"coverage html",
|
|
76
|
-
]
|
|
77
|
-
cov = [
|
|
78
|
-
"test-cov",
|
|
79
|
-
"cov-report",
|
|
80
|
-
]
|
|
89
|
+
type = "virtual"
|
|
90
|
+
path = ".venv"
|
|
81
91
|
|
|
82
|
-
[
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
]
|
|
92
|
-
[tool.hatch.envs.lint.scripts]
|
|
93
|
-
typing = "mypy --ignore-missing-imports --install-types --non-interactive {args:src/intellireading tests}"
|
|
94
|
-
style = [
|
|
95
|
-
"ruff check {args:.}",
|
|
96
|
-
"black --check --diff {args:.}",
|
|
97
|
-
]
|
|
98
|
-
fmt = [
|
|
99
|
-
"black {args:.}",
|
|
100
|
-
"ruff --fix {args:.}",
|
|
101
|
-
"style",
|
|
102
|
-
]
|
|
103
|
-
all = [
|
|
104
|
-
"style",
|
|
105
|
-
"typing",
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
[tool.black]
|
|
109
|
-
target-version = ["py37"]
|
|
110
|
-
line-length = 120
|
|
111
|
-
skip-string-normalization = true
|
|
92
|
+
[tool.hatch.envs.default.scripts]
|
|
93
|
+
lint = "ruff check . --fix"
|
|
94
|
+
format = "ruff format ."
|
|
95
|
+
lint-check = "ruff check ."
|
|
96
|
+
format-check = "ruff format --check ."
|
|
97
|
+
test = "pytest"
|
|
98
|
+
typecheck = "mypy"
|
|
99
|
+
validate = ["lint", "format", "test", "typecheck"]
|
|
100
|
+
check = ["lint-check", "format-check", "test", "typecheck"]
|
|
112
101
|
|
|
113
102
|
[tool.ruff]
|
|
114
|
-
target-version = "
|
|
103
|
+
target-version = "py313"
|
|
115
104
|
line-length = 120
|
|
116
105
|
lint.select = [
|
|
117
106
|
"A",
|
|
@@ -169,6 +158,9 @@ ban-relative-imports = "all"
|
|
|
169
158
|
# Tests can use magic values, assertions, and relative imports
|
|
170
159
|
"tests/**/*" = ["PLR2004", "S101", "TID252"]
|
|
171
160
|
|
|
161
|
+
[tool.ruff.format]
|
|
162
|
+
quote-style = "double"
|
|
163
|
+
|
|
172
164
|
[tool.coverage.run]
|
|
173
165
|
source_pkgs = ["intellireading", "tests"]
|
|
174
166
|
branch = true
|
|
@@ -182,8 +174,36 @@ intellireading = ["src/intellireading", "*/intellireading-cli/src/intellireading
|
|
|
182
174
|
tests = ["tests", "*/intellireading-cli/tests"]
|
|
183
175
|
|
|
184
176
|
[tool.coverage.report]
|
|
177
|
+
show_missing = true
|
|
178
|
+
skip_covered = false
|
|
179
|
+
fail_under = 75
|
|
185
180
|
exclude_lines = [
|
|
186
|
-
"no
|
|
181
|
+
"pragma: no cover",
|
|
182
|
+
"raise AssertionError",
|
|
183
|
+
"raise NotImplementedError",
|
|
187
184
|
"if __name__ == .__main__.:",
|
|
188
185
|
"if TYPE_CHECKING:",
|
|
189
186
|
]
|
|
187
|
+
|
|
188
|
+
[tool.pytest.ini_options]
|
|
189
|
+
addopts = "--tb=short --strict-markers --cov --cov-report=term-missing"
|
|
190
|
+
pythonpath = ["src"]
|
|
191
|
+
testpaths = ["tests"]
|
|
192
|
+
|
|
193
|
+
[tool.mypy]
|
|
194
|
+
python_version = "3.13"
|
|
195
|
+
strict = true
|
|
196
|
+
incremental = false
|
|
197
|
+
check_untyped_defs = true
|
|
198
|
+
mypy_path = ["src"]
|
|
199
|
+
files = ["src/intellireading"]
|
|
200
|
+
exclude = ["tests/"]
|
|
201
|
+
|
|
202
|
+
[[tool.mypy.overrides]]
|
|
203
|
+
module = ["lxml.*"]
|
|
204
|
+
ignore_missing_imports = true
|
|
205
|
+
|
|
206
|
+
[[tool.mypy.overrides]]
|
|
207
|
+
module = "tests.*"
|
|
208
|
+
disallow_untyped_defs = false
|
|
209
|
+
disallow_incomplete_defs = false
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.0"
|
|
@@ -2,6 +2,12 @@ from intellireading.client.app import entrypoint
|
|
|
2
2
|
|
|
3
3
|
# flake8: noqa : F401
|
|
4
4
|
from intellireading.client.metaguiding import (
|
|
5
|
+
BOLD_INTENSITIES,
|
|
6
|
+
BOLD_STYLES,
|
|
7
|
+
DEFAULT_BOLD_INTENSITY,
|
|
8
|
+
DEFAULT_BOLD_STYLE,
|
|
9
|
+
DEFAULT_FIXATION,
|
|
10
|
+
FIXATION_LEVELS,
|
|
5
11
|
metaguide_epub_stream,
|
|
6
12
|
metaguide_xhtml_stream,
|
|
7
13
|
metaguide_dir,
|