I know that you can use HTMLEditor.getHTMLText(); to convert text to HTML, I was just wondering if you can convert the HTML text back to plain text .
Any help will be appreciated.
What you need is to remove all the HTML tags from the HTML String returned by getHtmlText
.
You can implement a method, or better, you can use for example JSoup to do the job for you:
Jsoup.parse(htmlText).text();
Example
HTMLEditor editor = new HTMLEditor();
Button b = new Button("Get Text");
b.setOnAction(e -> System.out.println(Jsoup.parse(editor.getHtmlText()).text()));
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.