Last active
December 11, 2015 17:39
-
-
Save shirashin/4636177 to your computer and use it in GitHub Desktop.
del_color.rb <dir>
del_color.rb <file>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Remove color tag("\color{xxxx}") from the TeX File. | |
| dir_path = ARGV[0] | |
| if dir_path.nil? || dir_path.size == 0 | |
| print "ERROR: select target!!\n" | |
| exit 255 | |
| end | |
| print "target: #{dir_path}\n" | |
| if File.file?(dir_path) | |
| paths = [File.expand_path(dir_path)] | |
| else | |
| paths = Dir.glob(File.join(File.expand_path(dir_path), "*.tex")) | |
| end | |
| paths.each do |path| | |
| str = nil | |
| File.open(path, "r") do |f| | |
| str = f.read | |
| end | |
| File.open(path, "wb") do |f| | |
| print "override file: #{path}\n" | |
| f.write str.gsub(/\\color\{.*?\}/, "") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment