Here you can find the source of toHtmlByPlain(String plainText)
input:I amoutput: <div>I am <code>Java</code> programmer</div>Java
programmer
Parameter | Description |
---|---|
plainText | plain text |
public static Element toHtmlByPlain(String plainText)
//package com.java2s; //License from project: Open Source License import org.jsoup.nodes.Element; public class Main { /**//from w w w. ja v a 2 s. co m * same work with {@link #toHtmlByHtml(String)} <b>but</b> think input parameter as plain text (so meaning if there have charactor that cannot convert to html it's will change to other) <br> * Example: * <pre>{@code * input: <div>I am <code>Java</code> programmer</div> * output: * <html> * <head></head> * <body> * <div>I am <code>Java</code> programmer</div> * </body> * </html> * }</pre> * * @param plainText * plain text * @return input with html, body and head tag */ public static Element toHtmlByPlain(String plainText) { Element html = new Element("html"); Element head = new Element("head"); Element body = new Element("body").text(plainText); return html.prependChild(body).prependChild(head); } }