Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Using flexmark to render markdown in a javafx application #591

Open
kinglighthill opened this issue Sep 12, 2023 · 1 comment
Open

Comments

@kinglighthill
Copy link

I'm currently working on an e-learning application developed with JavaFX for Windows and macOS. I have been trying to use Flexmark to render some markdown text but I don't understand how to use it. Can it be you in Javafx or is it meant only for Java Swing? Again I have some latex I would also want to render, Is there an existing extension for it?
Sorry if this question is redundant, I have gone through most of the issues and the repo and still have not found any helpful solution but I have a strong feeling that this library can help me.
Thanks.

@thmarx
Copy link

thmarx commented Oct 25, 2023

Since JavaFx only uses Java, this shouldn't be a problem. Just render markdown into a string (see code below) and use a WebView to display the html.

Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();

// You can re-use parser and renderer instances
Node document = parser.parse("This is *Sparta*");
String html = renderer.render(document);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants