[latex3-commits] [git/LaTeX3-latex3-latex3] master: Basic support for 'fall back' image extensions (d755ead)
Joseph Wright
joseph.wright at morningstar2.co.uk
Wed May 8 18:24:17 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/d755eadcd7ad1b5aa352ff72733508e081345952
>---------------------------------------------------------------
commit d755eadcd7ad1b5aa352ff72733508e081345952
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Wed May 8 17:24:17 2019 +0100
Basic support for 'fall back' image extensions
Needs more work: doesn't like .tex at the moment!
>---------------------------------------------------------------
d755eadcd7ad1b5aa352ff72733508e081345952
l3experimental/l3image/l3image.dtx | 45 ++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 7 deletions(-)
diff --git a/l3experimental/l3image/l3image.dtx b/l3experimental/l3image/l3image.dtx
index c3b14c7..2bb9e13 100644
--- a/l3experimental/l3image/l3image.dtx
+++ b/l3experimental/l3image/l3image.dtx
@@ -172,8 +172,17 @@
% the two-argument version, or is inferred from the file extension extracted
% in the single-argument form. The exact image types supported depend upon
% the driver in use.
+%
+% Where the \meta{file} is not found and the \meta{type} is \emph{not}
+% given, a search for possible image files is undertaken using the extensions
+% stored in \cs{l_image_search_ext_seq}.
% \end{function}
%
+% \begin{variable}{\l_image_extensions_seq}
+% Extensions to use for image searching when the given \meta{file} name is not
+% found by \cs{image_include:n}.
+% \end{variable}
+%
% \begin{variable}{\l_image_search_path_seq}
% Each entry is the path to a directory which should be searched when
% seeking an image file. Each path can be relative or absolute, and should
@@ -470,6 +479,13 @@
% \end{macrocode}
% \end{variable}
%
+% \begin{variable}{\l_image_search_ext_seq}
+% Used to specify fall-back extensions: actually set on a per-driver basis.
+% \begin{macrocode}
+\seq_new:N \l_image_search_ext_seq
+% \end{macrocode}
+% \end{variable}
+%
% \begin{variable}{\g_@@_record_seq}
% A list of image files used.
% \begin{macrocode}
@@ -477,26 +493,39 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{macro}{\image_include:n, \image_include:nn}
+% \begin{macro}{\image_include:n}
+% \begin{macro}{\@@_include:}
+% \begin{macro}{\image_include:nn}
% \begin{macro}{\@@_include:n}
% Actually including an image is relatively straight-forward: most of the
% work is done by the driver. We only have to deal with making sure the
-% box has no apparent depth.
+% box has no apparent depth. Where the first given name is not found, we
+% search based on extension only if the \meta{type} was not given.
% \begin{macrocode}
\cs_new_protected:Npn \image_include:n #1
{
\group_begin:
\seq_set_eq:NN \l_file_search_path_seq \l_image_search_path_seq
\file_get_full_name:nNTF {#1} \l_@@_name_tl
+ { \@@_include: }
{
- \file_parse_full_name:VNNN \l_@@_name_tl
- \l_@@_dir_str \l_@@_name_str \l_@@_ext_str
- \exp_args:Nx \@@_include:n
- { \str_tail:N \l_@@_ext_str }
+ \seq_map_inline:Nn \l_image_search_ext_seq
+ {
+ \file_get_full_name:nNT { #1 . ##1 } \l_@@_name_tl
+ { \seq_map_break:n { \use_i:nnn \@@_include: } }
+ }
+ \use:n
+ { \__kernel_msg_error:nnn { image } { image-not-found } {#1} }
}
- { \__kernel_msg_error:nnn { image } { image-not-found } {#1} }
\group_end:
}
+\cs_new_protected:Npn \@@_include:
+ {
+ \file_parse_full_name:VNNN \l_@@_name_tl
+ \l_@@_dir_str \l_@@_name_str \l_@@_ext_str
+ \exp_args:Nx \@@_include:n
+ { \str_tail:N \l_@@_ext_str }
+ }
\cs_new_protected:Npn \image_include:nn #1#2
{
\group_begin:
@@ -536,6 +565,8 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
%
% \begin{macro}{\image_show_list:, \image_log_list:, \@@_list:N}
% \begin{macro}[EXP]{\@@_list_aux:n}
More information about the latex3-commits
mailing list