maestria-investigacion/public/tesis/docx/generate

28 lines
513 B
Ruby
Executable File

#!/usr/bin/env ruby
# encoding: UTF-8
# coding: UTF-8
require 'fileutils'
# Variables
tesis_raw = 'tesis_with-bib.md'
tesis = 'tesis.md'
# Lee el archivo de la tesis
md = File.read('../md/' + tesis_raw)
# Limpia la tesis
clean = md.gsub(/\+{2,}/, '')
.gsub(/\s+{\s*.frances\s*}/, '')
# Guarda la tesis
file = File.open(tesis, 'w:utf-8')
file.puts clean
file.close
# Convierte a DOCX
system("pandoc -V lang:es #{tesis} -o #{File.basename(tesis, '.md')}.docx")
# Elimina MD
FileUtils.rm(tesis)