From 6718ddef228e265e1229ab24336b433213b81db2 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 26 Mar 2020 21:59:35 +0000 Subject: hyph-utf8, with tlpsrc from arthur git-svn-id: svn://tug.org/texlive/trunk@54568 c570f23f-e606-0410-a88d-b1316a301751 --- .../generic/hyph-utf8/lib/tex/hyphen/converter.rb | 39 ++++++++++++++++++++++ .../hyph-utf8/lib/tex/hyphen/texlive/loader.rb | 2 +- .../hyph-utf8/lib/tex/hyphen/texlive/package.rb | 6 +++- .../hyph-utf8/lib/tex/hyphen/texlive/source.rb | 6 ++-- 4 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb (limited to 'Master/texmf-dist/source/generic/hyph-utf8/lib/tex') diff --git a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb new file mode 100644 index 00000000000..3b966d45a40 --- /dev/null +++ b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/converter.rb @@ -0,0 +1,39 @@ +# encoding: UTF-8 + +require 'scanf' +require 'byebug' + +module TeX + module Hyphen + class Converter + def read(conversion) + @mapping = { } + File.read(conversion).each_line do |line| + next if line =~ /^#/ + + eightbit, usv = line.scanf "0x%02X\tU+%04X" + @mapping[eightbit] = usv.chr(Encoding::UTF_8) + end + end + + def convert(filename) + raise "Please define the encoding mapping first with #read" unless @mapping + doconvert = false + File.open(filename, external_encoding: Encoding::ASCII_8BIT).each_line do |line| + if line =~ /\\patterns{/ + doconvert = true + next + end + doconvert = false if doconvert && line =~ /}/ + + if doconvert + puts (line.strip.each_byte.map do |byte| + byebug unless @mapping[byte] + @mapping[byte] + end || '').join + end + end + end + end + end +end diff --git a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/loader.rb b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/loader.rb index 2fcb3945d30..878bf0ef0d3 100644 --- a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/loader.rb +++ b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/loader.rb @@ -4,7 +4,7 @@ module TeX module Loader def unicode_only? # TODO Spec out - ['cu', 'sa','as','bn','gu','hi','hy','kn','lo','mul-ethi','ml','mr','or','pa','ta','te', 'pi'].include? @bcp47 + ['cu', 'sa','as','bn','gu','hi','hy','kn','lo','mul-ethi','ml','mr','or','pa','ta','te', 'pi', 'mk'].include? @bcp47 end def string_enc diff --git a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/package.rb b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/package.rb index 69481a41774..1d40dc512e8 100644 --- a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/package.rb +++ b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/package.rb @@ -104,7 +104,11 @@ module TeX unless has_dependency? languages.each do |language| if language.use_old_patterns_comment and language.legacy_patterns != "zerohyph.tex" and language.bcp47 != 'cop' - files << sprintf("tex/generic/hyphen/%s", language.legacy_patterns) + if language.bcp47 == 'la-x-classic' + files << sprintf("tex/generic/hyph-utf8/patterns/tex-8bit/%s", language.legacy_patterns) + else + files << sprintf("tex/generic/hyphen/%s", language.legacy_patterns) + end end end end diff --git a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/source.rb b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/source.rb index 61292dcd3bb..dce5be00b41 100644 --- a/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/source.rb +++ b/Master/texmf-dist/source/generic/hyph-utf8/lib/tex/hyphen/texlive/source.rb @@ -82,7 +82,7 @@ module TeX end files << File.join(PATH::HYPHU8, 'patterns', 'tex', sprintf('hyph-%s.tex', bcp47)) - if encoding && encoding != "ascii" then + if encoding && encoding != "ascii" && bcp47 != 'la-x-classic' then files << File.join(PATH::HYPHU8, 'patterns', 'ptex', sprintf('hyph-%s.%s.tex', bcp47, encoding)) elsif bcp47 == "cop" files << File.join(PATH::HYPHU8, 'patterns', 'tex-8bit', legacy_patterns) @@ -91,14 +91,14 @@ module TeX # we skip the mongolian language for luatex files return files if bcp47 == "mn-cyrl-x-lmc" - ['chr', 'pat', 'hyp', 'lic'].each do |t| + ['pat', 'hyp'].each do |t| files << File.join(PATH::HYPHU8, 'patterns', 'txt', sprintf('hyph-%s.%s.txt', bcp47, t)) end if bcp47 =~ /^sh-/ # duplicate entries (will be removed later) files << File.join(PATH::HYPHU8, 'patterns', 'tex', 'hyph-sr-cyrl.tex') - ['chr', 'pat', 'hyp', 'lic'].each do |t| + ['pat', 'hyp'].each do |t| # duplicate entries (will be removed later) files << File.join(PATH::HYPHU8, 'patterns', 'txt', sprintf('hyph-sr-cyrl.%s.txt', t)) end -- cgit v1.2.3