Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
M src/main/java/com/keenwrite/cmdline/HeadlessApp.java
66
77
import static com.keenwrite.events.Bus.register;
8
import static java.lang.String.format;
89
910
/**
...
3940
  @Subscribe
4041
  public void handle( final StatusEvent event ) {
42
    assert event != null;
43
4144
    if( !mArgs.quiet() ) {
42
      System.out.println( event.toString() );
43
      System.out.println( event.getProblem() );
45
      final var stacktrace = event.getProblem();
46
      final var problem = stacktrace.isBlank()
47
        ? ""
48
        : format( "%n%s", stacktrace );
49
      final var msg = format( "%s%s", event, problem );
50
51
      System.out.println( msg );
4452
    }
4553
  }
M src/main/java/com/keenwrite/dom/DocumentParser.java
11
package com.keenwrite.dom;
22
3
import com.keenwrite.io.SysFile;
43
import org.w3c.dom.*;
54
import org.xml.sax.InputSource;
M src/main/java/com/keenwrite/processors/XhtmlProcessor.java
1010
import org.w3c.dom.Document;
1111
12
import java.io.File;
1213
import java.io.FileNotFoundException;
1314
import java.nio.file.Path;
...
169170
   */
170171
  private Path downloadImage( final String src ) throws Exception {
171
    final Path imageFile;
172
    final Path imagePath;
173
    final File imageFile;
172174
    final var cachesPath = getCachesPath();
173175
...
181183
      final var id = hash.toLowerCase();
182184
183
      imageFile = cachesPath.resolve( APP_TITLE_ABBR + id + '.' + ext );
185
      imagePath = cachesPath.resolve( APP_TITLE_ABBR + id + '.' + ext );
186
      imageFile = toFile( imagePath );
184187
185188
      // Preserve image files if auto-remove is turned off.
186189
      if( autoRemove() ) {
187
        toFile( imageFile ).deleteOnExit();
190
        imageFile.deleteOnExit();
188191
      }
189192
190193
      try( final var image = response.getInputStream() ) {
191
        copy( image, imageFile, REPLACE_EXISTING );
194
        copy( image, imagePath, REPLACE_EXISTING );
192195
      }
193196
194197
      if( mediaType.isSvg() ) {
195
        sanitize( imageFile );
198
        sanitize( imagePath );
196199
      }
197200
    }
198201
199
    return imageFile;
202
    final var key = imageFile.exists()
203
      ? "Main.status.image.xhtml.image.saved"
204
      : "Main.status.image.xhtml.image.failed";
205
    clue( key, imageFile );
206
207
    return imagePath;
200208
  }
201209
M src/main/resources/com/keenwrite/messages.properties
187187
Main.status.image.xhtml.image.found=Found image ''{0}''
188188
Main.status.image.xhtml.image.missing=Missing image ''{0}''
189
Main.status.image.xhtml.image.saved=Saved image ''{0}''
190
Main.status.image.xhtml.image.failed=Cannot save image ''{0}''
189191
190192
Main.status.font.search.missing=No font name starting with ''{0}'' was found