Skip to content

global lang

This library provides the interface to LuaTeX's structure representing a language, and the associated functions.

😱 Types incomplete or incorrect? 🙏 Please contribute!


methods


lang.new


function lang.new(id: integer?) ->  Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}
@param id - Without an argument, the next available internal id number will be assigned to this object. With an argument, an object will be created that links to the internal language with that id number.

@return - The language object.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Create a new language object, with an optional fixed id number.

Example:

local l1 = lang.new()
print(l1:id())
-- 1

local l42 = lang.new(42)
print(l42:id())
-- 42

Reference:

  • Corresponding C source code: llanglib.c#L27-L48
  • https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/f52b099f3e01d53dc03b315e1909245c3d5418d3/manual/luatex-languages.tex#L944-954

lang.id


function lang.id(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) ->  integer
@param language - The language object.

@return - The number returned is the internal language id number this object refers to.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the current internal language id number.

Example:

local l = lang.new(123)
print(lang.id(l))
-- 123

Reference:

  • Corresponding C source code: llanglib.c#L50-L56
  • https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/f52b099f3e01d53dc03b315e1909245c3d5418d3/manual/luatex-languages.tex#L956-960

lang.hyphenation


function lang.hyphenation(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  hyphenation_exceptions: string
)
@param language - The language object.

Add hyphenation exceptions.

Example:

local l = lang.new()
lang.hyphenation(l, "man-u-script")
print(lang.hyphenation(l)) -- man-u-script
lang.hyphenation(l, "ca-tas-tro-phe")
print(lang.hyphenation(l)) -- man-u-script ca-tas-tro-phe

Reference:

  • Corresponding C source code: llanglib.c#L86-L104
  • https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/f52b099f3e01d53dc03b315e1909245c3d5418d3/manual/luatex-languages.tex#L968-980

lang.hyphenation


function lang.hyphenation(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> hyphenation_exceptions string?
@param language - The language object.

Get the hyphenation exceptions.

Example:

local l = lang.new()
lang.hyphenation(l, "man-u-script")
print(lang.hyphenation(l)) -- man-u-script

Reference:

  • Corresponding C source code: llanglib.c#L86-L104
  • https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/f52b099f3e01d53dc03b315e1909245c3d5418d3/manual/luatex-languages.tex#L968-980

lang.clear_hyphenation


function lang.clear_hyphenation(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
})

Clear the set of hyphenation exceptions.

Example:

local l = lang.new()
print(lang.hyphenation(l)) -- nil
lang.hyphenation(l, "man-u-script")
lang.hyphenation(l, "ca-tas-tro-phe")
print(lang.hyphenation(l)) --  man-u-script ca-tas-tro-phe
lang.clear_hyphenation(l)
print(lang.hyphenation(l)) -- nil

lang.clean


function lang.clean(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  o: string
) -> n string
@param language - The language object.

Clear the exception dictionary (string) for this language.

Reference:

lang.clean


function lang.clean(o: string) -> n string
@param o - The language object.

Clear the exception dictionary (string) for this language.

Reference:

lang.patterns


function lang.patterns(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  patterns: string
)
@param language - The language object.

@param patterns - For example .ab3a .abb2 .ab5erk

😱 Types incomplete or incorrect? 🙏 Please contribute!

Add additional patterns for this language object.

Reference:

lang.patterns


function lang.patterns(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> pattterns string?
@param language - The language object.

@return pattterns - For example .ab3a .abb2 .ab5erk

😱 Types incomplete or incorrect? 🙏 Please contribute!

Return the current set of patterns.

Reference:

lang.clear_patterns


function lang.clear_patterns(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
})

Clear the set of hyphenation patterns.

Clear the pattern dictionary for a language.

Reference:

lang.hyphenationmin


function lang.hyphenationmin(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  min: integer
)

Set the value of the TeX parameter \hyphenationmin.

Reference:

lang.hyphenationmin


function lang.hyphenationmin(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> min integer
@param language - The language object.

Get the value of the TeX parameter \hyphenationmin.

Reference:

lang.prehyphenchar


function lang.prehyphenchar(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  char: integer
)
@param language - The language object.

Set the “pre-break” hyphen characters for implicit hyphenation in this language.

The intial values are decimal 45 (hyphen) and decimal 0 (indicating emptiness).

Reference:

lang.prehyphenchar


function lang.prehyphenchar(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> char integer
@param language - The language object.

Get the “pre-break” hyphen characters for implicit hyphenation in this language.

The intial values are decimal 45 (hyphen) and decimal 0 (indicating emptiness).

Reference:

lang.posthyphenchar


function lang.posthyphenchar(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  char: integer
)
@param language - The language object.

Set the “post-break” hyphen characters for implicit hyphenation in this language.

The intial values are decimal 45 (hyphen) and decimal 0 (indicating emptiness).

Reference:

lang.posthyphenchar


function lang.posthyphenchar(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> char integer
@param language - The language object.

Get the “post-break” hyphen characters for implicit hyphenation in this language.

The intial values are decimal 45 (hyphen) and decimal 0 (indicating emptiness).

Reference:

lang.preexhyphenchar


function lang.preexhyphenchar(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  char: integer
)
@param language - The language object.

Set the “pre-break” hyphen characters for explicit hyphenation in this language.

The hyphen character is initially decimal 0 (indicating emptiness).

Reference:

lang.preexhyphenchar


function lang.preexhyphenchar(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> char integer
@param language - The language object.

Get the “pre-break” hyphen characters for explicit hyphenation in this language.

The hyphen character is initially decimal 0 (indicating emptiness).

Reference:

lang.postexhyphenchar


function lang.postexhyphenchar(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  char: integer
)
@param language - The language object.

Set the “post-break” hyphen characters for explicit hyphenation in this language.

The hyphen character is initially decimal 0 (indicating emptiness).

Reference:

lang.postexhyphenchar


function lang.postexhyphenchar(language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
}) -> char integer
@param language - The language object.

Get the “post-break” hyphen characters for explicit hyphenation in this language.

The hyphen character is initially decimal 0 (indicating emptiness).

Reference:

lang.hyphenate


function lang.hyphenate(
  head: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
},
  tail: Node?
) -> success boolean

Hyphenate a node list.

Insert hyphenation points (discretionary nodes) in a node list.

If tail is given as argument, processing stops on that node. Currently, success is always true if head (and tail, if specified) are proper nodes, regardless of possible other errors.

Hyphenation works only on “characters”, a special subtype of all the glyph nodes with the node subtype having the value 1. Glyph modes with different subtypes are not processed.

Reference:

lang.sethjcode


function lang.sethjcode(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  char: integer,
  used_char: integer
)
@param language - The language object.

Set hj codes.

When you set a hjcode the current sets get initialized unless the set was already initialized due to \savinghyphcodes being larger than zero.

Reference:

lang.gethjcode


function lang.gethjcode(
  language: Language {
    id = function,
    hyphenation = function,
    hyphenation = function,
    clear_hyphenation = function,
    patterns = function,
    patterns = function,
},
  char: number
) -> used_char integer
@param language - The language object.

Query hj codes.

Reference: