diff --git a/src/converter/converter.cpp b/src/converter/converter.cpp index d5502c59..04e693f5 100644 --- a/src/converter/converter.cpp +++ b/src/converter/converter.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -231,12 +231,46 @@ void GeometryConverter::convert(const fs::path &inputFile, serConf->setParameter(XMLUni::fgDOMErrorHandler, &errorHandler); if (serConf->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true)) serConf->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, true); - if (serConf->canSetParameter(XMLUni::fgDOMWRTXercesPrettyPrint, true)) - serConf->setParameter(XMLUni::fgDOMWRTXercesPrettyPrint, true); DOMLSOutput *output = impl->createLSOutput(); - XMLFormatTarget *target = new LocalFileFormatTarget(outputFile.file_string().c_str()); + MemBufFormatTarget *target = new MemBufFormatTarget(); output->setByteStream(target); serializer->write(doc, output); + const XMLByte *content = target->getRawBuffer(); + std::ostringstream oss; + + /* Turn leading spaces into tabs */ + bool newline = true; + int numSpaces = 0; + for (size_t i=0; igetLen(); ++i) { + char data = content[i]; + switch (data) { + case ' ': + if (newline) + numSpaces++; + else + oss << data; + break; + case '\r': + case '\n': + oss << data; + newline = true; + numSpaces = 0; + break; + default: + if (newline) { + for (int i=0; i