diff --git a/ext/html-preview.pm b/ext/html-preview.pm index 324d5c6..4d5fe01 100644 --- a/ext/html-preview.pm +++ b/ext/html-preview.pm @@ -21,23 +21,20 @@ use strict; -sub vscode_convert_texinfo_image_uri { +sub vscode_convert_image_uri { my ( $self, $cmdname, $command, $args ) = @_; my $filename = $args->[0]->{'monospacetext'}; - if ( defined($filename) - && rindex( $filename, 'http://', 0 ) == -1 - && rindex( $filename, 'https://', 0 ) == -1 ) - { - $self->set_conf( 'IMAGE_LINK_PREFIX', - $self->{'parser'}->{'values'}->{'__vscode_texinfo_image_uri_base'} - ); - } - return &{ $self->default_commands_conversion($cmdname) } - ( $self, $cmdname, $command, $args ); + my $prefix + = ( defined($filename) + && rindex( $filename, 'http://', 0 ) == -1 + && rindex( $filename, 'https://', 0 ) == -1 ) + ? $self->{'parser'}->{'values'}->{'__vscode_texinfo_image_uri_base'} + : undef; + $self->set_conf( 'IMAGE_LINK_PREFIX', $prefix ); + return &{ $self->default_commands_conversion($cmdname) }(@_); } -texinfo_register_command_formatting( 'image', - \&vscode_convert_texinfo_image_uri ); +texinfo_register_command_formatting( 'image', \&vscode_convert_image_uri ); 1; diff --git a/scripts/make-vsix.js b/scripts/make-vsix.js index 420bed7..1b2f489 100644 --- a/scripts/make-vsix.js +++ b/scripts/make-vsix.js @@ -6,7 +6,7 @@ * this notice are preserved. This file is offered as-is, without any warranty. */ -const fs = require('fs') +const fs = require('fs'); const yazl = require('yazl'); async function addPathToZipFile(zipFile, path) { diff --git a/scripts/package.sh b/scripts/package.sh index 2877fb5..a4884dd 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -19,10 +19,11 @@ minify-xml --output extension.vsixmanifest{,} cd extension # Minify JSON files. json -j0 -I -e "$PACKAGE_JSON_CLEANUP_JS" -f package.json -sed -i '' -e '2d' package.json +perl -pi -e 'chomp if eof' package.json json5 -o language-configuration.json{,} # Remove comments from Markdown files. -sed -i '' -e '1,8d' README.md CHANGELOG.md +tail -n +9 README.md > _ && mv _ README.md +tail -n +9 CHANGELOG.md > _ && mv _ CHANGELOG.md cd ext # Minify Perl scripts. if [ -x "$(command -v perltidy)" ]; then