Document.Range.Replace with ReplacementFormat.Markdown replaces text wthout markdown formatting

Hello, Aspose team!

We are trying to use Aspose.Words in to edit a content of word document, and one of the intermediate task is to replace text, using markdown as a replacement. This is a code we are using in our simple test application to test such functionality:

using Aspose.Words.Replacing;
using Aspose.Words;

var document = new Document("input.docx");

document.Range.Replace("ChangeMe", "**Employee Classifications**", new FindReplaceOptions
{
   MatchCase = true,
   ReplacementFormat = ReplacementFormat.Markdown,
});

document.Save("output.docx", SaveFormat.Docx);

We expected result to be a formatted text, but, unfortunately, text inserted is a plain text (we are using evaluation license for test):

You could find our test solution in attachment:
MarkdownReplacementFormatTest.zip (12.3 KB)

Could you please review our code and give an advice or provide working code example, which will replace content with formatted text, not a plain text?

Thanks in advance!

@vladislavpedanepam ReplacementFormat works only when LowCore.Replacer is used, as mentioned in the documentation. So you should use the following code:

FindReplaceOptions opt = new FindReplaceOptions();
opt.ReplacementFormat = ReplacementFormat.Markdown;
Aspose.Words.LowCode.Replacer.Replace(@"C:\Temp\in.docx", @"C:\Temp\out.docx", SaveFormat.Docx, "ChangeMe", "**Employee Classifications**", opt);
1 Like