mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-26 10:55:09 +01:00
Use flexmark to convert to Markdown
This commit is contained in:
@@ -777,6 +777,9 @@ dependencies {
|
||||
implementation "org.commonmark:commonmark-ext-gfm-tables:$commonmark_version";
|
||||
implementation "org.commonmark:commonmark-ext-gfm-strikethrough:$commonmark_version";
|
||||
|
||||
// https://github.com/vsch/flexmark-java
|
||||
implementation "com.vladsch.flexmark:flexmark-html2md-converter:0.64.8"
|
||||
|
||||
// // https://github.com/QuadFlask/colorpicker
|
||||
//implementation "com.github.QuadFlask:colorpicker:$colorpicker_version"
|
||||
implementation project(':colorpicker')
|
||||
|
||||
@@ -19,13 +19,14 @@ package eu.faircode.email;
|
||||
Copyright 2018-2024 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter;
|
||||
|
||||
import org.commonmark.Extension;
|
||||
import org.commonmark.ext.gfm.strikethrough.StrikethroughExtension;
|
||||
import org.commonmark.ext.gfm.tables.TablesExtension;
|
||||
import org.commonmark.node.Node;
|
||||
import org.commonmark.parser.Parser;
|
||||
import org.commonmark.renderer.html.HtmlRenderer;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -47,7 +48,10 @@ public class Markdown {
|
||||
}
|
||||
|
||||
static String fromHtml(String html) {
|
||||
// TODO: HTML to Markdown
|
||||
throw new IllegalArgumentException("Not implemented");
|
||||
// https://github.com/vsch/flexmark-java/wiki/Extensions#html-to-markdown
|
||||
String markdown = FlexmarkHtmlConverter.builder()
|
||||
.build()
|
||||
.convert(html);
|
||||
return markdown.replaceAll("\n\n\\s+<!-- -->\n", "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user