Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
M src/main/java/com/keenwrite/dom/DocumentParser.java
184184
  }
185185
186
  public static Node createElement(
187
    final Document doc, final String nodeName, final String nodeValue ) {
188
    assert doc != null;
189
    assert nodeName != null;
190
    assert !nodeName.isBlank();
191
192
    final var node = doc.createElement( nodeName );
193
194
    if( nodeValue != null ) {
195
      node.setTextContent( nodeValue );
196
    }
197
198
    return node;
199
  }
200
186201
  public static String toString( final Document xhtml ) {
187202
    assert xhtml != null;
...
269284
   * until an iterable sub-interface is written.
270285
   */
271
  private DocumentParser() {}
286
  private DocumentParser() { }
272287
}
273288
M src/main/java/com/keenwrite/processors/XhtmlProcessor.java
1818
1919
import static com.keenwrite.Bootstrap.APP_TITLE_ABBR;
20
import static com.keenwrite.dom.DocumentParser.createMeta;
21
import static com.keenwrite.dom.DocumentParser.visit;
20
import static com.keenwrite.dom.DocumentParser.*;
2221
import static com.keenwrite.events.StatusEvent.clue;
2322
import static com.keenwrite.io.downloads.DownloadManager.open;
...
3938
4039
  private final ProcessorContext mContext;
41
42
  /**
43
   * Adorns the given document with {@code html}, {@code head}, and
44
   * {@code body} elements.
45
   *
46
   * @param html The document to decorate.
47
   * @return A document with a typical HTML structure.
48
   */
49
  private static String decorate( final String html ) {
50
    return
51
      "<html><head><title> </title><meta charset='utf8'/></head><body>"
52
        + html
53
        + "</body></html>";
54
  }
5540
5641
  public XhtmlProcessor(
...
7459
7560
    try {
76
      final var doc = DocumentParser.parse( decorate( html ) );
61
      final var doc = parse( html );
7762
      setMetaData( doc );
7863
...
126111
  private void setMetaData( final Document doc ) {
127112
    final var metadata = createMetaDataMap( doc );
128
129
    visit( doc, "/html/head", node ->
130
      metadata.entrySet()
131
              .forEach( entry -> node.appendChild( createMeta( doc, entry ) ) )
132
    );
133
134113
    final var title = metadata.get( "title" );
135114
136
    if( title != null ) {
137
      visit( doc, "/html/head/title", node -> node.setTextContent( title ) );
138
    }
115
    visit( doc, "/html/head", node -> {
116
      // Insert <title>text</title> inside <head>.
117
      node.appendChild( createElement( doc, "title", title ) );
118
119
      // Insert each <meta name=x content=y /> inside <head>.
120
      metadata.entrySet().forEach(
121
        entry -> node.appendChild( createMeta( doc, entry ) )
122
      );
123
    } );
139124
  }
140125
...
209194
210195
      if( mediaType.isSvg() ) {
211
        DocumentParser.sanitize( imageFile );
196
        sanitize( imageFile );
212197
      }
213198
    }
M src/main/resources/com/keenwrite/messages.properties
314314
Wizard.typesetter.container.version=4.3.1
315315
Wizard.typesetter.container.checksum=b741702663234ca36e1555149721580dc31ae76985d50c022a8641c6db2f5b93
316
Wizard.typesetter.themes.version=1.8.0
317
Wizard.typesetter.themes.checksum=2e6177d23210ea183f7759e5b6232f70bb1d4638a2f911beca129f877d25f92d
316
Wizard.typesetter.themes.version=1.8.1
317
Wizard.typesetter.themes.checksum=0cdb637cd77a1cd672aeedaba7ae364214aff7ffd28dd2812a8f360dfcea9d28
318318
319319
# STEP 1: Introduction panel (all)