In Czech, when writing some more advanced documents, there is a rule, where conjunctions cannot line wrap, in another words, it cannot be the last character on a line. If the rendered output looked like this:
Dnes jsme přijeli domů a
rozbalili nákup.
it’d be incorrect as the first line ends with a
. A correct example would have a
on the start of the second line. This also applies if the characters are the first word in a sentence. This example:
Mánička dnes dojela domů. K
tomu všemu nestihla ani rozbalit nákup.
is also incorrect.
The conjunctions (not only conjunctions, but it’s the closest word) are these: ["a","A","k","K","i", "I", "u", "U", "s", "S", "o", "O", "v", "V"]
.
The most manual solution is to insert unbreakable space after each conjunction, like so:
Máma dnes dojela domů a~rozbalila nákup.
It gets very tedious and I was wondering, is there a way to do it automatically for every paragraph?
I tried using regex to match and replace, however typst’s regex cannot use lookahead and cannot replace only specific capture groups. Another solution is to use individual show rules, like so:
#show " a ": [ a~]
#show " i ": [ i~]
However, as you can see, it can get very tedious.