Introduce a "file" element to supersede "datafile" - #3139
Open
skiadas wants to merge 11 commits into
Open
Conversation
skiadas
force-pushed
the
file-element
branch
2 times, most recently
from
August 11, 2026 19:49
baf86c6 to
1e60a98
Compare
skiadas
marked this pull request as ready for review
August 14, 2026 19:31
Contributor
|
@skiadas - didn't do an exhaustive test, but tried it out and also verified that it doesn't appear to change output for existing items. That looks great. Suggestions (don't take these as gospel):
|
Every "datafile" in the sample book becomes an equivalent "file" in
the recommended form: a text "file" keeps its "pre" child and names
its visibility with @user-interaction (edit, view, none); an image
"file" is left hidden (no @user-interaction) and displayed to the
reader with a sibling "image" element naming the same source. The
prose references to the element name are updated.
The built output intentionally differs from the previous commit:
- image files now render as a hidden "file" plus a sibling
"image", rather than the visible image the assembly auto-
conversion produces (a pragmatic 1:1 mapping that shows only in
interactive output);
- the lunr search index carries the authored indentation of the
four inline-pre files again, as it did before this PR, where the
auto-conversion had stripped it.
A "file" with no @user-interaction stays hidden from the reader (the default); this small example shows the "pre" content is still delivered to programs by filename, and that @Format may be omitted for a text file inserted with a "pre" child.
A binary "file" delivered with plain @add-files is just data in the program's working directory. A Python3 program decompresses a gzip archive to show the base64 round-trip preserves the bytes exactly. This complements the jar example, where @compile-also puts the file on the javac/java classpath instead.
Contributor
Author
Thanks @ascholerChemeketa ! I updated the PR following those. I think I addressed all the points. Two things I want to emphasize:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
fileelement as successor todatafile;@format(pre/image/binary) names the kind,@user-interaction(none/view/edit) the visibility.datafilestays valid but is deprecated and auto-converted in the pre-processor (@editable="yes"→edit,@hide="yes"→none, elseview). Adds first-class binary support.Runestone integration
The PreTeXt side is complete; the Runestone side implements it:
data-isbinary(+data-mime-type). The Runestonedatafilecomponent reads it, and server-side (Jobe) programs receive the real file in their working directory via@add-files/@compile-also— the base64 round-trips byte-for-byte (the sample book's gzip example verifies this).@compile-alsois per-language. "Add to compilation" means different things depending on the program's@languageand whether the file is text or binary:.jar/.zip) is placed on the compiler's classpath (-cp), so its classes are visible to the program;.o/.a) is placed on the link line, after the source, so it is linked into the executable;@compile-alsoalso folds the file into the program's@add-files, so authors only need to name it once..so) are not supported: the server cannot arrange for the runtime linker to find them.fileis dropped from static (non-Runestone) output.user-interaction="upload"(reader uploads a file into a program) needs Runestone server per-reader persistence; a one-line schema value reintroduces it later.data-edit,textarea) and hidden files (user-interaction="none"— registered but not displayed) behave as before.Related
datafile/pre/@sourcedatafiledeprecation PR (predecessor to this work)