Merge pull request #105 from timmmmmmmmm/main

feat: add disable-smallcaps option
This commit is contained in:
Paul T
2025-03-10 10:38:12 -04:00
committed by GitHub

82
lib.typ
View File

@@ -38,6 +38,23 @@
/// Helpers /// Helpers
// Common helper functions
#let __format_author_name(author, language) = {
if language == "zh" or language == "ja" {
str(author.firstname) + str(author.lastname)
} else {
str(author.firstname) + " " + str(author.lastname)
}
}
#let __apply_smallcaps(content, use-smallcaps) = {
if use-smallcaps {
smallcaps(content)
} else {
content
}
}
// layout utility // layout utility
#let __justify_align(left_body, right_body) = { #let __justify_align(left_body, right_body) = {
block[ block[
@@ -70,23 +87,21 @@
] ]
} }
#let __coverletter_footer(author, language, date, lang_data) = { #let __coverletter_footer(author, language, date, lang_data, use-smallcaps: true) = {
set text( set text(
fill: gray, fill: gray,
size: 8pt, size: 8pt,
) )
__justify_align_3[ __justify_align_3[
#smallcaps[#date] #__apply_smallcaps(date, use-smallcaps)
][ ][
#smallcaps[ #__apply_smallcaps(
#if language == "zh" or language == "ja" [ {
#author.firstname#author.lastname let name = __format_author_name(author, language)
] else [ name + " · " + linguify("cover-letter", from: lang_data)
#author.firstname#sym.space#author.lastname },
] use-smallcaps
#sym.dot.c )
#linguify("cover-letter", from: lang_data)
]
][ ][
#context { #context {
counter(page).display() counter(page).display()
@@ -94,23 +109,21 @@
] ]
} }
#let __resume_footer(author, language, lang_data, date) = { #let __resume_footer(author, language, lang_data, date, use-smallcaps: true) = {
set text( set text(
fill: gray, fill: gray,
size: 8pt, size: 8pt,
) )
__justify_align_3[ __justify_align_3[
#smallcaps[#date] #__apply_smallcaps(date, use-smallcaps)
][ ][
#smallcaps[ #__apply_smallcaps(
#if language == "zh" or language == "ja" [ {
#author.firstname#author.lastname let name = __format_author_name(author, language)
] else [ name + " · " + linguify("resume", from: lang_data)
#author.firstname#sym.space#author.lastname },
] use-smallcaps
#sym.dot.c )
#linguify("resume", from: lang_data)
]
][ ][
#context { #context {
counter(page).display() counter(page).display()
@@ -195,6 +208,7 @@
/// - accent-color (color): The accent color of the resume /// - accent-color (color): The accent color of the resume
/// - colored-headers (boolean): Whether the headers should be colored or not /// - colored-headers (boolean): Whether the headers should be colored or not
/// - language (string): The language of the resume, defaults to "en". See lang.toml for available languages /// - language (string): The language of the resume, defaults to "en". See lang.toml for available languages
/// - use-smallcaps (boolean): Whether to use small caps formatting throughout the template
/// - body (content): The body of the resume /// - body (content): The body of the resume
/// -> none /// -> none
#let resume( #let resume(
@@ -208,6 +222,7 @@
font: ("Source Sans Pro", "Source Sans 3"), font: ("Source Sans Pro", "Source Sans 3"),
header-font: ("Roboto"), header-font: ("Roboto"),
paper-size: "a4", paper-size: "a4",
use-smallcaps: true,
body, body,
) = { ) = {
if type(accent-color) == "string" { if type(accent-color) == "string" {
@@ -240,6 +255,7 @@
language, language,
lang_data, lang_data,
date, date,
use-smallcaps: use-smallcaps,
)] else [], )] else [],
footer-descent: 0pt, footer-descent: 0pt,
) )
@@ -286,7 +302,7 @@
size: 10pt, size: 10pt,
weight: "regular", weight: "regular",
) )
smallcaps[#it.body] __apply_smallcaps(it.body, use-smallcaps)
} }
let name = { let name = {
@@ -319,12 +335,13 @@
weight: "regular", weight: "regular",
) )
align(center)[ align(center)[
#smallcaps[ #__apply_smallcaps(
#author.positions.join( author.positions.join(
text[#" "#sym.dot.c#" "], text[#" "#sym.dot.c#" "],
),
use-smallcaps
) )
] ]
]
} }
let address = { let address = {
@@ -576,6 +593,7 @@
/// - font (array): The font families of the cover letter /// - font (array): The font families of the cover letter
/// - show-footer (boolean): Whether to show the footer or not /// - show-footer (boolean): Whether to show the footer or not
/// - closing (content): The closing of the cover letter. This defaults to "Attached Curriculum Vitae". You can set this to `none` to show the default closing or remove it completely. /// - closing (content): The closing of the cover letter. This defaults to "Attached Curriculum Vitae". You can set this to `none` to show the default closing or remove it completely.
/// - use-smallcaps (boolean): Whether to use small caps formatting throughout the template
/// - body (content): The body of the cover letter /// - body (content): The body of the cover letter
#let coverletter( #let coverletter(
author: (:), author: (:),
@@ -587,6 +605,7 @@
show-footer: true, show-footer: true,
closing: none, closing: none,
paper-size: "a4", paper-size: "a4",
use-smallcaps: true,
body, body,
) = { ) = {
if type(accent-color) == "string" { if type(accent-color) == "string" {
@@ -624,6 +643,7 @@
language, language,
date, date,
lang_data, lang_data,
use-smallcaps: use-smallcaps,
)] else [], )] else [],
footer-descent: 0pt, footer-descent: 0pt,
) )
@@ -686,12 +706,13 @@
weight: "regular", weight: "regular",
) )
align(right)[ align(right)[
#smallcaps[ #__apply_smallcaps(
#author.positions.join( author.positions.join(
text[#" "#sym.dot.c#" "], text[#" "#sym.dot.c#" "],
),
use-smallcaps
) )
] ]
]
} }
let address = { let address = {
@@ -812,6 +833,7 @@
#let hiring-entity-info( #let hiring-entity-info(
entity-info: (:), entity-info: (:),
date: datetime.today().display("[month repr:long] [day], [year]"), date: datetime.today().display("[month repr:long] [day], [year]"),
use-smallcaps: true,
) = { ) = {
set par(leading: 1em) set par(leading: 1em)
pad(top: 1.5em, bottom: 1.5em)[ pad(top: 1.5em, bottom: 1.5em)[
@@ -823,7 +845,7 @@
#pad(top: 0.65em, bottom: 0.65em)[ #pad(top: 0.65em, bottom: 0.65em)[
#text(weight: "regular", fill: color-gray, size: 9pt)[ #text(weight: "regular", fill: color-gray, size: 9pt)[
#smallcaps[#entity-info.name] \ #__apply_smallcaps(entity-info.name, use-smallcaps) \
#entity-info.street-address \ #entity-info.street-address \
#entity-info.city \ #entity-info.city \
] ]