Class: TxTranslate::MdProcess

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/tx_translate/md_process.rb

Class Method Summary collapse

Class Method Details

.run(filename) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tx_translate/md_process.rb', line 5

def self.run(filename)
  file = File.open(filename, "r")
  basename = File.basename(filename, "md")
  contents = file.read
  new_contents = ""


  old_content_array = contents.split("\n\n")


  new_content_array = ParallelArray.new(old_content_array).parallel_process

  old_content_array.each_with_index do |item,i|
    new_contents += old_content_array[i] + "\n\n" + new_content_array[i] + "\n\n"
  end

  file = File.open("#{basename}zh-si.md", "w") { |f| f.write(new_contents) }
end