h

hy-dro-gen

@preview

Word hyphenation via bindings to typst/hypher

v0.1.2
MIT

Package Information

Last Updated
Categories
textlanguagesintegration

1. Get the package

Download the package using the TPIX CLI:

tpix get @preview/hy-dro-gen:0.1.2

2. Import in your Typst file

Add this to your .typ file:

#import "@preview/hy-dro-gen:0.1.2": *

Version History

0.1.2
a95631bc3fe6...
0.1.1
6b5790008609...
0.1.0
a0133d51aa01...

Hy-dro-gen

Unofficial bindings from typst/hypher to native Typst.

Full documentation here.

Versions

hy-dro-gen hypher
0.1.0 0.1.5
0.1.1 0.1.6
0.1.2 (latest) 0.1.6 forked to 83aa0d2

Basic usage

#import "@preview/hy-dro-gen:0.1.2" as hy

// `exists` checks if a language is supported
#assert(hy.exists("fr"))
#assert(not hy.exists("xz"))

// `syllables` splits words according to the language provided (default "en")
#assert.eq(hy.syllables("hydrogen"), ("hy", "dro", "gen"))
#assert.eq(hy.syllables("hydrogène", lang: "fr"), ("hy", "dro", "gène"))
#assert.eq(hy.syllables("υδρογόνο", lang: "el"), ("υ", "δρο", "γό", "νο"))

// Use the following to add hyphenation to a language not natively supported
#let trie_ro = hy.trie(
  // Download patterns from github.com:hyphenation/tex-hyphen
  // (look for files 'hyph-{iso}.tex')
  tex: read("patterns/hyph-ro.tex"),
  // (left,right)-hyphenmin on www.hyphenation.org
  bounds: (2, 3),
)
#hy.load-patterns(
  ro: trie_ro,
)
#show: hy.apply-patterns("ro")