Skip to content

Commit

Permalink
switch to kebab-case as recommended by typst
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Jan 13, 2025
1 parent cc64d0f commit 241dff0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Here is the template and its preview:
// with this code, you can provide which kind you want on the command line
// typst compile input.typ output.pdf --input digital=(true|false)
digital: json.decode(sys.inputs.at("digital", default: "false")),
// zine_page_margin: 0.25in // margin of zine pages
// draw_border: true // draw border boxes in printing mode
// zine-page-margin: 0.25in // margin of zine pages
// draw-border: true // draw border boxes in printing mode
)
// provide your content pages in order and they
Expand Down
48 changes: 24 additions & 24 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
/// The inner margins are _shared_ between pages so this is also
/// the inner distance between any two zine pages.
/// -> length
zine_page_margin: 0.25in,
zine-page-margin: 0.25in,
/// whether to draw the border of the zine pages in printer mode
///
/// This border is sometimes helpful for seeing the placement of
/// content on the final printer-ready page.
/// -> boolean
draw_border: true,
draw-border: true,
/// whether to be in printer mode (false) or digital (true)
///
/// When creating a digital zine, the margin specified with `zine_page_margin`
/// When creating a digital zine, the margin specified with `zine-page-margin`
/// is divided by two so that the digital visually looks like the printed
/// zine with the pages cut out.
/// -> boolean
Expand All @@ -50,35 +50,35 @@
// in order to deduce the zine page height and width
// each of the zine pages share the margin with their neighbors
// this height/width is without margins
let zine_page_height = (page.width - 3*zine_page_margin)/2;
let zine_page_width = (page.height - 5*zine_page_margin)/4;
let zine-page-height = (page.width - 3*zine-page-margin)/2;
let zine-page-width = (page.height - 5*zine-page-margin)/4;
if digital {
// assign half the zine margin to each digital page
// resize pages and then provide content since it has pagebreaks already
set page(
height: zine_page_height+zine_page_margin/2,
width: zine_page_width+zine_page_margin/2,
margin: zine_page_margin/2
height: zine-page-height+zine-page-margin/2,
width: zine-page-width+zine-page-margin/2,
margin: zine-page-margin/2
)
content
} else {
// make sure page has the correct margin and it is flipped
set page(margin: zine_page_margin, flipped: true)
set page(margin: zine-page-margin, flipped: true)
// break content into the array of pages using the pagebreak
// function and then place those pages into the grid
let contents = ()
let current_content = []
let current-content = []
for child in content.at("children") {
if child.func() == pagebreak {
contents.push(current_content)
current_content = []
contents.push(current-content)
current-content = []
} else {
current_content = current_content + child
current-content = current-content + child
}
}

if current_content != [] {
contents.push(current_content)
if current-content != [] {
contents.push(current-content)
}

assert.eq(
Expand All @@ -93,8 +93,8 @@
// wrap the contents in blocks the size of the zine pages so that we can
// maneuver them at will
elem => block(
width: zine_page_width,
height: zine_page_height,
width: zine-page-width,
height: zine-page-height,
spacing: 0em,
elem
)
Expand All @@ -113,16 +113,16 @@
}
)

let zine_grid = grid.with(
columns: 4 * (zine_page_width, ),
rows: zine_page_height,
gutter: zine_page_margin,
let zine-grid = grid.with(
columns: 4 * (zine-page-width, ),
rows: zine-page-height,
gutter: zine-page-margin,
)
if draw_border {
zine_grid = zine_grid.with(
if draw-border {
zine-grid = zine-grid.with(
stroke: luma(0)
)
}
zine_grid(..contents)
zine-grid(..contents)
}
}
4 changes: 2 additions & 2 deletions template/main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
// with this code, you can provide which kind you want on the command line
// typst compile input.typ output.pdf --input digital=(true|false)
digital: json.decode(sys.inputs.at("digital", default: "false")),
// zine_page_margin: 0.25in // margin of zine pages
// draw_border: true // draw border boxes in printing mode
// zine-page-margin: 0.25in // margin of zine pages
// draw-border: true // draw border boxes in printing mode
)
// provide your content pages in order and they
Expand Down

0 comments on commit 241dff0

Please sign in to comment.