summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-11-04 20:26:59 +0000
committerKarl Berry <karl@freefriends.org>2018-11-04 20:26:59 +0000
commit100a6835ee4907ef9a8778ae422fa36f9791fbbd (patch)
treefb33cd50758aa1319519d277613a6d95c0b95f64 /Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb
parent52c5fa5fd97e408e01da7adf772db57671796c92 (diff)
hyph-utf (4nov18)
git-svn-id: svn://tug.org/texlive/trunk@49078 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb')
-rw-r--r--Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb289
1 files changed, 47 insertions, 242 deletions
diff --git a/Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb b/Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb
index 845d43951c0..223b3f04579 100644
--- a/Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb
+++ b/Master/texmf-dist/source/generic/hyph-utf8/generate-tl-files.rb
@@ -4,274 +4,79 @@
# this file auto-generates tlpsrc files for hyphenation patterns - to be improved
require_relative 'languages.rb'
-
-$package_name="hyph-utf8"
-
-# TODO - make this a bit less hard-coded
-$path_tex_generic=File.expand_path("../../../../tex/generic", __FILE__)
-$path_TL=File.expand_path("../../../../../TL", __FILE__)
-$path_language_dat="#{$path_TL}/texmf-dist/tex/generic/config"
-# hyphen-foo.tlpsrc for TeX Live
-$path_tlpsrc="#{$path_TL}/tlpkg/tlpsrc"
-
-$path_txt="#{$path_tex_generic}/#{$package_name}/patterns/txt"
-
-$l = Languages.new
-# TODO: should be singleton
-languages = $l.list.sort{|a,b| a.name <=> b.name}
-
-language_grouping = {
- 'english' => ['en-gb', 'en-us'],
- 'norwegian' => ['nb', 'nn'],
- 'german' => ['de-1901', 'de-1996', 'de-ch-1901'],
- 'mongolian' => ['mn-cyrl', 'mn-cyrl-x-lmc'],
- 'greek' => ['el-monoton', 'el-polyton'],
- 'ancientgreek' => ['grc', 'grc-x-ibycus'],
- 'chinese' => ['zh-latn-pinyin'],
- 'indic' => ['as', 'bn', 'gu', 'hi', 'kn', 'ml', 'mr', 'or', 'pa', 'ta', 'te'],
- 'serbian' => ['sh-latn', 'sh-cyrl'],
- 'latin' => ['la', 'la-x-classic', 'la-x-liturgic'],
-}
-
-language_used_in_group = Hash.new
-language_grouping.each_value do |group|
- group.each do |code|
- language_used_in_group[code] = true
- end
-end
-
-# a hash with language name as key and array of languages as the value
-language_groups = Hash.new
-# single languages first
-languages.each do |language|
- # temporary remove cyrilic serbian until someone explains what is needed
- if language.code == 'sr-cyrl' or language.code == 'en-us' then
- # ignore the language
- elsif language_used_in_group[language.code] == nil then
- language_groups[language.name] = [language]
- end
-
- if language.code == 'sh-latn' then
- language.code = 'sr-latn'
- elsif language.code == 'sh-cyrl' then
- language.code = 'sr-cyrl'
- end
-end
-
-# then groups of languages
-language_grouping.each do |name,group|
- language_groups[name] = []
- group.each do |code|
- language_groups[name].push($l[code])
- end
-end
-
-# languages.each do |language|
-# if language.hyphenmin == nil then
-# lmin = ''
-# rmin = ''
-# else
-# lmin = language.hyphenmin[0]
-# rmin = language.hyphenmin[1]
-# end
-# puts "#{language.name}: #{lmin} #{rmin}"
-# end
+include Language::TeXLive
+include TeXLive
#--------#
# TLPSRC #
#--------#
-language_groups.sort.each do |language_name,language_list|
- files_path_hyph8 = "tex/generic/hyph-utf8"
- files_run = []
- files_doc = []
- files_src = []
- $file_tlpsrc = File.open("#{$path_tlpsrc}/hyphen-#{language_name}.tlpsrc", 'w')
- puts "generating #{$path_tlpsrc}/hyphen-#{language_name}.tlpsrc"
-
- #$file_tlpsrc.puts "name hyphen-#{language_name}"
- $file_tlpsrc.puts "category TLCore"
- $file_tlpsrc.puts "depend hyphen-base"
- $file_tlpsrc.puts "depend hyph-utf8"
-
- # external dependencies for Russian and Ukrainian (until we implement the new functionality at least)
- if language_name == "russian" then
- $file_tlpsrc.puts "depend ruhyphen"
- elsif language_name == "ukrainian" then
- $file_tlpsrc.puts "depend ukrhyph"
- elsif language_name == "norwegian" then
- files_run.push("#{files_path_hyph8}/patterns/tex/hyph-no.tex")
- end
- language_list.each do |language|
- if language.description_s != nil then
- $file_tlpsrc.puts "shortdesc #{language.description_s}."
- $file_tlpsrc.puts "longdesc #{language.description_l.join("\nlongdesc ")}"
- # if language.version != nil then
- # $file_tlpsrc.puts "catalogue-version #{language.version}"
- # end
- end
- name = "name=#{language.name}"
- # synonyms
- if language.synonyms != nil and language.synonyms.length > 0 then
- synonyms=" synonyms=#{language.synonyms.join(',')}"
- else
- synonyms=""
- end
- # lefthyphenmin/righthyphenmin
- if language.hyphenmin == nil or language.hyphenmin.length == 0 then
- lmin = ''
- rmin = ''
- elsif language.filename_old_patterns == "zerohyph.tex" then
- lmin = ''
- rmin = ''
- else
- lmin = language.hyphenmin[0]
- rmin = language.hyphenmin[1]
- end
- hyphenmins = "lefthyphenmin=#{lmin} \\\n\trighthyphenmin=#{rmin}"
- # which file to use
- file = ""
- file_patterns = ""
- file_exceptions = ""
- if language.use_new_loader then
- file = "file=loadhyph-#{language.code}.tex"
- files_run.push("#{files_path_hyph8}/loadhyph/loadhyph-#{language.code}.tex")
- if language.has_quotes then
- files_run.push("#{files_path_hyph8}/patterns/quote/hyph-quote-#{language.code}.tex")
- end
-
- if language.code == "mn-cyrl-x-lmc" then
- files_run.push("#{files_path_hyph8}/patterns/tex/hyph-#{language.code}.tex")
- files_run.push("#{files_path_hyph8}/patterns/ptex/hyph-#{language.code}.#{language.encoding}.tex")
- # we skip the mongolian language for luatex files
- else
- if language.code == "sr-latn" or language.code == "sr-cyrl" then
- code = language.code.gsub(/sr/, "sh")
- filename_pat = "hyph-sh-latn.pat.txt,hyph-sh-cyrl.pat.txt"
- filename_hyp = "hyph-sh-latn.hyp.txt,hyph-sh-cyrl.hyp.txt"
-
- files_run.push("#{files_path_hyph8}/patterns/tex/hyph-#{code}.tex")
- files_run.push("#{files_path_hyph8}/patterns/ptex/hyph-#{code}.#{language.encoding}.tex")
- # duplicate entries (will be removed later)
- files_run.push("#{files_path_hyph8}/patterns/tex/hyph-sr-cyrl.tex")
- ['chr', 'pat', 'hyp', 'lic'].each do |t|
- files_run.push("#{files_path_hyph8}/patterns/txt/hyph-#{code}.#{t}.txt")
- # duplicate entries (will be removed later)
- files_run.push("#{files_path_hyph8}/patterns/txt/hyph-sr-cyrl.#{t}.txt")
- end
- else
- filename_pat = "hyph-#{language.code}.pat.txt"
- filename_hyp = "hyph-#{language.code}.hyp.txt"
-
- files_run.push("#{files_path_hyph8}/patterns/tex/hyph-#{language.code}.tex")
- if language.encoding != nil and language.encoding != "ascii" then
- files_run.push("#{files_path_hyph8}/patterns/ptex/hyph-#{language.code}.#{language.encoding}.tex")
- elsif language.code == "cop" then
- files_run.push("#{files_path_hyph8}/patterns/tex-8bit/#{language.filename_old_patterns}")
- # files_run.push("#{files_path_hyph8}/patterns/tex-8bit/copthyph.tex")
- end
- ['chr', 'pat', 'hyp', 'lic'].each do |t|
- files_run.push("#{files_path_hyph8}/patterns/txt/hyph-#{language.code}.#{t}.txt")
- end
+Package.all.sort.each do |package|
+ tlpsrcname = File.join(PATH::TLPSRC, sprintf('hyphen-%s.tlpsrc', package.name.safe))
+ file_tlpsrc = File.open(tlpsrcname, 'w')
+ printf "generating %s\n", tlpsrcname
- # check for existance of patterns and exceptions
- if !File::exists?( "#{$path_txt}/#{filename_pat}" ) then
- puts "some problem with #{$path_txt}/#{filename_pat}!!!"
- end
- if !File::exists?( "#{$path_txt}/#{filename_hyp}" ) then
- puts "some problem with #{$path_txt}/#{filename_hyp}!!!"
- end
- end
+ file_tlpsrc.puts "category TLCore"
+ package.list_dependencies.each do |dependency|
+ file_tlpsrc.puts dependency
+ end
- file_patterns = "file_patterns=#{filename_pat}"
- if File::size?( "#{$path_txt}/#{filename_hyp}" ) != nil then
- file_exceptions = "file_exceptions=#{filename_hyp}"
- # TODO: nasty workaround
- elsif language.code == "sr-latn" or language.code == "sr-cyrl" then
- file_exceptions = "file_exceptions=#{filename_hyp}"
- else
- file_exceptions = "file_exceptions="
- # puts "> #{filename_hyp} is empty"
- end
- end
- else
- file = "file=#{language.filename_old_patterns}"
- if language.code == 'ar' or language.code == 'fa' then
- file = file + " \\\n\tfile_patterns="
- elsif language.code == 'grc-x-ibycus' then
- # TODO: fix this
- file = file + " \\\n\tluaspecial=\"disabled:8-bit only\""
- end
+ # FIXME Still doesn’t work well for Latin
+ file_tlpsrc.printf "shortdesc %s.\n", package.description_s
+ package.description_l.each do |line|
+ file_tlpsrc.printf "longdesc %s\n", line
+ end
+ package.languages.each do |language|
+ if language.description_s && language.description_l then
+ # file_tlpsrc.printf "shortdesc %s.\n", language.description_s
+ # language.description_l.each do |line|
+ # file_tlpsrc.printf "longdesc %s\n", line
+ # end
end
- $file_tlpsrc.puts "execute AddHyphen \\\n\t#{name}#{synonyms} \\"
- $file_tlpsrc.print "\t#{hyphenmins} \\\n\t#{file}"
- if file_patterns + file_exceptions != ""
- $file_tlpsrc.print " \\\n\t#{file_patterns} \\\n\t#{file_exceptions}"
+ file_tlpsrc.printf "execute AddHyphen \\\n\tname=%s%s \\\n", language.name.safe, language.list_synonyms
+ file_tlpsrc.printf "\t%s \\\n\t%s", language.list_hyphenmins, language.list_loader
+ if language.patterns_line + language.exceptions_line != ""
+ file_tlpsrc.printf " \\\n\t%s \\\n\t%s", language.patterns_line, language.exceptions_line
end
if language.code == "mn-cyrl-x-lmc" then
- $file_tlpsrc.print " \\\n\tluaspecial=\"disabled:only for 8bit montex with lmc encoding\""
+ file_tlpsrc.printf " \\\n\tluaspecial=\"disabled:only for 8bit montex with lmc encoding\""
end
# end-of-line
- $file_tlpsrc.puts
-
- # add sources
- if ['es', 'eu', 'gl', 'hy', 'mul-ethi', 'tk', 'tr'].include?(language.code) then
- files_src.push("source/generic/hyph-utf8/languages/#{language.code}")
- end
- # add documentation
- if ['bg', 'es', 'hu', 'sa'].include?(language.code) then
- files_doc.push("doc/generic/hyph-utf8/#{language.code}")
- end
- end
- if language_name != "russian" and language_name != "ukrainian" then
- language_list.each do |language|
- if language.use_old_patterns and language.filename_old_patterns != "zerohyph.tex" and language.filename_old_patterns != "copthyph.tex" then
- files_run.push("tex/generic/hyphen/#{language.filename_old_patterns}")
- end
- end
+ file_tlpsrc.puts
end
- # documeentation
- if language_name == "greek" then
- files_doc.push("doc/generic/elhyphen")
- elsif language_name == "hungarian" then
- files_doc.push("doc/generic/huhyphen")
- elsif language_name == "german" then
- files_run.push("tex/generic/hyphen/dehyphtex.tex")
- files_run.push("tex/generic/hyphen/ghyphen.README")
+ # documentation
+ package.list_support_files('doc').sort.each do |filename|
+ file_tlpsrc.printf "docpattern d texmf-dist/%s\n", filename
end
- files_doc.sort.each do |f|
- $file_tlpsrc.puts "docpattern d texmf-dist/#{f}"
- end
- files_src.sort.each do |f|
- $file_tlpsrc.puts "srcpattern d texmf-dist/#{f}"
+ # sources
+ package.list_support_files('source').sort.each do |filename|
+ file_tlpsrc.printf "srcpattern d texmf-dist/%s\n", filename
end
- files_run.sort.uniq.each do |f|
- $file_tlpsrc.puts "runpattern f texmf-dist/#{f}"
+
+ package.list_run_files.sort.uniq.each do |filename|
+ file_tlpsrc.printf "runpattern f texmf-dist/%s\n", filename
end
- $file_tlpsrc.close
+ file_tlpsrc.close
end
#--------------#
# language.dat #
#--------------#
-$file_language_dat = File.open("#{$path_language_dat}/language.dat", "w")
-language_groups.sort.each do |language_name,language_list|
- language_list.each do |language|
- if language.use_new_loader then
- $file_language_dat.puts "#{language.name}\tloadhyph-#{language.code}.tex"
- else
- $file_language_dat.puts "#{language.name}\t#{language.filename_old_patterns}"
- end
-
- # synonyms
- if language.synonyms != nil then
+language_dat_filename = File.join PATH::LANGUAGE_DAT, 'language.dat'
+File.open(language_dat_filename, 'w') do |file_language_dat|
+ printf "Generating %s\n", language_dat_filename
+ Package.all.sort.each do |package|
+ package.languages.each do |language|
+ # main language name
+ file_language_dat.printf "%s\t%s\n", language.name.safe, language.loadhyph
+
+ # synonyms
language.synonyms.each do |synonym|
- $file_language_dat.puts "=#{synonym}"
+ file_language_dat.printf "=%s\n", synonym
end
end
end
end
-$file_language_dat.close