Ruby で非常に単純なマークダウンのようなコンバーターを作成し、その出力をPrinceXMLに渡そうとしています(これは素晴らしいことです)。Prince は基本的に html を pdf に変換します。
これが私のコードです:
#!/usr/bin/ruby
# USAGE: command source-file.txt target-file.pdf
# read argument 1 as input
text = File.read(ARGV[0])
# wrap paragraphs in paragraph tags
text = text.gsub(/^(.+)/, '<p>\1</p>')
# create a new temp file for processing
htmlFile = File.new('/tmp/sample.html', "w+")
# place the transformed text in the new file
htmlFile.puts text
# run prince
system 'prince /tmp/sample.html #{ARGV[1]}'
しかし、これは空のファイルをにダンプします/tmp/sample.html
。王子の呼び出しを除外すると、変換は問題なく行われます。
私は何を間違っていますか?