Skip to content

Conversation

@yfyang86
Copy link

Bug Fixes for Typst Template

  • verified typst version: >= 0.13.1
  • OS: Mac OS 15.4.1

Issues Fixed

1. Deprecated Type Comparisons

Problem: Comparing types with strings is deprecated and will return false in future releases.

Locations:

  • Line 55: type(date) == "datetime"
  • Line 57: type(date) == "dictionary"
  • Line 186: type(logo) == "content"
  • Line 274: type(abstract) == "content"

Solution: Changed to compare with literal types instead:

// Before
if (type(date) == "datetime") { ... }

// After
if (type(date) == datetime) { ... }

2. Invalid Selector Usage with locate()

Problem: Only element functions can be used as selectors. The locate() function is deprecated in certain contexts.

Locations:

  • Line 83-95: Page header configuration
  • Line 136-175: Heading show rule

Solution: Replaced locate() with context expressions:

// Before
header: locate(loc => {
  if(loc.page() == 1) { ... }
})

// After
header: context {
  if(here().page() == 1) { ... }
}

3. Context Required for Counter Operations

Problem: Page counter operations require context to be known.

Location: Line 112-115: Footer page numbering

Solution: Wrapped counter operations in context block and converted final count to string:

// Before
#counter(page).display() of #locate((loc) => {counter(page).final(loc).first()})

// After
#context {
  counter(page).display()
  [ of ]
  str(counter(page).final().first())
}

4. Deprecated image.decode()

Problem: image.decode() is deprecated in favor of passing bytes directly to image().

Location: Line 213: ORCID logo rendering

Solution:

  1. Converted SVG string to bytes using bytes() function
  2. Passed bytes directly to image() instead of using image.decode()
// Before
let orcidSvg = ```<svg...>```.text
...
#image.decode(orcidSvg)

// After
let orcidSvg = bytes(```<svg...>```.text)
...
#image(orcidSvg)

5. Deprecated par set block

Change show par: set block(...) to set par(...) as typst (as of 0.13) suggests.

…locate(). 2. Context Required for Counter Operations. 3. Deprecated functions of image.decode() and string compare.
@yfyang86 yfyang86 mentioned this pull request Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant