Jump to content

BIRT Developer Center Download

- - - - -

Parsing markdown with birt designer

  • Please log in to reply
2 replies to this topic

#1 Gertenbol



  • Members
  • Pip
  • 1 posts

Posted 15 February 2017 - 02:29 AM

Hi there,


I'm using Birt designer in Eclipse. The application I'm fetching data from is using markdown. I have been looking for ways to create bullet lists based on the markdown *. Any ideas on how to do this?




#2 jfranken


    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 17 February 2017 - 09:02 AM

Hi Geert,


I haven't used markdown, but the attached example shows how to turn "*" bullets into an html list.  There is probably a more efficient way to write the code, but hopefully this example will get you started.




Attached Files

Jeff F.


Customer Support Engineer I

Website: www.opentext.com






#3 Clement Wong

Clement Wong

    Senior Member

  • BIRT Experts
  • 1204 posts

Posted 17 February 2017 - 03:17 PM

Also, you can convert the incoming markdown text to HTML using a Java package such flexmark-java (https://github.com/vsch/flexmark-java), commonmark-java, or pegdown ( https://github.com/sirthias/pegdown).


You can perform this conversion, for example as a Computed Column, or in a text report item.


Then, with the converted HTML, you can output as is, or parse further as needed.


I've used the pegdown package in a BIRT report.  You'll need to include its dependencies (asm-all-5.0.3.jar, parboiled-core-1.1.7.jar, parboiled-java-1.1.7.jar) and the main package, pegdown-1.6.0.jar as part of the report's resources.


For example, pegdown would convert the following markdown "This is *Sparta*" to "<p>This is <em>Sparta</em></p>".


I also have tried flexmark-java (latest version 0.15.0) and it works too.  The JARs included needed were: flexmark-0.15.0.jar, flexmark-util-0.15.0.jar and flexmark-html-parser-0.15.0.jar (downloaded @ https://search.maven...ch.flexmark" ).


Example code snippet:

importPackage( Packages.com.vladsch.flexmark.parser );
importPackage( Packages.com.vladsch.flexmark.html );

var parser = Parser.builder().build();
var document = parser.parse("This is *Sparta*");
var renderer = HtmlRenderer.builder().build();
var convertedText = renderer.render(document);  // "<p>This is <em>Sparta</em></p>"

//I am using commercial BIRT to write out to the log file to see the output.
//var logger = java.util.logging.Logger.getLogger("birt.report.logger");
//logger.warning (convertedText);

Clement Wong
Principal Analytics Architect

OpenText Corporation
http://www.actuate.com | http://www.opentext.com