summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb')
-rw-r--r--Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb219
1 files changed, 129 insertions, 90 deletions
diff --git a/Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb b/Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb
index 3c94441229c..9ea3ca061f8 100644
--- a/Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb
+++ b/Master/texmf-dist/source/generic/hyph-utf8/generate-pattern-loaders.rb
@@ -16,74 +16,108 @@ languages = Languages.new.list
#text_if_native_utf = "\input pattern-loader.tex\n\\ifNativeUtfEightPatterns"
-text_if_native_utf = <<EOT
-% Test whether we received one or two arguments
-\\def\\testengine#1#2!{\\def\\secondarg{#2}}
-% That's Tau (as in Taco or ΤΕΧ, Tau-Epsilon-Chi), a 2-byte UTF-8 character
-\\testengine Τ!\\relax
-% Unicode-aware engine (such as XeTeX or LuaTeX) only sees a single (2-byte) argument
-\\ifx\\secondarg\\empty
-EOT
-
languages.each do |language|
+
+string_enc = (language.encoding == nil) ? "" : language.encoding.upcase + " "
+
+################
+# Header texts #
+################
+
+# a message about auto-generation
+# TODO: write a more comprehensive one
+text_header =
+"% filename: loadhyph-#{language.code}.tex
+% language: #{language.name}
+%
+% Loader for hyphenation patterns, generated by
+% source/generic/hyph-utf8/generate-pattern-loaders.rb
+% See also http://tug.org/tex-hyphen
+%
+% Copyright 2008-2011 TeX Users Group.
+% You may freely use, modify and/or distribute this file.
+% (But consider adapting the scripts if you need modifications.)
+%
+% Once it turns out that more than a simple definition is needed,
+% these lines may be moved to a separate file.
+%"
+
+text_if_native_utf =
+'% Test for pTeX
+\\ifx\\kanjiskip\\undefined
+% Test for native UTF-8 (which gets only a single argument)
+% That\'s Tau (as in Taco or ΤΕΧ, Tau-Epsilon-Chi), a 2-byte UTF-8 character
+\\def\\testengine#1#2!{\\def\\secondarg{#2}}\\testengine Τ!\\relax
+\\ifx\\secondarg\\empty'
+
+comment_engine_utf8 = "% Unicode-aware engine (such as XeTeX or LuaTeX) only sees a single (2-byte) argument"
+comment_engine_8bit = "% 8-bit engine (such as TeX or pdfTeX)"
+comment_engine_ptex = "% pTeX"
+
+text_engine_ascii = ["% ASCII patterns - no additional support is needed",
+ "\\message{ASCII #{language.message}}",
+ "\\input hyph-#{language.code}.tex"]
+text_engine_utf8 = [" #{comment_engine_utf8}",
+ " \\message{UTF-8 #{language.message}}"]
+text_engine_8bit = [" #{comment_engine_8bit}",
+ " \\message{#{string_enc}#{language.message}}"]
+text_engine_ptex = [" #{comment_engine_ptex}",
+ " \\message{#{string_enc}#{language.message}}"]
+text_engine_8bit_no = [" #{comment_engine_8bit}",
+ " \\message{No #{language.message} - only for Unicode engines}",
+ " %\\input zerohyph.tex"]
+text_engine_ptex_no = [" #{comment_engine_ptex}",
+ " \\message{No #{language.message} - only for Unicode engines}",
+ " %\\input zerohyph.tex"]
+text_patterns = " \\input hyph-#{language.code}.tex"
+text_patterns_ptex = " \\input phyph-#{language.code}.tex"
+text_patterns_old = " \\input #{language.filename_old_patterns}"
+text_patterns_conv = " \\input conv-utf8-#{language.encoding}.tex"
+
+###########
+# lccodes #
+###########
+
+lccodes_common = []
+if language.code == 'af' or language.code == 'it' or language.code == 'fr' or language.code == 'uk' or language.code == 'zh-latn' then
+ lccodes_common.push("\\lccode`\\'=`\\'")
+end
+if language.code == 'af' or language.code == 'pt' or language.code == 'tk' or language.code == 'ru' or language.code == 'uk' then
+ lccodes_common.push("\\lccode`\\-=`\\-")
+end
+
if language.use_new_loader then
- filename = "#{$path_loadhyph}/loadhyph-#{language.code}.tex"
+ if language.code == 'sh-latn' then
+ filename = "#{$path_loadhyph}/loadhyph-sr-latn.tex"
+ else
+ filename = "#{$path_loadhyph}/loadhyph-#{language.code}.tex"
+ end
puts "generating '#{filename}'"
+
File.open(filename, "w") do |file|
- # a message about auto-generation
- # TODO: write a more comprehensive one
- file.puts "% loadhyph-#{language.code}.tex"
- file.puts "%"
- file.puts "% Autogenerated loader for hyphenation patterns for \"#{language.name}\""
- file.puts "% by source/generic/hyph-utf8/generate-pattern-loaders.rb"
- file.puts "% See also http://tug.org/tex-hyphen"
- file.puts "%"
- file.puts "% Copyright 2008 TeX Users Group."
- file.puts "% You may freely use, modify and/or distribute this file."
- file.puts "% (But consider adapting the scripts if you need modifications.)"
- file.puts "%"
- file.puts "% Once it turns out that more than a simple definition is needed,"
- file.puts "% these lines may be moved to a separate file."
- file.puts "%"
-
- # message (where it exists)
- # if language.message != nil
- # file.puts("\\message{#{language.message}}\n%")
- # end
-
- # TODO:
- # \lefthyphenmin=2 \righthyphenmin=2
- # but probably this needs to reside outside of \begingroup/endgroup
-
+ file.puts text_header
file.puts('\begingroup')
- if language.code == 'af' or language.code == 'it' or language.code == 'fr' or language.code == 'uk' or language.code == 'zh-latn' then
- file.puts("\\lccode`\\'=`\\'")
- end
- if language.code == 'pt' or language.code == 'tk' then
- file.puts("\\lccode`\\-=`\\-")
+
+ if lccodes_common.length > 0 then
+ file.puts lccodes_common.join("\n")
end
-
+
+########################################
+# GROUP nr. 1 - ONLY USABLE WITH UTF-8 #
+########################################
# some special cases firs
#
# some languages (sanskrit) are useless in 8-bit engines; we only want to load them for UTF engines
# TODO - maybe consider doing something similar for ibycus
- if language.code == 'sa' or
- language.code == 'as' or
- language.code == 'bn' or
- language.code == 'gu' or
- language.code == 'hi' or
- language.code == 'hy' or
- language.code == 'kn' or
- language.code == 'lo' or
- language.code == 'ml' or
- language.code == 'mr' or
- language.code == 'or' or
- language.code == 'pa' or
- language.code == 'ta' or
- language.code == 'te' then
+ if ['sa','as','bn','gu','hi','hy','kn','lo','mul-ethi','ml','mr','or','pa','ta','te'].include?(language.code) then
file.puts(text_if_native_utf)
- file.puts(" \\message{UTF-8 #{language.message}}")
- if language.code != 'lo' then
+ file.puts(text_engine_utf8)
+ # lccodes
+ if language.code == 'mul-ethi' then
+ file.puts(' % Set \lccode for Ethiopian word space.')
+ file.puts(' \lccode"1361="1361')
+ file.puts(' \lccode"1362="1362')
+ elsif language.code != 'lo' then
file.puts(' % Set \lccode for ZWNJ and ZWJ.')
file.puts(' \lccode"200C="200C')
file.puts(' \lccode"200D="200D')
@@ -93,38 +127,38 @@ languages.each do |language|
file.puts(' \lccode"0CF2="0CF2')
end
end
- file.puts(" \\input hyph-#{language.code}.tex")
+ file.puts(text_patterns)
file.puts('\else')
- file.puts(" \\message{No #{language.message} - only available with Unicode engines}")
- file.puts(' \input zerohyph.tex')
+ file.puts(text_engine_8bit_no)
+ file.puts('\fi\else')
+ file.puts(text_engine_ptex_no)
file.puts('\fi')
+
+#######################
+# GROUP nr. 2 - ASCII #
+#######################
# for ASCII encoding, we don't load any special support files, but simply load everything
elsif language.encoding == "ascii" then
- file.puts('% ASCII patterns - no additional support is needed')
- # for UK English we simply load the old file without bothering about renaming it
- if language.use_old_patterns then
- file.puts("\\input #{language.filename_old_patterns}")
- # for the rest we load the new file
- else
- file.puts("\\message{ASCII #{language.message}}")
- file.puts("\\input hyph-#{language.code}.tex")
- end
+ file.puts(text_engine_ascii)
+####################################
+# GROUP nr. 3 - different patterns #
+####################################
# when lanugage uses old patterns for 8-bit engines, load two different patterns rather than using the converter
elsif language.use_old_patterns then
file.puts(text_if_native_utf)
- file.puts(" \\message{UTF-8 #{language.message}}")
+ file.puts(text_engine_utf8)
# some catcodes for XeTeX
if language.code == 'grc' or language.code.slice(0,2) == 'el' then
file.puts(" \\lccode`'=`'\\lccode`’=`’\\lccode`ʼ=`ʼ\\lccode`᾽=`᾽\\lccode`᾿=`᾿")
end
- file.puts(" \\input hyph-#{language.code}.tex")
+ file.puts(text_patterns)
# russian and ukrainian exceptions - hacks with dashes
if language.code == 'ru' or language.code == 'uk' then
file.puts(' % Additional patterns with hyphen/dash: a hack to prevent breaking after hyphen, but not before.')
file.puts(" \\input exhyph-#{language.code}.tex")
end
file.puts('\else')
- file.puts(" \\message{#{language.message}}")
+ file.puts(text_engine_8bit)
# explain why we are still using the old patterns
if language.use_old_patterns_comment != nil then
file.puts(" % #{language.use_old_patterns_comment}")
@@ -132,30 +166,35 @@ languages.each do |language|
puts "Missing comment for #{language.name}"
file.puts(' % we still load old patterns for 8-bit TeX')
end
- file.puts(" \\input #{language.filename_old_patterns}")
+ file.puts(text_patterns_old)
+ file.puts('\fi\else')
+ file.puts(text_engine_ptex)
+ # greek, coptic
+ if language.encoding == nil then
+ file.puts(text_patterns_old)
+ else
+ file.puts(text_patterns_ptex)
+ end
file.puts('\fi')
+#########################
+# GROUP nr. 4 - regular #
+#########################
else
file.puts(text_if_native_utf)
- file.puts(" \\message{UTF-8 #{language.message}}")
+ file.puts(text_engine_utf8)
+ file.puts(text_patterns)
file.puts('\else')
- file.puts(" \\message{#{language.encoding.upcase} #{language.message}}")
- # a hack for OT1 encoding in three languages
- if language.code == 'da' or language.code == 'fr' then
- file.puts(" % A hack to support both EC and OT1 encoding in 8-bit engines.")
- file.puts(" % Kept for backward compatibility only, though we would prefer to drop it.")
- file.puts(" % OT1 encoding is close-to-useless for proper hyphenation.")
- file.puts(" \\input spechyph-ot1-#{language.code}.tex")
- end
- file.puts(" \\input conv-utf8-#{language.encoding}.tex")
+ file.puts(text_engine_8bit)
+ file.puts(text_patterns_conv)
+ file.puts(text_patterns)
+ file.puts('\fi\else')
+ file.puts(text_engine_ptex)
+ file.puts(text_patterns_ptex)
file.puts('\fi')
- if language.code == 'sr-latn' then
- file.puts("% Load Serbo-Croatian patterns")
- file.puts("\\input hyph-sh-latn.tex")
- else
- file.puts("\\input hyph-#{language.code}.tex")
- end
-# file.puts("\\loadhyphpatterns{#{language.code}}{#{language.encoding}}%")
end
+#######
+# end #
+#######
file.puts('\endgroup')
end
end