which obviously omits the line break between line 3 and line 4.
Does anyone know the problem too? Is here the right place to address this issue?
A full reproducer is this test case
class AsposeLinebreakTest {
@Test
void markdownToHtml_lineBreaks() throws Exception {
final var license = AsposeService.class.getResourceAsStream("/license/Aspose.Words.Java.lic");
new License().setLicense(license);
final var markdown = """
Line 1
Line 3
Line 4
""";
final var out = new ByteArrayOutputStream();
final var charset = Charset.defaultCharset();
final var doc = new Document(IOUtils.toInputStream(markdown, charset), new LoadOptions(LoadFormat.MARKDOWN, null, null));
doc.save(out, SaveOptions.createSaveOptions(SaveFormat.HTML));
FileUtils.writeStringToFile(new File("test.html"), out.toString(), charset);
}
}
It appears you are experiencing a change in behavior when converting Markdown to HTML after upgrading from Aspose Words Java 25.4 to 25.5. The issue seems to be related to how line breaks are handled in the Markdown input.
In your example, the Markdown input contains multiple line breaks, but the output in version 25.5 does not preserve the line break between “Line 3” and “Line 4.” This may be due to changes in how the library interprets Markdown formatting.
To address this issue, you may want to review the release notes for version 25.5 to identify any changes related to Markdown processing. If this behavior is indeed a regression, consider reporting it through the Aspose support channels for further assistance.
As a workaround, you can manually insert a line break in your Markdown input by adding an explicit <br /> tag or using two spaces at the end of the line before a new line. Here’s a modified version of your Markdown input:
Line 1
Line 3
Line 4
This adjustment should help maintain the line break when converting to HTML.
@fjakop In new versions of Aspose.Words you can control what character is used as a soft line break upon loading Markdown. You can use the following code to get the expected output:
@alexey.noskov thanks a lot, that fixes the issue.
Nevertheless it’s strange that this change (and the necessity to change my code for getting the same result) is introduced with a minor version.