diff options
Diffstat (limited to 'Master/texmf-dist/doc/support/lua-uca/README.md')
-rw-r--r-- | Master/texmf-dist/doc/support/lua-uca/README.md | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/Master/texmf-dist/doc/support/lua-uca/README.md b/Master/texmf-dist/doc/support/lua-uca/README.md index 6ef94a49950..918dca7ad29 100644 --- a/Master/texmf-dist/doc/support/lua-uca/README.md +++ b/Master/texmf-dist/doc/support/lua-uca/README.md @@ -2,7 +2,10 @@ # The `Lua-UCA` package \fi -This package adds support for the [Unicode collation algorithm](https://unicode.org/reports/tr10/) for Lua 5.3. +This package adds support for the [Unicode collation algorithm](https://unicode.org/reports/tr10/) for Lua 5.3 and later. +It is mainly intended for use with Lua\TeX and working \TeX\ distribution, but it can work also as a standalone +Lua module. You will need to install a required [Lua-uni-algos](https://github.com/latex3/lua-uni-algos) package by hand +in that case. ## Usage @@ -48,6 +51,9 @@ in Lua by Herbert Voß. It has built-in `Lua-UCA` support starting with version xindex -u -l no -c norsk filename.idx +## Use with LuaJIT + +The default version of `lua-uca-ducet` fails with Luajit. You can use alternative version of this file, `lua-uca-ducet-jit`. ## Change sorting rules @@ -95,6 +101,11 @@ can be enabled using `collator_obj:uppercase_first()` function: tailoring("&ǀ<æ<<<Æ<<ä<<<Ä<ø<<<Ø<<ö<<<Ö<<ő<<<Ő<å<<<Å<<<aa<<<Aa<<<AA") tailoring("&oe<<œ<<<Œ") + +Some languages, for example Canadian French, sort accent backwards, like gêne < gëne < gêné. +In this case, you can set the `collator_obj.accents_backward` variable to `true`. + + % More information on a new language support is in the `HACKING.md` % document in the [`Lua-UCA` Github repo](https://github.com/michal-h21/lua-uca/blob/master/HACKING.md). @@ -116,6 +127,37 @@ In German or Czech, numbers should be sorted after all other characters. This ca The special keyword "others" means that the scripts that follows in the table will be sorted at the very end. +## Headers for index entries + +In some languages, for example Czech, multiple letters may count as one +character. This is the case of the *ch* character. + +Lua-UCA provides function `collator_obj:get_lowest_char()`. It returns table with UTF-8 codepoints +for correct first character for a given language that can be used for example as an index header. + + + local czech = collator.new(ducet) + languages.cs(czech) + -- first we need to convert string to codepoints + local codepoints = czech:string_to_codepoints("Chrobák") + local first_char = czech:get_lowest_char(codepoints) + -- it should print letters "ch" + print(utf8.char(table.unpack(first_char))) + -- you can also specify position of the character + local second_char = czech:get_lowest_char(codepoints, 2) + -- it should print letter "h", as it is second codepoint in the string + print(utf8.char(table.unpack(second_char))) + + +## Unicode normalization + +By default, no Unicode normalization is used internally. You can explicitly request normalization that use the +[Uninormalize package](https://ctan.org/pkg/uninormalize?lang=en). Note that it will significantly increase the +procesing time. + +There are two normalization methods, NFC and NFD. They can be enabled using +`collation.use_nfc()` and `collation.use_nfd()` functions. + # What is missing @@ -125,7 +167,7 @@ will be sorted at the very end. \iffalse # Copyright -Michal Hoftich, 2021. See LICENSE file for more details. +Michal Hoftich, 2021–2024. See LICENSE file for more details. \fi |