diff options
Diffstat (limited to 'tex/context/base/lang-ini.lua')
-rw-r--r-- | tex/context/base/lang-ini.lua | 74 |
1 files changed, 54 insertions, 20 deletions
diff --git a/tex/context/base/lang-ini.lua b/tex/context/base/lang-ini.lua index d75a665e2..46ccdec35 100644 --- a/tex/context/base/lang-ini.lua +++ b/tex/context/base/lang-ini.lua @@ -16,10 +16,13 @@ if not modules then modules = { } end modules ['lang-ini'] = { --~ lang:hyphenation(string) string = lang:hyphenation() lang:clear_hyphenation() +-- todo: no foo:bar but foo(bar,...) + local type, tonumber = type, tonumber local utfbyte = utf.byte local format, gsub = string.format, string.gsub local concat, sortedkeys, sortedpairs = table.concat, table.sortedkeys, table.sortedpairs +local utfbytes = string.utfvalues local context = context local commands = commands @@ -31,33 +34,37 @@ local trace_patterns = false trackers.register("languages.patterns", function(v local report_initialization = logs.reporter("languages","initialization") +local lang = lang + local prehyphenchar = lang.prehyphenchar -- global per language local posthyphenchar = lang.posthyphenchar -- global per language local preexhyphenchar = lang.preexhyphenchar -- global per language local postexhyphenchar = lang.postexhyphenchar -- global per language local lefthyphenmin = lang.lefthyphenmin local righthyphenmin = lang.righthyphenmin +local sethjcode = lang.sethjcode + +local uccodes = characters.uccodes -local lang = lang -lang.exceptions = lang.hyphenation -local new_langage = lang.new +lang.exceptions = lang.hyphenation +local new_langage = lang.new -languages = languages or {} -local languages = languages +languages = languages or {} +local languages = languages -languages.version = 1.010 +languages.version = 1.010 -languages.registered = languages.registered or { } -local registered = languages.registered +languages.registered = languages.registered or { } +local registered = languages.registered -languages.associated = languages.associated or { } -local associated = languages.associated +languages.associated = languages.associated or { } +local associated = languages.associated -languages.numbers = languages.numbers or { } -local numbers = languages.numbers +languages.numbers = languages.numbers or { } +local numbers = languages.numbers -languages.data = languages.data or { } -local data = languages.data +languages.data = languages.data or { } +local data = languages.data storage.register("languages/registered",registered,"languages.registered") storage.register("languages/associated",associated,"languages.associated") @@ -107,7 +114,8 @@ end -- patterns=en -- patterns=en,de -local function validdata(dataset,what,tag) +local function validdata(loaded,what,tag) + local dataset = loaded[what] if dataset then local data = dataset.data if not data or data == "" then @@ -124,6 +132,31 @@ local function validdata(dataset,what,tag) end end +local function sethjcodes(instance,loaded,what) + local l = loaded[what] + local c = l and l.characters + if c then + local h = l.codehash + if not h then + h = { } + l.codehash = h + end + local s = tex.savinghyphcodes + tex.savinghyphcodes = 0 + for l in utfbytes(c) do + local u = uccodes[l] + sethjcode(instance,l,l) + h[l] = l + if type(u) == "number" then + -- we don't want ß -> SS + sethjcode(instance,u,l) + h[u] = l + end + end + tex.savinghyphcodes = s + end +end + local function loaddefinitions(tag,specification) statistics.starttiming(languages) local data, instance = resolve(tag) @@ -160,12 +193,13 @@ local function loaddefinitions(tag,specification) local loaded = table.load(fullname,gzipped and gzip.load) if loaded then -- todo: version test ok, nofloaded = true, nofloaded + 1 - -- instance:patterns (loaded.patterns and resources.patterns .data or "") - -- instance:hyphenation(loaded.exceptions and resources.exceptions.data or "") - instance:patterns (validdata(loaded.patterns, "patterns", tag) or "") - instance:hyphenation(validdata(loaded.exceptions,"exceptions",tag) or "") +if sethjcodes then -- for now + sethjcodes(instance,loaded,"patterns") + sethjcodes(instance,loaded,"exceptions") +end + instance:patterns (validdata(loaded,"patterns", tag) or "") + instance:hyphenation(validdata(loaded,"exceptions",tag) or "") resources[#resources+1] = loaded -- so we can use them otherwise - else report_initialization("invalid definition %a for language %a in %a",definition,tag,filename) end |