Commit 29b9c555 authored by 0xJMR's avatar 0xJMR
Browse files

Further development on TeXHTMLMathPrettyPrinter.

parent 1450d7c7
Pipeline #58742 passed with stages
in 45 seconds
......@@ -65,12 +65,18 @@ public class GeneratorHelper {
return this.texPrinter.prettyPrint(ast);
}
public String[] getLines(ASTMathCompilationUnit ast) {
public String[] getHTMLLines(ASTMathCompilationUnit ast) {
String printedHTML = this.printHTML(ast);
return printedHTML.split("\n");
}
public String[] getTeXHTMLLines(ASTMathCompilationUnit ast) {
String printedHTML = this.printTeXHTML(ast);
return printedHTML.split("\n");
}
@Subscribe
public void onMathFileParsed(MathFileParsedEvent event) {
......
......@@ -15,10 +15,7 @@ import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import java.awt.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.io.*;
import java.nio.file.Path;
public class SVGGenerator {
......@@ -32,6 +29,10 @@ public class SVGGenerator {
public void setContext(ASTMathCompilationUnit ast) {
this.outputPath = this.optionsService.getOutputPath(ast);
File outputDirectory = this.outputPath.toFile();
if (!outputDirectory.exists()) outputDirectory.mkdirs();
}
public String generate(String latex) throws IOException {
......
......@@ -66,7 +66,7 @@
<ul>
<li>
<table>
<#list helper.getLines(ast) as line>
<#list helper.getHTMLLines(ast) as line>
<tr>
<td class="line-number">${1 + line?index}</td>
<td><pre><#if line?length == 0>&nbsp;<#else>${line}</#if></pre></td>
......@@ -75,12 +75,14 @@
</table>
</li>
<li>
<pre class="line-numbers">
<#list 1..helper.getLinesCount(ast) as lineNumber>
${lineNumber}
</#list>
</pre>
<pre>${helper.printTeXHTML(ast)}</pre>
<table>
<#list helper.getTeXHTMLLines(ast) as line>
<tr>
<td class="line-number">${1 + line?index}</td>
<td><pre><#if line?length == 0>&nbsp;<#else>${line}</#if></pre></td>
</tr>
</#list>
</table>
</li>
</ul>
</body>
......
package de.monticore.lang.monticar.mpp.core;
package de.monticore.lang.monticar.mpp.core.application;
import de.monticore.lang.monticar.mpp.core.application.Application;
import org.junit.Ignore;
......
package de.monticore.lang.monticar.mpp.core.tex;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class SVGGeneratorTest {
@Test
@Ignore
public void testGenerate() throws IOException {
Path target = Paths.get("target/generated-sources/svg").toAbsolutePath();
SVGGenerator generator = new SVGGenerator();
generator.generate(target, "\\forall \\varepsilon \\in \\mathbb{R}");
}
}
package de.monticore.lang.monticar.mpp.montimath;
import de.monticore.lang.math._ast.ASTMathCompilationUnit;
import de.monticore.lang.math._parser.MathParser;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
public class TeXHTMLMathPrettyPrinterTest {
@Test
@Ignore
public void test() throws IOException {
Path model = Paths.get("src/test/resources/models/montimath/vanilla/Example.m").toAbsolutePath();
MathParser parser = new MathParser();
Optional<ASTMathCompilationUnit> astOptional = parser.parse(model.toString());
//TeXHTMLMathPrettyPrinter visitor = new TeXHTMLMathPrettyPrinter();
//astOptional.ifPresent(visitor::handle);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment