sphinx-typst-render 0.2.4__tar.gz → 0.2.5__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.4 → sphinx_typst_render-0.2.5}/PKG-INFO +9 -1
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/README.md +8 -0
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/pyproject.toml +1 -1
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/pyproject.toml.orig +1 -1
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/__init__.py +1 -1
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/_compile.py +14 -2
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/LICENSE +0 -0
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/_directive.py +0 -0
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/_downloads.py +0 -0
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/static/typst-render.css +0 -0
- {sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/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.5
|
|
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)
|
|
@@ -180,6 +180,14 @@ yourself.
|
|
|
180
180
|
Available helpers are `text_field`, `textarea_field`, `checkbox_field`, and
|
|
181
181
|
`radio_field`, plus the lower level `capture_field`.
|
|
182
182
|
|
|
183
|
+
Fillable PDFs keep the source document's metadata, including its title and
|
|
184
|
+
author. Set a title in Typst to use it in PDF viewer tabs:
|
|
185
|
+
|
|
186
|
+
```typ
|
|
187
|
+
#set document(title: "Worksheet", author: "NB2420")
|
|
188
|
+
= Worksheet
|
|
189
|
+
```
|
|
190
|
+
|
|
183
191
|
## Field length
|
|
184
192
|
|
|
185
193
|
ReportLab caps every text field at 100 characters by default, which stops a
|
|
@@ -149,6 +149,14 @@ yourself.
|
|
|
149
149
|
Available helpers are `text_field`, `textarea_field`, `checkbox_field`, and
|
|
150
150
|
`radio_field`, plus the lower level `capture_field`.
|
|
151
151
|
|
|
152
|
+
Fillable PDFs keep the source document's metadata, including its title and
|
|
153
|
+
author. Set a title in Typst to use it in PDF viewer tabs:
|
|
154
|
+
|
|
155
|
+
```typ
|
|
156
|
+
#set document(title: "Worksheet", author: "NB2420")
|
|
157
|
+
= Worksheet
|
|
158
|
+
```
|
|
159
|
+
|
|
152
160
|
## Field length
|
|
153
161
|
|
|
154
162
|
ReportLab caps every text field at 100 characters by default, which stops a
|
|
@@ -16,8 +16,8 @@ LIB_DIRNAME = "_typst_lib"
|
|
|
16
16
|
OUT_DIRNAME = "_typst"
|
|
17
17
|
LIB_FILENAME = "capture_field.typ"
|
|
18
18
|
|
|
19
|
-
#: Bumped whenever the output
|
|
20
|
-
_CACHE_VERSION =
|
|
19
|
+
#: Bumped whenever the generated output changes, to invalidate stale caches.
|
|
20
|
+
_CACHE_VERSION = 4
|
|
21
21
|
|
|
22
22
|
#: Characters a generated text field accepts unless configured otherwise.
|
|
23
23
|
#: Large enough that no worksheet answer reaches it, and written explicitly
|
|
@@ -179,6 +179,7 @@ def _add_form_fields(base: bytes, request: RenderRequest) -> bytes:
|
|
|
179
179
|
from io import BytesIO
|
|
180
180
|
|
|
181
181
|
from pypdf import PdfReader, PdfWriter
|
|
182
|
+
from pypdf.generic import BooleanObject, NameObject
|
|
182
183
|
from typst_fillable import create_form_overlay, extract_field_metadata
|
|
183
184
|
|
|
184
185
|
fields = extract_field_metadata(request.source, root=request.root)
|
|
@@ -194,6 +195,17 @@ def _add_form_fields(base: bytes, request: RenderRequest) -> bytes:
|
|
|
194
195
|
)
|
|
195
196
|
|
|
196
197
|
writer = PdfWriter(clone_from=overlay)
|
|
198
|
+
# Keep the document's metadata instead of ReportLab's "untitled" defaults.
|
|
199
|
+
# Replace the info dictionary so absent values do not inherit overlay data.
|
|
200
|
+
writer.metadata = reader.metadata
|
|
201
|
+
if "/Metadata" in reader.trailer["/Root"]:
|
|
202
|
+
writer.root_object[NameObject("/Metadata")] = (
|
|
203
|
+
reader.trailer["/Root"].raw_get("/Metadata").clone(writer)
|
|
204
|
+
)
|
|
205
|
+
if reader.metadata and reader.metadata.title:
|
|
206
|
+
writer.create_viewer_preferences()[NameObject("/DisplayDocTitle")] = (
|
|
207
|
+
BooleanObject(True)
|
|
208
|
+
)
|
|
197
209
|
for index, page in enumerate(reader.pages):
|
|
198
210
|
if index < len(writer.pages):
|
|
199
211
|
writer.pages[index].merge_page(page, over=False)
|
|
File without changes
|
{sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/_directive.py
RENAMED
|
File without changes
|
{sphinx_typst_render-0.2.4 → sphinx_typst_render-0.2.5}/src/sphinx_typst_render/_downloads.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|