From 51025649ffce0fd68b794d28a1b073750f517a4d Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 7 May 2022 04:51:40 +0200 Subject: Format tables with a bit more spacing. Change-Id: Iba0dcabce7a0841dbb0f5cf795cb2d684faf7462 --- .../java/eu/mulk/mulkcms2/common/markdown/MarkdownConverter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java/eu') 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(); } } -- cgit v1.2.3