private String renderBodyText(Set<RenderOption> renderOptions, MarkdownGlobalOptions markdownOptions,
String sourceText) throws IOException {
String bodyText;
try {
PegDownProcessor markdownProcessor = new PegDownProcessor(markdownOptions.getExtensionsValue());
final boolean resolveImageUrls = renderOptions.contains(RenderOption.RESOLVE_IMAGE_URLS);
final boolean resolveLinkUrls = renderOptions.contains(RenderOption.RESOLVE_LINK_URLS);
if (resolveImageUrls || resolveLinkUrls) {
RootNode rootNode = markdownProcessor.parseMarkdown(sourceText.toCharArray());
FileObject sourceFile = context.getPrimaryFile();
final PreviewSerializer htmlSerializer
= new PreviewSerializer(sourceFile.toURL(), resolveImageUrls, resolveLinkUrls);
bodyText = htmlSerializer.toHtml(rootNode);
}
else {
RootNode rootNode = markdownProcessor.parseMarkdown(sourceText.toCharArray());
final ExportSerializer htmlSerializer
= new ExportSerializer(new LinkRenderer());
bodyText = htmlSerializer.toHtml(rootNode);
}
}