diff options
author | Karl Berry <karl@freefriends.org> | 2017-11-22 22:44:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-11-22 22:44:42 +0000 |
commit | 6ded4238ca0913166ea4b5a5efdde5f44900d3e8 (patch) | |
tree | 0647eeedddb841e93d9eb7f6c44b6bd111a47832 /Master/texmf-dist/tex | |
parent | 1bea5926931cacb1ac5323dc459a8c297f3b9871 (diff) |
lyluatex (22nov17)
git-svn-id: svn://tug.org/texlive/trunk@45886 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty b/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty new file mode 100644 index 00000000000..f3cc35dbf22 --- /dev/null +++ b/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty @@ -0,0 +1,73 @@ +\ProvidesPackage{lyluatex} + +% Dépendances +\RequirePackage{luatexbase} +\RequirePackage{luaotfload} +\RequirePackage{kvoptions} +\RequirePackage{graphicx} +\RequirePackage{keycommand} +\RequirePackage{environ} +\RequirePackage{currfile} +% Options +\DeclareStringOption[lilypond]{program}[lilypond] +\ProcessKeyvalOptions* +% Script lua +\directlua{dofile(kpse.find_file("lyluatex.lua"))} +\directlua{LILYPOND = '\lyluatex@program'} + +% Une tricherie un peu sale pour récupérer la largeur de ligne +\let\bs\textbackslash +{\catcode`p=12 \catcode`t=12 \gdef\un#1pt{#1}} +\newcommand*{\largeur}{\expandafter\un\the\linewidth} +% Taille des partitions +% Si la valeur est 0, elle sera automatiquement calculée +% à partir de la taille de police. +\def\staffsize{0} +\let\localstaffsize\staffsize + + +% Commandes principales +% Inclusion d'un fichier ly +\newkeycommand*\includely[staffsize=\staffsize][autres][1]{% +\directlua{% + inclure_ly( + "\luatexluaescapestring{#1}", + "\luatexluaescapestring{\currfiledir}", + \luatexluaescapestring{\largeur}, + \luatexluaescapestring{\commandkey{staffsize}} + )% +}% +} + +% Inclusion d'un fragment intégré au document (environnement de base) +\NewEnviron{compilerly}{% +\directlua{% + direct_ly( + "\luatexluaescapestring{\unexpanded\expandafter{\BODY}}", + \luatexluaescapestring{\largeur}, + \luatexluaescapestring{\localstaffsize} + )% +}% +} + +% Commande et environnement avec paramètres +\newkeycommand{\lily}[staffsize=\staffsize][autres][1]{% +\def\localstaffsize{\commandkey{staffsize}}% +\begin{compilerly}% +{#1} +\end{compilerly}% +} + +\newkeyenvironment{ly}[staffsize=\staffsize][autres]{% +\def\localstaffsize{\commandkey{staffsize}}% +\compilerly% +}{% +\endcompilerly% +} + +% Commandes pour la compatibilité avec lilypond-book +\let\lilypondfile\includely +\protected\def\lilypond{\def\reserved@a{lilypond}% + \ifx\reserved@a\@currenvir \expandafter \ly + \else \expandafter\lily \fi} +\let\endlilypond\endly |