Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Update quote conversion, close resources

AuthorDaveJarvis <email>
Date2022-05-18 19:59:10 GMT-0700
Commit389281068dd0d4687efee79831244198b10c5f37
Parent034e046
Delta15 lines added, 15 lines removed
src/main/java/com/keenwrite/processors/XhtmlProcessor.java
final var attrs = node.getAttributes();
- if( attrs != null ) {
- final var attr = attrs.getNamedItem( "src" );
+ final var attr = attrs.getNamedItem( "src" );
- if( attr != null ) {
- final var imageFile = exportImage( attr.getTextContent() );
+ if( attr != null ) {
+ final var imageFile = exportImage( attr.getTextContent() );
- attr.setTextContent( imageFile.toString() );
- }
+ attr.setTextContent( imageFile.toString() );
}
} catch( final Exception ex ) {
// Download remote resources into temporary files.
if( protocol.isRemote() ) {
- final var response = httpGet( src );
- final var mediaType = response.getMediaType();
+ try( final var response = httpGet( src ) ) {
+ final var mediaType = response.getMediaType();
- imageFile = mediaType.createTemporaryFile( APP_TITLE_LOWERCASE );
+ imageFile = mediaType.createTemporaryFile( APP_TITLE_LOWERCASE );
- try( final var image = response.getInputStream() ) {
- copy( image, imageFile, REPLACE_EXISTING );
- }
+ try( final var image = response.getInputStream() ) {
+ copy( image, imageFile, REPLACE_EXISTING );
+ }
- // Strip comments, superfluous whitespace, DOCTYPE, and XML declarations.
- if( mediaType.isSvg() ) {
- DocumentParser.sanitize( imageFile );
+ // Strip comments, superfluous whitespace, DOCTYPE, and XML
+ // declarations.
+ if( mediaType.isSvg() ) {
+ DocumentParser.sanitize( imageFile );
+ }
}
}