mirror of
https://github.com/typst/typst
synced 2025-08-12 14:17:55 +08:00
40 lines
1.2 KiB
XML
40 lines
1.2 KiB
XML
// Test file attachments. The tests here so far are unsatisfactory because we
|
|
// have no PDF testing infrastructure. That should be improved in the future.
|
|
|
|
--- pdf-attach ---
|
|
#pdf.attach("/assets/text/hello.txt")
|
|
#pdf.attach(
|
|
"/assets/data/details.toml",
|
|
relationship: "supplement",
|
|
mime-type: "application/toml",
|
|
description: "Information about a secret project",
|
|
)
|
|
|
|
--- pdf-attach-bytes ---
|
|
#pdf.attach("hello.txt", read("/assets/text/hello.txt", encoding: none))
|
|
#pdf.attach(
|
|
"a_file_name.txt",
|
|
read("/assets/text/hello.txt", encoding: none),
|
|
relationship: "supplement",
|
|
mime-type: "text/plain",
|
|
description: "A description",
|
|
)
|
|
|
|
--- pdf-attach-invalid-relationship ---
|
|
#pdf.attach(
|
|
"/assets/text/hello.txt",
|
|
// Error: 17-23 expected "source", "data", "alternative", "supplement", or none
|
|
relationship: "test",
|
|
mime-type: "text/plain",
|
|
description: "A test file",
|
|
)
|
|
|
|
--- pdf-attach-invalid-data ---
|
|
// Error: 39-46 expected bytes, found string
|
|
#pdf.attach("/assets/text/hello.txt", "hello")
|
|
|
|
--- pdf-embed-deprecated ---
|
|
// Warning: 6-11 the name `embed` is deprecated, use `attach` instead
|
|
// Hint: 6-11 it will be removed in Typst 0.15.0
|
|
#pdf.embed("/assets/text/hello.txt")
|