Last active
August 29, 2015 14:16
-
-
Save JenniferMack/3169e131d5cd8c6f40db to your computer and use it in GitHub Desktop.
ePub playOrder fix for Ulysses export
This file contains 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
#!/usr/bin/env ruby | |
cnt = 1 | |
cmd = ARGV[0] | |
file = ARGV[1] | |
begin | |
if cmd == "unzip" | |
system "unzip", "-q", file | |
ARGV.replace ["OPS/toc.ncx"] | |
elsif cmd == "zip" | |
system "zip", "-f", file | |
exit | |
end | |
ARGF.each_line do |line| | |
if /playOrder/.match(line) | |
line.sub!(/playOrder="1"/, "playOrder=\"#{cnt}\"") | |
cnt += 1 | |
end | |
puts line | |
end | |
rescue | |
puts "Oops. Something went wrong." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to search for full 'playOrder="1"' string instead of each digit.