Dave Jarvis' Repositories

M src/main/java/com/keenwrite/preview/HtmlPreview.java
1111
import javafx.embed.swing.SwingNode;
1212
import org.greenrobot.eventbus.Subscribe;
13
import org.jsoup.Jsoup;
1314
1415
import javax.swing.*;
...
3536
import static org.controlsfx.glyphfont.FontAwesome.Glyph.LOCK;
3637
import static org.controlsfx.glyphfont.FontAwesome.Glyph.UNLOCK_ALT;
37
import static org.jsoup.Jsoup.parse;
3838
3939
/**
...
158158
   */
159159
  public void render( final String html ) {
160
    final var doc = CONVERTER.fromJsoup( parse( decorate( html ) ) );
160
    final var doc = CONVERTER.fromJsoup( Jsoup.parse( decorate( html ) ) );
161161
    final var uri = getBaseUri();
162162
    doc.setDocumentURI( uri );
...
269269
   * followed by the ISO 15924 alpha-4 script code, followed by an ISO 3166
270270
   * alpha-2 country code or UN M.49 numeric-3 area code. For example, this
271
   * could return "en-Latn-CA" for Canadian English written in the Latin
271
   * could return {@code en-Latn-CA} for Canadian English written in the Latin
272272
   * character set.
273273
   *
M src/main/java/com/keenwrite/processors/markdown/BaseMarkdownProcessor.java
88
import com.keenwrite.processors.markdown.extensions.r.RInlineExtension;
99
import com.vladsch.flexmark.ext.definition.DefinitionExtension;
10
import com.vladsch.flexmark.ext.gfm.strikethrough.*;
10
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughSubscriptExtension;
1111
import com.vladsch.flexmark.ext.superscript.SuperscriptExtension;
1212
import com.vladsch.flexmark.ext.tables.TablesExtension;
1313
import com.vladsch.flexmark.html.HtmlRenderer;
1414
import com.vladsch.flexmark.parser.Parser;
1515
import com.vladsch.flexmark.util.ast.IParse;
1616
import com.vladsch.flexmark.util.ast.IRender;
1717
import com.vladsch.flexmark.util.ast.Node;
1818
import com.vladsch.flexmark.util.data.MutableDataSet;
1919
import com.vladsch.flexmark.util.misc.Extension;
20
import org.jsoup.Jsoup;
21
import org.jsoup.nodes.Document.OutputSettings.Syntax;
2022
2123
import java.util.ArrayList;
...
7981
  @Override
8082
  public String apply( final String markdown ) {
81
    return toHtml( parse( markdown ) );
83
    return toXhtml( toHtml( parse( markdown ) ) );
8284
  }
8385
8486
  /**
8587
   * Returns the AST in the form of a node for the given Markdown document. This
86
   * can be used, for example, to determine if a hyperlink exists inside of a
88
   * can be used, for example, to determine if a hyperlink exists inside a
8789
   * paragraph.
8890
   *
...
102104
  public String toHtml( final Node node ) {
103105
    return getRenderer().render( node );
106
  }
107
108
  /**
109
   * Ensures that subsequent processing will receive a well-formed document.
110
   * That is, an XHTML document.
111
   *
112
   * @param html Document to transform (may contain unbalanced HTML tags).
113
   * @return A well-formed (balanced) equivalent HTML document.
114
   */
115
  private String toXhtml( final String html ) {
116
    final var document = Jsoup.parse( html );
117
    document.outputSettings().syntax( Syntax.xml );
118
    return document.html();
104119
  }
105120