From 1bcbcdf719a79c5b851d5506608fd117288f90cc Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 2 Sep 2019 20:57:55 +0000
Subject: lwarp (2sep19)

git-svn-id: svn://tug.org/texlive/trunk@52016 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/lwarp/lwarp-lyluatex.sty  | 62 +++++++++++++++-------
 1 file changed, 42 insertions(+), 20 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/lwarp/lwarp-lyluatex.sty')

diff --git a/Master/texmf-dist/tex/latex/lwarp/lwarp-lyluatex.sty b/Master/texmf-dist/tex/latex/lwarp/lwarp-lyluatex.sty
index d77574e1597..72772a2edba 100644
--- a/Master/texmf-dist/tex/latex/lwarp/lwarp-lyluatex.sty
+++ b/Master/texmf-dist/tex/latex/lwarp/lwarp-lyluatex.sty
@@ -15,31 +15,53 @@
 %%   http://www.latex-project.org/lppl.txt
 %% and version 1.3 or later is part of all distributions of LaTeX
 %% version 2005/12/01 or later.
+\LWR@origRequirePackage{luacode}
+
 \LWR@ProvidesPackagePass{lyluatex}[2019/05/27]
-\newcommand*{\lyluateximagename}{(-lilypond-~\packagediagramname)}
+\newcommand*{\LyluatexImageAltText}{-lilypond-~\PackageDiagramAltText}
 \LetLtxMacro\LWR@orig@ly@compilescore\ly@compilescore
 
 \renewcommand*{\ly@compilescore}[1]{%
-    \begin{lateximage}[\lyluateximagename]%
-    \LWR@orig@ly@compilescore{#1}%
-    \end{lateximage}%
-}
-
-\AtBeginDocument{
-    \lysetoption{paperwidth}{6in}
-    \lysetoption{paperheight}{9in}
-    \lysetoption{line-width}{5.5in}
-    \lysetoption{twoside}{false}
-    \lysetoption{fullpagestyle}{empty}
-    \lysetoption{fullpagealign}{crop}
-    \lysetoption{print-page-number}{false}
-    \lysetoption{insert}{systems}
-    \lysetoption{extra-top-margin}{0}
-    \lysetoption{extra-bottom-margin}{0}
-    \lysetoption{valign}{center}
-    \lysetoption{staffsize}{20}
-    \lysetoption{inline-staffsize}{14}
+    \begingroup%
+    \LWR@orignewpage%
+    \LWR@origloadgeometry{LWR@usergeometry}%
+    \LWR@print@normalsize%
+    \renewcommand{\includegraphics}[2][]{%
+        \InlineClass{lyluatex}{%
+            \begin{lateximage}[\LyluatexImageAltText]%
+            \LWR@addbaselinemarker%
+            \LWR@origincludegraphics{##2}%
+            \end{lateximage}%
+        }%
+    }%
+    \ly@setunits%
+    \directlua{
+        ly_opts:set_option('currfiledir', [[\currfiledir]])
+        ly_opts:set_option('twoside', '\ly@istwosided')
+        #1
+    }%
+    \ly@resetunits%
+    \ly@currentfonts%
+    \directlua{
+        if (ly.score.insert == 'fullpage') then
+            tex.print{[[\string\begin{BlockClass}{lyluatex}]]}
+        end
+    }%
+    \directlua{ly.score:process()}%
+    \directlua{
+        if (ly.score.insert == 'fullpage') then
+            tex.print{[[\string\end{BlockClass}]]}
+        end
+    }%
+    \LWR@orignewpage%
+    \LWR@origrestoregeometry%
+    \endgroup%
 }
+\xpatchcmd{\endly@bufferenv}
+    {\hspace{0pt}\\}
+    {}
+    {}
+    {\LWR@patcherror{lyluatex}{endly@bufferenv}}
 \endinput
 %%
 %% End of file `lwarp-lyluatex.sty'.
-- 
cgit v1.2.3

