2021-04-23 12:38:07 +00:00
|
|
|
#
|
|
|
|
# ext/html-preview.pm
|
|
|
|
#
|
|
|
|
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
|
|
|
#
|
|
|
|
# This file is part of vscode-texinfo.
|
|
|
|
#
|
|
|
|
# vscode-texinfo is free software: you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
|
|
# Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# vscode-texinfo is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along with
|
|
|
|
# vscode-texinfo. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
2021-04-24 17:39:48 +00:00
|
|
|
sub vscode_convert_image_uri {
|
2021-04-23 12:38:07 +00:00
|
|
|
my ( $self, $cmdname, $command, $args ) = @_;
|
|
|
|
|
|
|
|
my $filename = $args->[0]->{'monospacetext'};
|
2021-04-24 17:39:48 +00:00
|
|
|
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) }(@_);
|
2021-04-23 12:38:07 +00:00
|
|
|
}
|
|
|
|
|
2021-04-24 17:39:48 +00:00
|
|
|
texinfo_register_command_formatting( 'image', \&vscode_convert_image_uri );
|
2021-04-23 12:38:07 +00:00
|
|
|
|
|
|
|
1;
|