We have a requirement where we need to have a markdown file of a docx file in order to process it properly with formatting. However, it seems as though when you convert a file from docx to markdown it does not preserve the original numbering if they are lists or nested lists. The library considers all numbers as 1, now this is pretty accurate if the renderer is also markdown.
Since we are dealing with text here and proper formatting it now becomes a requirement for us to have proper numbering in the markdown text to track changes. is there a way that can be done
The current code we use is
import com.aspose.words.*;
public class ExMarkdownSaveOptions {
public void convertDocxToMarkdownWithFormatting() throws Exception {
// Load your DOCX file
Document doc = new Document("input.docx");
// Set up Markdown save options to preserve styles, numbering, and formatting
MarkdownSaveOptions options = new MarkdownSaveOptions();
options.setListExportMode(MarkdownListExportMode.MARKDOWN_SYNTAX); // Preserves numbering and bullets
options.setTableContentAlignment(TableContentAlignment.AUTO); // Preserves table alignment
options.setExportImagesAsBase64(true); // Embeds images as base64
options.setExportHeadersFootersMode(ExportHeadersFootersMode.PER_SECTION); // Exports headers/footers
options.setPrettyFormat(true); // Makes output more readable
// Save as Markdown
doc.save("output.md", options);
}
public static void main(String[] args) {
try {
new ExMarkdownSaveOptions().convertDocxToMarkdownWithFormatting();
System.out.println("Conversion complete.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
how do we preserve all the lettering and numbering of the lists like in this text for example, while converting it to markdown?
1. All information disclosed by one party to the other to evaluate the Project and/or Purpose that is designated in writing as “Confidential” at the time of disclosure or if disclosed orally is designated in writing as “Confidential” within fifteen (15) days of disclosure is “Confidential Information.” Confidential Information does not include information which:
(a) was known by the receiving party prior to receipt from the disclosing party;
(b) is generally available in the public domain or thereafter becomes available to the public through no act of the receiving party;
(c) is independently discovered by an employee, agent, or representative of the receiving party who had no knowledge of the Confidential Information disclosed; or
(d) is made available to the receiving party as a matter of lawful right by a third party.
2. The receiving party agrees to disclose Confidential Information only to their respective employees, agents, or representatives who have been determined to have a need to know and have been advised of their obligation to comply with the terms of this Agreement. To the extent allowed by the law applicable to the receiving party, the receiving party will be liable for any breach of this agreement by any of its employees, agents, affiliates or representatives that receive access to the Co