Closed xu-cheng closed 8 years ago
Fixed by following scripts:
#!/usr/bin/env ruby
require "pathname"
class Fixer
attr_reader :file
attr_reader :content
def initialize(file)
@file = Pathname.new file
@content = file.read
end
def fix!
puts "==> Fixing #{file}"
puts "Global linespread: #{global_linespread}"
content.gsub! '\pdfpagewidth', '\pagewidth'
content.gsub! '\pdfpageheight', '\pageheight'
content.gsub! '\usepackage{interfaces-LaTeX}' + "\n", ""
content.gsub! '\RequirePackage{interfaces-LaTeX}' + "\n", ""
content.gsub! 'Use \pkgurl{interfaces} package to handle font size and line spread. ', ""
content.gsub! 'Use \href{http://mirrors.ctan.org/help/Catalogue/entries/interfaces}{\texttt{interfaces}} package to handle font size and line spread. ', ""
content.gsub! '\RequirePackage[all]{xy}' + "\n", ""
content.gsub! /[^\n]*xypic[^\n]*\n/m, ""
content.gsub! '\tl_expandable_lowercase:n', '\str_fold_case:n'
change_font_cmds = content.scan(/\\changefont{[^}]*}/)
change_font_cmds.each do |cmd|
fix_change_font_cmd(cmd)
end
file.write content
end
def global_linespread
@global_linespread ||= content[/We set global line spread to (\d\.\d)./, 1].to_f
end
def fix_change_font_cmd(cmd)
size = cmd[/size=([^,}]*)/, 1]
if size
raise "Unknown size unit #{size}" unless size.end_with? "pt"
size_f = size[0...-2].to_f
end
linespread = cmd[/linespread=([^,}]*)/, 1]
new_cmd = if size && linespread
"\\fontsize{#{size}}{#{(size_f * linespread.to_f).round(1)}pt}\\selectfont"
elsif size
"\\fontsize{#{size}}{#{(size_f * global_linespread).round(1)}pt}\\selectfont"
elsif linespread
"\\linespread{#{linespread}}\\selectfont"
else
""
end
puts "#{cmd} -> #{new_cmd}"
content.gsub! cmd, new_cmd
end
end
ROOT = Pathname.new "/Users/xucheng/dev/git/hust-latex"
Pathname.glob(ROOT/"**/*.dtx") do |dtx|
Dir.chdir(dtx.parent.parent) do
system "git checkout ."
end
fixer = Fixer.new dtx
fixer.fix!
message = <<-EOS
#{dtx.basename(".dtx")}: fix for TeXLive 2016
* remove interfaces
* remove xypic
* other fixes
EOS
Dir.chdir(dtx.parent.parent) do
system "make", "clean"
system "git", "add", dtx.to_s
system "git", "commit", "-m", message
end
end
Very good. Thanks for the update.
It caused a long time known issue with pgf 3.0 and stops us to upload template to CTAN (#20)