mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 11:07:04 +00:00
feat(export): apply print bleed and full-bleed full-page images
This commit is contained in:
1 parent
d684abbdef
commit
008e22c36c
1 file changed
+10
-5
+10
-5
@@ -51,9 +51,13 @@ function listItem(item: JSONContent): string {
|
|||||||
function figure(node: JSONContent, paths: Map<string, string>): string {
|
function figure(node: JSONContent, paths: Map<string, string>): string {
|
||||||
const path = paths.get(node.attrs?.src);
|
const path = paths.get(node.attrs?.src);
|
||||||
if (!path) return "";
|
if (!path) return "";
|
||||||
|
const placement = node.attrs?.placement ?? "inline";
|
||||||
|
if (placement === "full-page") {
|
||||||
|
return `#page(margin: 0pt, numbering: none)[#image(${str(path)}, width: 100%, height: 100%, fit: "cover")]`;
|
||||||
|
}
|
||||||
const caption = node.attrs?.caption ? `, caption: [${esc(node.attrs.caption)}]` : "";
|
const caption = node.attrs?.caption ? `, caption: [${esc(node.attrs.caption)}]` : "";
|
||||||
const placement = node.attrs?.placement === "float-top" ? ", placement: top" : "";
|
const float = placement === "float-top" ? ", placement: top" : "";
|
||||||
return `#figure(image(${str(path)}, width: 100%)${caption}${placement})`;
|
return `#figure(image(${str(path)}, width: 100%)${caption}${float})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function block(node: JSONContent, paths: Map<string, string>): string {
|
function block(node: JSONContent, paths: Map<string, string>): string {
|
||||||
@@ -87,11 +91,12 @@ function chapterBody(content: JSONContent, paths: Map<string, string>): string {
|
|||||||
function preamble(book: Book): string {
|
function preamble(book: Book): string {
|
||||||
const trim = TRIM[book.settings.trim];
|
const trim = TRIM[book.settings.trim];
|
||||||
const meta = book.metadata;
|
const meta = book.metadata;
|
||||||
|
const bleed = book.settings.bleed ? "0.125in" : "0in";
|
||||||
return `#set document(title: ${str(meta.title || "Untitled")}, author: ${str(meta.author)})
|
return `#set document(title: ${str(meta.title || "Untitled")}, author: ${str(meta.author)})
|
||||||
#set page(
|
#set page(
|
||||||
width: ${trim.w},
|
width: ${trim.w} + ${bleed},
|
||||||
height: ${trim.h},
|
height: ${trim.h} + ${bleed} * 2,
|
||||||
margin: (inside: 0.875in, outside: 0.625in, top: 0.8in, bottom: 0.8in),
|
margin: (inside: 0.875in, outside: 0.625in + ${bleed}, top: 0.8in + ${bleed}, bottom: 0.8in + ${bleed}),
|
||||||
binding: left,
|
binding: left,
|
||||||
)
|
)
|
||||||
#set text(font: "Literata", size: 11pt, lang: ${str(meta.language || "en")}, hyphenate: true)
|
#set text(font: "Literata", size: 11pt, lang: ${str(meta.language || "en")}, hyphenate: true)
|
||||||
|
|||||||
Reference in new issue
Block a user