Added workaround regexes for sloppyPrint()'s inconsistent line endings inside comments
This commit is contained in:
parent
78704d2377
commit
f3825d3bd8
2 changed files with 4 additions and 1 deletions
|
@ -226,6 +226,7 @@ public class ModUtilities {
|
|||
StringWriter writer = new StringWriter();
|
||||
SloppyXMLOutputProcessor.sloppyPrint( mergedDoc, writer, encoding );
|
||||
String mergedString = writer.toString();
|
||||
mergedString = mergedString.replaceAll( "\r(?!\n)|(?<!\r)\n", "\r\n" ); // sloppyPrint needs normalizing!?
|
||||
|
||||
InputStream result = encodeText( mergedString, encoding, mainDescription+"+"+appendDescription );
|
||||
return result;
|
||||
|
@ -259,6 +260,7 @@ public class ModUtilities {
|
|||
StringWriter writer = new StringWriter();
|
||||
SloppyXMLOutputProcessor.sloppyPrint( doc, writer, encoding );
|
||||
String resultString = writer.toString();
|
||||
resultString = resultString.replaceAll( "\r(?!\n)|(?<!\r)\n", "\r\n" ); // sloppyPrint needs normalizing!?
|
||||
|
||||
InputStream result = encodeText( resultString, encoding, srcDescription+" (cleaned)" );
|
||||
return result;
|
||||
|
|
|
@ -150,12 +150,13 @@ public class SloppyXMLOutputProcessor extends AbstractXMLOutputProcessor {
|
|||
* is encoding bytes to match. If encoding is null, the default
|
||||
* is "UTF-8".
|
||||
*
|
||||
* LineEndings will be CR-LF.
|
||||
* LineEndings will be CR-LF. Except for comments!?
|
||||
*/
|
||||
public static void sloppyPrint( Document doc, Writer writer, String encoding ) throws IOException {
|
||||
Format format = Format.getPrettyFormat();
|
||||
format.setExpandEmptyElements( false );
|
||||
format.setOmitDeclaration( false );
|
||||
format.setIndent( "\t" );
|
||||
format.setLineSeparator( LineSeparator.CRNL );
|
||||
|
||||
if ( encoding != null ) format.setEncoding( encoding );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue