简体   繁体   中英

Markdown with javax.swing

I am new to javax.swing, so sorry if my question seems obvious.

I have a markdown file, what would be the correct class/way to represent it using javax.swing?

I have not found a straightforward answer in internet...is it possible to represent a markdown file in an easy way? I don't need to modify it, just show the content.

Thanks everyone

This is fairly involved.

There is no swing component that 'natively' renders markdown. There are libraries though, which are entirely unrelated to swing, that turn markdown into something else, usually, HTML.

And there are swing components that render HTML.

1+1 = 2.

Using TxtMark :

public void renderMarkdown(String md) {
  String html = txtmark.Processor.process(md);
  JEditorPane editor = ...;
  editor.setContentType("text/html");
  editor.setText(html);
}

renderMarkdown("Hey, *this seems* not __too difficult__");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM