33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ffnpdf/chapter.rb', line 33
def convert_to_md
puts "converting #{padded_ch}.html to #{padded_ch}.md"
Converter.exec("pandoc #{padded_ch}.html -o #{padded_ch}.md")
if chapter ==1 or chapter_title
tempfile = File.new("#{padded_ch}.temp", "w")
if chapter == 1
tempfile.puts "\\pagenumbering{arabic}"
tempfile.puts "\\setcounter{page}{1}"
tempfile.puts
end
if (chapter_title)
tempfile.puts "\#\# #{chapter_title}"
tempfile.puts
end
IO.foreach("#{padded_ch}.md") do |line|
tempfile.puts line
end
tempfile.close
FileUtils.rm("#{padded_ch}.md")
File.rename("#{padded_ch}.temp", "#{padded_ch}.md")
end
end
|