fix the mess of encodings

This commit is contained in:
Wirlaburla 2024-07-26 21:05:56 -05:00
parent 3d91ebbbd7
commit 9950188e0d
2 changed files with 12 additions and 17 deletions

View File

@ -18,6 +18,7 @@ dependencies {
implementation group: 'net.lingala.zip4j', name: 'zip4j', version: '2.11.5'
implementation group: 'org.json', name: 'json', version: '20240303'
implementation group: 'io.github.java-diff-utils', name: 'java-diff-utils', version: '4.12'
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0'
implementation 'com.jetbrains.intellij.java:java-gui-forms-rt:203.7148.30'
antTask 'com.jetbrains.intellij.java:java-compiler-ant-tasks:203.7148.30'
@ -30,14 +31,15 @@ java {
}
jar {
manifest {
attributes(
'Main-Class': 'Main'
)
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes(
'Main-Class': 'Main'
)
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
application {

View File

@ -54,6 +54,7 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.apache.commons.text.StringEscapeUtils;
public class Rizzo {
private Scanner scanner;
@ -123,15 +124,7 @@ public class Rizzo {
transformer.setOutputProperty(OutputKeys.METHOD, "html");
transformer.transform(source, result);
// Look ma, I'm breaking XML standards!
String xmlString = result.getWriter().toString()
.replace("&", "&")
.replace("&lt;", "<")
.replace("&gt;", ">")
.replace("&#9;", "\t")
.replace("&#8;", "\b")
.replace("&#10;", "\n")
.replace("&#13;", "\r")
.replace("&#12;", "\f");
String xmlString = StringEscapeUtils.unescapeHtml4(result.getWriter().toString());
try (PrintStream ps = new PrintStream(output)) {
ps.print(xmlString);
}