RDで仕事のドキュメントをわんさか作っているときは、このrakefileとCSSファイルをディレクトリに突っ込んでrakeしてます。
rd2html-ext-lib.rbはるびきちさんのところからダウンロードしたもの。
RDs = FileList["**/*.rd"] HTMLs = RDs.ext('html') CSS = "default.css" task :default => HTMLs task :clean do sh "rm *.html" end rule '.html' => ['.rd'] do |t| rd_ext_option = "--native-inline --ref-extension --headline-secno" cmd = "rdrt2 -r rd/rd2html-ext-lib.rb #{rd_ext_option} " cmd += "--with-css=#{CSS} #{t.source} " cmd += "|embeddingCSS.rb > #{t.name}" sh cmd end
途中に出てくるembeddingCSS.rbは、cssの内容をHTMLに埋め込んでしまうスクリプトです。HTML単体をメールしたりするので、基本全部入れちゃう。こんなスクリプト
#!/usr/bin/ruby -Ks while line = gets if /^<link href="(.*)" type="text\/css"/ =~ line then print '<META http-equiv=Content-Type content="text/html; charset=shift_jis">' print '<style type="text/css">',"\n" File.open($1){|css| print css.read} print '</style>',"\n" else print line end end