mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-12 16:38:48 +00:00
23 lines
707 B
Java
23 lines
707 B
Java
package com.imprimelibros.erp.common.web;
|
|
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Entities;
|
|
|
|
public class HtmlToXhtml {
|
|
|
|
public static String toXhtml(String html) {
|
|
if (html == null || html.isBlank()) return "";
|
|
|
|
Document doc = Jsoup.parseBodyFragment(html);
|
|
|
|
doc.outputSettings()
|
|
.syntax(Document.OutputSettings.Syntax.xml) // => <br/>
|
|
.escapeMode(Entities.EscapeMode.xhtml) // entidades XHTML
|
|
.prettyPrint(false); // no metas saltos raros
|
|
|
|
// devolvemos sólo el contenido del body (sin <html><head>…)
|
|
return doc.body().html();
|
|
}
|
|
}
|