diff options
author | Karl Berry <karl@freefriends.org> | 2008-05-06 01:02:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2008-05-06 01:02:24 +0000 |
commit | 441728c3fc15c10e69422d748dc214751ef51c17 (patch) | |
tree | d29c70e0731e4e981f55f2405e2aeacd138496ee /Master/texmf-dist/doc/latex/cd/parsecd.rb | |
parent | 101395e54ec0c670b2308650550de02c7b4ce460 (diff) |
cd update (5may08)
git-svn-id: svn://tug.org/texlive/trunk@7882 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/cd/parsecd.rb')
-rw-r--r-- | Master/texmf-dist/doc/latex/cd/parsecd.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/cd/parsecd.rb b/Master/texmf-dist/doc/latex/cd/parsecd.rb new file mode 100644 index 00000000000..6f7f02580b1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/cd/parsecd.rb @@ -0,0 +1,54 @@ +#!/usr/bin/ruby + +# +# This script generates a data file using data from freedb.org. +# +# Typical usage: +# +# wget -O- http://www.freedb.org/freedb/jazz/380a0a05 | ./parsecd.rb +# + +track = [] + +class String + def tex + return sub(/&/, "\\\\&").sub(/%/, "\\\\%").sub(/#/, "\\\\#") + end +end + +$stdin.each_line do |line| + name, content = line.split("=") + name.strip! if name + content.strip! if content + + if name == "DTITLE" then + author, title = content.split("/") + author = "" if ! author + title = "" if ! title + author.strip! + title.strip! + author_cap = [] + author.each(" ") { |word| author_cap << word.strip.capitalize.tex } + print "\\covertext{\n", author_cap.join(" "), "\\\\\n", "\\bfseries ", title.strip.tex, "\n}\n\n" + + print "\\leftspine{", author.upcase.tex, "}\n\n" + print "\\centerspine{", title.upcase.tex, "}\n\n" + + end + + if name.strip =~ /TTITLE.*/ then + track << content + end +end + +print "\\lefttracklist{\n" + +if track.size < 16 then track.each { |x| print "\\track ", x.tex, "\n" } +else + track[0,(track.size/2)+1].each { |x| print "\\track ", x.tex, "\n" } + print "}\n\n\\righttracklist{\n" + track[(track.size/2)+1,track.size].each { |x| print "\\track ", x.tex, "\n" } +end + + +print "}\n" |