Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Correct Usage of Extension #14

#1

Hi,

im would like to convert some HTML into Jira-Markdown, so i was trying to combine the FlexmarkHtmlConverterwith the JiraConverterExtension.
To test it i would use the creation of image links, because jira expects them to have a closing !.
So a <p><img src="/url" alt="foo" title="title" /></p> should become a ![foo](/url "title")! instead of a ![foo](/url "title").

Sadly, looking through the documentation i found on github and inside the test-code i am not sure how to correctly combine the extension with the coverter. The Converter seems to ignore the extension.
I tried to pass it like this

final DataHolder options = new MutableDataSet()
			.set(Parser.EXTENSIONS, List.of(JiraConverterExtension.create()))
			.toImmutable();
final String withJiraExtension = FlexmarkHtmlConverter
			.builder(options)
			.build()
			.convert(HMTL_SAMPLE);

and also like this

final String withJiraExtension = FlexmarkHtmlConverter
			.builder(options)
			.extensions(Set.of(JiraConverterExtension.create()))
			.build()
			.convert(HMTL_SAMPLE);

Did i do it wrong?
Does is this combination incompatible?
Should i parse the html to the AST and then output the AST to jira? How would i do that?

  • replies 2
  • views 1.2K
  • likes 0
#2

Jira renderer extension is an extension to the HTML Renderer. As such it requires AST generated from Markdown not HTML.

It is intended to be used for rendering Markdown to JIRA not HTML to JIRA.

Depending on the complexity of HTML you may be able to convert HTML to Markdown, then parse the Markdown to AST and render it as JIRA.

Sven snv · Author
#3

Thanks for the very quick reply and the useful clarification!

I assumed/hoped registering the extension into the converter would plug it into it's internal pipeline to use it for it's AST->Markdown-String Step.

According to your reccomendation i got it to work like this:

final String commonMD = FlexmarkHtmlConverter
	.builder()
	.build()
	.convert(input.content);

final Document AST = Parser.builder()
	.build()
	.parse(commonMD);

final String jiraMD = HtmlRenderer.builder()
	.extensions(Set.of(JiraConverterExtension.create()))
	.build()
	.render(AST);