• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env ruby
2
3# converts the patterns from upstream git repository to TeX-friendly form
4
5path = File.expand_path("../../hyph-utf8/tex/generic/hyph-utf8/patterns/tex")
6
7# http://git.savannah.gnu.org/cgit/smc.git/tree/hyphenation
8languages = %w(as bn gu hi kn ml mr or pa ta te)
9#languages = %w(as)
10
11languages.each do |language_code|
12	filename = "hyph_#{language_code}_IN.dic"
13	# git://git.sv.gnu.org/smc/hyphenation.git
14  # url      = "http://git.savannah.gnu.org/cgit/smc/hyphenation.git/plain/#{language_code}_IN/#{filename}"
15	url      = "https://raw.githubusercontent.com/santhoshtr/hyphenation/master/#{language_code}_IN/#{filename}"
16	system("wget -N -c -P original #{url}")
17
18	lines = IO.readlines("original/#{filename}", '.').join("").
19# a few temporary patches - remove double newline at the end of file, remove trailing spaces, remove double "GENERAL RULE" comment in the file
20		gsub(/\n\n$/, "\n").gsub(/[ ]*\n/, "\n").
21		# gsub(/(% GENERAL RULE)\n% GENERAL RULE/, '\1').
22# end of temporary patches
23		gsub(/UTF-8/, "% These patterns originate from\n%    https://github.com/santhoshtr/hyphenation/)\n% and have been adapted for hyph-utf8 (for use in TeX).\n%").
24		gsub(/% GENERAL RULE/, "\\patterns{\n% GENERAL RULE") + "}\n"
25
26	filename_out = "#{path}/hyph-#{language_code}.tex"
27	file_out = File.open(filename_out, "w")
28	file_out.puts(lines)
29	file_out.close
30end
31