sphinx-typst-render 0.2.2__tar.gz → 0.2.3__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.
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/PKG-INFO +1 -1
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/pyproject.toml +1 -1
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/pyproject.toml.orig +1 -1
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/__init__.py +1 -1
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/_compile.py +31 -1
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/LICENSE +0 -0
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/README.md +0 -0
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/_directive.py +0 -0
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/_downloads.py +0 -0
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/static/typst-render.css +0 -0
- {sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/static/typst-render.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sphinx-typst-render
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Render Typst sources into downloadable PDFs and inline previews in Sphinx and Jupyter Book.
|
|
5
5
|
Keywords: jupyter-book,sphinx,typst,pdf,forms,documentation
|
|
6
6
|
Author: NB-TUDelft, K.Zabłocki (Zamkorus)
|
|
@@ -17,7 +17,7 @@ OUT_DIRNAME = "_typst"
|
|
|
17
17
|
LIB_FILENAME = "capture_field.typ"
|
|
18
18
|
|
|
19
19
|
#: Bumped whenever the output layout changes, to invalidate stale caches.
|
|
20
|
-
_CACHE_VERSION =
|
|
20
|
+
_CACHE_VERSION = 2
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
@dataclass(frozen=True)
|
|
@@ -115,6 +115,35 @@ def _fingerprint(request: RenderRequest) -> str:
|
|
|
115
115
|
return digest.hexdigest()
|
|
116
116
|
|
|
117
117
|
|
|
118
|
+
def _unbound_field_lengths(writer) -> None:
|
|
119
|
+
"""Drop the character cap ReportLab puts on every text field.
|
|
120
|
+
|
|
121
|
+
``AcroForm.textfield()`` defaults to ``maxlen=100`` and typst-fillable does
|
|
122
|
+
not override it, so a field silently refuses input after 100 characters.
|
|
123
|
+
A worksheet answer box that stops mid-sentence is worse than useless, and
|
|
124
|
+
there is no sensible cap for one, so remove /MaxLen rather than raise it.
|
|
125
|
+
"""
|
|
126
|
+
seen: set[int] = set()
|
|
127
|
+
|
|
128
|
+
def strip(obj) -> None:
|
|
129
|
+
if obj is None or id(obj) in seen:
|
|
130
|
+
return
|
|
131
|
+
seen.add(id(obj))
|
|
132
|
+
if "/MaxLen" in obj:
|
|
133
|
+
del obj["/MaxLen"]
|
|
134
|
+
for kid in obj.get("/Kids", []) or []:
|
|
135
|
+
strip(kid.get_object())
|
|
136
|
+
|
|
137
|
+
for page in writer.pages:
|
|
138
|
+
for annot in page.get("/Annots", []) or []:
|
|
139
|
+
strip(annot.get_object())
|
|
140
|
+
|
|
141
|
+
acroform = writer._root_object.get("/AcroForm")
|
|
142
|
+
if acroform:
|
|
143
|
+
for field in acroform.get("/Fields", []) or []:
|
|
144
|
+
strip(field.get_object())
|
|
145
|
+
|
|
146
|
+
|
|
118
147
|
def _add_form_fields(base: bytes, request: RenderRequest) -> bytes:
|
|
119
148
|
"""Overlay interactive AcroForm fields onto an already compiled PDF.
|
|
120
149
|
|
|
@@ -149,6 +178,7 @@ def _add_form_fields(base: bytes, request: RenderRequest) -> bytes:
|
|
|
149
178
|
for index, page in enumerate(reader.pages):
|
|
150
179
|
if index < len(writer.pages):
|
|
151
180
|
writer.pages[index].merge_page(page, over=False)
|
|
181
|
+
_unbound_field_lengths(writer)
|
|
152
182
|
# Ask the reader to build field appearances, so a blank field is visible.
|
|
153
183
|
writer.set_need_appearances_writer(True)
|
|
154
184
|
|
|
File without changes
|
|
File without changes
|
{sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/_directive.py
RENAMED
|
File without changes
|
{sphinx_typst_render-0.2.2 → sphinx_typst_render-0.2.3}/src/sphinx_typst_render/_downloads.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|