diff options
author | Karl Berry <karl@freefriends.org> | 2022-08-12 21:10:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-08-12 21:10:33 +0000 |
commit | 3edecded35f54f8efc8ee5ba322d25eca38038cb (patch) | |
tree | 5dcce8bc27611c262b91dca6adbc12bb37bd857a /Master/texmf-dist/tex/latex | |
parent | e8edaa14a713f455b6102abf7384068939d08de3 (diff) |
media4svg (12aug22)
git-svn-id: svn://tug.org/texlive/trunk@64107 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rwxr-xr-x | Master/texmf-dist/tex/latex/media4svg/media4svg.lua | 30 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/media4svg/media4svg.sty | 17 |
2 files changed, 28 insertions, 19 deletions
diff --git a/Master/texmf-dist/tex/latex/media4svg/media4svg.lua b/Master/texmf-dist/tex/latex/media4svg/media4svg.lua index ae291a368ee..6abc26d339a 100755 --- a/Master/texmf-dist/tex/latex/media4svg/media4svg.lua +++ b/Master/texmf-dist/tex/latex/media4svg/media4svg.lua @@ -1,9 +1,9 @@ #!/usr/bin/env texlua -------------------------------------------------------------------------------- +-- ============================================================================ -- -- media4svg.lua -- --- base64 encoding utility, version 2020/04/09 +-- base64 encoding utility, version 2022/08/12 -- -- (C) 2020-today, Alexander Grahn, using code by Alex Kloss -- @@ -11,22 +11,26 @@ -- -- 1. as a commandline utility: -- --- texlua media4svg.lua <file> +-- texlua media4svg.lua <file> [<chunksize>] -- -- 2. as a library from within LuaTeX input: -- -- \directlua{require('media4svg')} -- \directlua{media4svg.base64("<file>",<chunksize>,"<end-of-line string>")} -- --- <file> string; file name --- <chunksize> integer, multiple of 3; size of binary data (bytes) --- to be converted at a time --- <end-of-line string> a string to be appended at the end of every output --- line +-- The output is placed into LuaTeX's input stream. -- --- The output is placed into LuaTeX's input stream. +-- ---------------------------------------------------------------------------- -- -------------------------------------------------------------------------------- +-- <file> string; file name +-- <chunksize> integer, multiple of 3; size of binary data (bytes) +-- to be converted at a time +-- <end-of-line string> a string to be appended at the end of every converted +-- chunk; usually a newline should be passed here, or +-- something equivalent, such as "{?nl}" when using the +-- output in a `dvisvgm:raw' \special +-- +-- ============================================================================ -- This work may be distributed and/or modified under the -- conditions of the LaTeX Project Public License. @@ -91,8 +95,12 @@ if (string.find(arg[0],'media4svg%.lua$') and arg[1] ~= nil) then end local filehandle = io.open(foundfile,'rb') if not filehandle then os.exit(1) end + local chunksize=72 + if arg[2] ~= nil then + chunksize= tonumber(arg[2]) + end while true do - local data = filehandle:read(72) + local data = filehandle:read(chunksize) if not data then break end print(base64(data)) end diff --git a/Master/texmf-dist/tex/latex/media4svg/media4svg.sty b/Master/texmf-dist/tex/latex/media4svg/media4svg.sty index 4a3396f10ac..fec450169ba 100644 --- a/Master/texmf-dist/tex/latex/media4svg/media4svg.sty +++ b/Master/texmf-dist/tex/latex/media4svg/media4svg.sty @@ -23,8 +23,8 @@ % % The Current Maintainer of this work is A. Grahn. -\def\g@msvg@date@tl{2022/08/04} -\def\g@msvg@version@tl{0.8} +\def\g@msvg@date@tl{2022/08/12} +\def\g@msvg@version@tl{0.9} \NeedsTeXFormat{LaTeX2e}[2022-06-01] \ProvidesExplPackage{media4svg}{\g@msvg@date@tl}{\g@msvg@version@tl} @@ -190,8 +190,8 @@ } % base64-encode (non-Lua way) the media file \sys_if_engine_luatex:F{ - \msvg_convert_file_to_blob:nN{ - \l_msvg_full_name_tl}\g_msvg_media_blob_tl + \msvg_convert_file_to_blob:nnnN{ + \l_msvg_full_name_tl}{72}{{?nl}}\g_msvg_media_blob_tl } } \special{dvisvgm:raw {?nl} @@ -729,7 +729,8 @@ % (very slow!) \cs_set_eq:NN\ior_msvg_shell_open:Nn\ior_shell_open:Nn \cs_generate_variant:Nn\ior_msvg_shell_open:Nn{Nx} -\cs_new_protected_nopar:Nn\msvg_convert_file_to_blob:nN{% #1 filename, #2 tlvar +\cs_new_protected_nopar:Nn\msvg_convert_file_to_blob:nnnN{ + % #1 filename, #2 chunk size, #3 endline marker, #4 tlvar \sys_if_shell_unrestricted:F{ \msg_error:nnx{media4svg}{unrestricted~shell~required}{#1} } @@ -741,11 +742,11 @@ } \ior_close:N\g_tmpa_ior % encode - \ior_msvg_shell_open:Nx\g_tmpa_ior{texlua~\l_tmpa_tl\space #1} + \ior_msvg_shell_open:Nx\g_tmpa_ior{texlua~\l_tmpa_tl\space #1\space #2} \message{<#1} - \tl_gclear_new:N#2 + \tl_gclear_new:N#4 \ior_str_map_inline:Nn\g_tmpa_ior{ - \tl_gput_right:Nn#2{##1{?nl}}\message{.}}\message{>} + \tl_gput_right:Nn#4{##1#3}\message{.}}\message{>} \ior_close:N\g_tmpa_ior } |