Adding `default` keyword in typst langage

Recently, while creating summaries using Typst to help with my job search, I came across a somewhat troubling aspect of the language that I think might be worth discussing.

In practice, to make my Typst projects look better, I like to modify list markers and other objects using show rules and set commands. However, I’ve noticed that sometimes there’s no way to reset modified objects to their initial state without consulting the documentation. This is a natural part of learning a language, but I think having a default keyword could address this need to constantly consult the wiki. You can refer to this example :

== Je veux / J'aime
#set list(marker: emoji.checkmark)
#set text(fill: green)
- La conception de système et la réflexion associée
- La résolution de problème
- L'analyse de système et de code
- La variété offerte par le domaine, l'évolution constante et le changement de projet
- Ce qui est lié au Forensic, l'enquête, la réflexion ect
== Je veux pas
#set list(marker: emoji.crossmark)
#set text(fill: red)
- Un métier uniquement focus sur la "_compliance_"
- Un métier fixé sur un objectif très fixe  sans grande différence dans les projets (par exemple analyse de logs)
- Consultance

= Objectifs
#set list(marker: ([•], [‣], [–])) // look up te docs to paste the symbol list
// #set list(marker:default) seems more intuitive
#set text(fill: luma(10))
// #set text(fill : default) no need to check that default color of text is  ...
// default keyword change context based on the object it is attributed to
- a
- b 
- c

Since I clearly don’t yet have the skills to contribute on GitHub, I figured it would be better to discuss it here and let the idea develop a bit before creating a GitHub issue.

In Typst, set rules are scoped, they only apply within the block where they are defined.

If you want them to be temporary, one possibility is to wrap them inside a #[ ... ] block so they don’t affect the rest of the document.

== Je veux / J'aime
#[
#set list(marker: emoji.checkmark)
#set text(fill: green)
- La conception de système et la réflexion associée
- La résolution de problème
- L'analyse de système et de code
- La variété offerte par le domaine, l'évolution constante et le changement de projet
- Ce qui est lié au Forensic, l'enquête, la réflexion ect
]

== Je veux pas
#[
#set list(marker: emoji.crossmark)
#set text(fill: red)
- Un métier uniquement focus sur la "_compliance_"
- Un métier fixé sur un objectif très fixe  sans grande différence dans les projets (par exemple analyse de logs)
- Consultance
]

= Objectifs
- a
- b 
- c

So the default keyword is not mandatory for this usecase.

A good approach will be in this case to create your own lists.

1 Like