You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to convert md to docx and I have a problem with converting single back ticks. It does apply sourceText style to run but also applies ParagraphTextBody which overrides run style and it is not shown in word or in libre office.
This is the code I used:
@TestpublicvoidmdToDocx() throwsException {
DataHolderOPTIONS = newMutableDataSet()
.set(Parser.EXTENSIONS, Arrays.asList())
.setFrom(ParserEmulationProfile.GITHUB_DOC);
Stringinput =
"# Backticks MD file\n" +
"\n" +
"`this is single line of backticks`\n" +
"\n" +
"Tis is text which contains `text under backticks`\n" +
"\n" +
"\n" +
"`this is backticks` this is regular text\n";
ParserparserDocx = Parser.builder(OPTIONS).build();
DocxRendererdocxRenderer = DocxRenderer.builder(OPTIONS).build();
Nodedocument2 = parserDocx.parse(input);
WordprocessingMLPackagetemplate = WordprocessingMLPackage.createPackage();
Filefile = newFile("/path/to/file/doc.docx");
docxRenderer.render(document2, template);
System.out.println("***********************************");
System.out.println(XmlUtils.marshaltoString(template
.getMainDocumentPart().getJaxbElement(), true, true));
System.out.println("***********************************");
template.save(file);
}
and this is the output
<w:body>
<w:bookmarkStartw:name="backticks-md-file"w:id="1"/>
<w:bookmarkEndw:id="1"/>
<w:p>
<w:pPr>
<w:pStylew:val="Heading1"/>
</w:pPr>
<w:r>
<w:t>Backticks MD file</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="ParagraphTextBody"/>
</w:pPr>
<w:r>
<w:rPr>
<w:rStylew:val="SourceText"/>
</w:rPr>
<w:t>this is single line of backticks</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="ParagraphTextBody"/>
</w:pPr>
<w:r>
<w:txml:space="preserve">Tis is text which contains </w:t>
</w:r>
<w:r>
<w:rPr>
<w:rStylew:val="SourceText"/>
</w:rPr>
<w:t>text under backticks</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStylew:val="ParagraphTextBody"/>
</w:pPr>
<w:r>
<w:rPr>
<w:rStylew:val="SourceText"/>
</w:rPr>
<w:t>this is backticks</w:t>
</w:r>
<w:r>
<w:txml:space="preserve"> this is regular text</w:t>
</w:r>
</w:p>
<w:sectPr>
<w:pgSzw:w="11907"w:h="16839"w:code="9"/>
<w:pgMarw:top="1440"w:right="1440"w:bottom="1440"w:left="1440"/>
</w:sectPr>
</w:body>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I am trying to convert md to docx and I have a problem with converting single back ticks. It does apply sourceText style to run but also applies ParagraphTextBody which overrides run style and it is not shown in word or in libre office.
This is the code I used:
and this is the output
I attached generated docx file.
idemo.docx
Beta Was this translation helpful? Give feedback.
All reactions