From 2afb75ef03a75c97c01a49bd7408f6a598b63073 Mon Sep 17 00:00:00 2001 From: "Achim D. Brucker" Date: Tue, 6 Mar 2018 07:43:42 +0000 Subject: [PATCH] Removed toUppper from output. --- .../converter/src/dof_latex_converter.scala | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 document-generator/converter/src/dof_latex_converter.scala diff --git a/document-generator/converter/src/dof_latex_converter.scala b/document-generator/converter/src/dof_latex_converter.scala new file mode 100644 index 0000000..cd0750e --- /dev/null +++ b/document-generator/converter/src/dof_latex_converter.scala @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2018 The University of Sheffield. All rights reserved. + * 2018 The University of Paris-Sud. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +package com.logicalhacking.dof.converter + +import java.io.{BufferedWriter, File, FileWriter} +import IoUtils._ +import scala.util.matching.Regex + +object DofConverter { + def convertTexLine(line:String) = { + // TODO + line + } + + def convertFile(f: File) = { + val texFileName = f.getAbsolutePath() + println("ODF Converger: converting " + texFileName + + " (Not yet fully implemented!)") + f.renameTo(new File(texFileName+".orig")) + + using(io.Source.fromFile(texFileName+".orig")) { + inputFile => + using(new BufferedWriter(new FileWriter(new File(texFileName), true))) { + outputFile => + outputFile.write("% This file was modified by the DOV LaTex converter\n") + for (line <- inputFile.getLines) { + val outputLine = convertTexLine(line) + outputFile.write(outputLine + "\n") + } + } + } + } + + def main(args: Array[String]): Unit = { + val dir = if (args.length == 0) { + "." + } else { + args(0) + } + val texFiles = recursiveListFiles(new File(dir), new Regex("\\.tex$")) + for (file <- texFiles) { + convertFile(file) + } + } +}