diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/mulk/mulkcms2/common/markdown/MarkdownConverter.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/common/markdown/MarkdownConverter.java b/src/main/java/eu/mulk/mulkcms2/common/markdown/MarkdownConverter.java index 4286e25..013a5dd 100644 --- a/src/main/java/eu/mulk/mulkcms2/common/markdown/MarkdownConverter.java +++ b/src/main/java/eu/mulk/mulkcms2/common/markdown/MarkdownConverter.java @@ -13,6 +13,7 @@ import com.vladsch.flexmark.util.data.MutableDataSet; import java.util.Arrays; import javax.enterprise.context.ApplicationScoped; import org.jsoup.Jsoup; +import org.jsoup.safety.Cleaner; import org.jsoup.safety.Safelist; @ApplicationScoped @@ -47,7 +48,10 @@ public class MarkdownConverter { public String htmlify(String markdown) { var parsedDocument = parser.parse(markdown); - var unsanitizedHtml = renderer.render(parsedDocument); - return Jsoup.clean(unsanitizedHtml, Safelist.relaxed()); + var uncleanHtml = renderer.render(parsedDocument); + var cleaner = new Cleaner(Safelist.relaxed().addTags("abbr", "acronym")); + var cleanedDocument = cleaner.clean(Jsoup.parseBodyFragment(uncleanHtml)); + cleanedDocument.select("table").addClass("pure-table").addClass("pure-table-horizontal"); + return cleanedDocument.body().html(); } } |