texlive[45886] Master: lyluatex (22nov17)

commits+karl at tug.org commits+karl at tug.org
Wed Nov 22 23:44:42 CET 2017


Revision: 45886
          http://tug.org/svn/texlive?view=revision&revision=45886
Author:   karl
Date:     2017-11-22 23:44:42 +0100 (Wed, 22 Nov 2017)
Log Message:
-----------
lyluatex (22nov17)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/collection-music.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/support/lyluatex/
    trunk/Master/texmf-dist/doc/support/lyluatex/LICENSE
    trunk/Master/texmf-dist/doc/support/lyluatex/README.md
    trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.pdf
    trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.tex
    trunk/Master/texmf-dist/scripts/lyluatex/
    trunk/Master/texmf-dist/scripts/lyluatex/lyluatex.lua
    trunk/Master/texmf-dist/tex/latex/lyluatex/
    trunk/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty
    trunk/Master/tlpkg/tlpsrc/lyluatex.tlpsrc

Added: trunk/Master/texmf-dist/doc/support/lyluatex/LICENSE
===================================================================
--- trunk/Master/texmf-dist/doc/support/lyluatex/LICENSE	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/lyluatex/LICENSE	2017-11-22 22:44:42 UTC (rev 45886)
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 jperon
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+

Added: trunk/Master/texmf-dist/doc/support/lyluatex/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/lyluatex/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/lyluatex/README.md	2017-11-22 22:44:42 UTC (rev 45886)
@@ -0,0 +1,56 @@
+This material is subject to the MIT license.
+
+# Lyluatex
+## Usage
+
+In the preable of your document, include the package `lyluatex`:
+
+    \usepackage{lyluatex}
+
+The `program` option permits the definition of an alternative path to
+`lilypond`, for example:
+
+    \usepackage[program=/opt/lilypond-dev/lilypond]{lyluatex}
+
+Thereafter, you can include a lilypond file with the command:
+
+    \includely[staffsize=17]{CHEMIN/VERS/LA/PARTITION}
+
+The argument `staffsize`, which is optional, changes the size of the score.  You
+can change the size for all the subsequent scores in a document by placing the
+following command before your first include statement to be so affected:
+
+    \def\staffsize{24}
+
+Next, you simply need to compile the document normally with the command
+`lualatex -shell-escape` :
+
+    lualatex -shell-escape DOCUMENT.TEX
+
+Another "more secure" option is to add `lilypond` to default allowed commands :
+
+    shell_escape_commands=$(kpsewhich -expand-var '$shell_escape_commands'),lilypond lualatex DOCUMENT.TEX
+
+On systems with low RAM, when working on big documents, you could encounter
+*buffer overflows* in `lilypond` calls. In that case, first compile with option
+`-draftmode`, then compile again without this option.
+
+You can also input music directly into your docoment with the `ly` environment.
+This is only recommended for very short snippets.  For example:
+
+    \begin{ly}
+    \relative c' { c d e f g a b c }
+    \end{ly}
+
+
+## Migration from `lilypond-book`
+
+In order to facilitate the migration from `lilypond-book`, `lyluatex` defines
+the command `\lilypondfile` with the same arguments as `\includely`.  There is
+also the environment `lilypond` which is the same as `ly`, and the command
+`\lilypond` should work as with `lilypond-book`.
+
+In this manner, documents typeset with `lilypond-book` can be adapted to use
+`lyluatex` without much difficulty.  Just keep in mind that apart from the
+`staffsize` parameter, the optional parameters that `lilypond-book` supports are
+not supported by `lyluatex` (at least for now).


Property changes on: trunk/Master/texmf-dist/doc/support/lyluatex/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.pdf	2017-11-22 22:42:40 UTC (rev 45885)
+++ trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.pdf	2017-11-22 22:44:42 UTC (rev 45886)

Property changes on: trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.tex	2017-11-22 22:44:42 UTC (rev 45886)
@@ -0,0 +1,138 @@
+\documentclass[]{article}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage{ifxetex,ifluatex}
+\usepackage{fixltx2e} % provides \textsubscript
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+  \usepackage[T1]{fontenc}
+  \usepackage[utf8]{inputenc}
+\else % if luatex or xelatex
+  \ifxetex
+    \usepackage{mathspec}
+  \else
+    \usepackage{fontspec}
+  \fi
+  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
+\fi
+% use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+% use microtype if available
+\IfFileExists{microtype.sty}{%
+\usepackage[]{microtype}
+\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
+}{}
+\PassOptionsToPackage{hyphens}{url} % url is loaded by hyperref
+\usepackage[unicode=true]{hyperref}
+\hypersetup{
+            pdfborder={0 0 0},
+            breaklinks=true}
+\urlstyle{same}  % don't use monospace font for urls
+\IfFileExists{parskip.sty}{%
+\usepackage{parskip}
+}{% else
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+}
+\setlength{\emergencystretch}{3em}  % prevent overfull lines
+\providecommand{\tightlist}{%
+  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+\setcounter{secnumdepth}{0}
+% Redefines (sub)paragraphs to behave more like sections
+\ifx\paragraph\undefined\else
+\let\oldparagraph\paragraph
+\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
+\fi
+\ifx\subparagraph\undefined\else
+\let\oldsubparagraph\subparagraph
+\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
+\fi
+
+% set default figure placement to htbp
+\makeatletter
+\def\fps at figure{htbp}
+\makeatother
+
+
+\date{}
+
+\begin{document}
+
+\section{Lyluatex}\label{lyluatex}
+
+\subsection{Usage}\label{usage}
+
+In the preable of your document, include the package \texttt{lyluatex}:
+
+\begin{verbatim}
+\usepackage{lyluatex}
+\end{verbatim}
+
+The \texttt{program} option permits the definition of an alternative
+path to \texttt{lilypond}, for example:
+
+\begin{verbatim}
+\usepackage[program=/opt/lilypond-dev/lilypond]{lyluatex}
+\end{verbatim}
+
+Thereafter, you can include a lilypond file with the command:
+
+\begin{verbatim}
+\includely[staffsize=17]{CHEMIN/VERS/LA/PARTITION}
+\end{verbatim}
+
+The argument \texttt{staffsize}, which is optional, changes the size of
+the score. You can change the size for all the subsequent scores in a
+document by placing the following command before your first include
+statement to be so affected:
+
+\begin{verbatim}
+\def\staffsize{24}
+\end{verbatim}
+
+Next, you simply need to compile the document normally with the command
+\texttt{lualatex\ -shell-escape}~:
+
+\begin{verbatim}
+lualatex -shell-escape DOCUMENT.TEX
+\end{verbatim}
+
+Another ``more secure'' option is to add \texttt{lilypond} to default
+allowed commands~:
+
+\begin{verbatim}
+shell_escape_commands=$(kpsewhich -expand-var '$shell_escape_commands'),lilypond lualatex DOCUMENT.TEX
+\end{verbatim}
+
+On systems with low RAM, when working on big documents, you could
+encounter \emph{buffer overflows} in \texttt{lilypond} calls. In that
+case, first compile with option \texttt{-draftmode}, then compile again
+without this option.
+
+You can also input music directly into your docoment with the
+\texttt{ly} environment. This is only recommended for very short
+snippets. For example:
+
+\begin{verbatim}
+\begin{ly}
+\relative c' { c d e f g a b c }
+\end{ly}
+\end{verbatim}
+
+\subsection{\texorpdfstring{Migration from
+\texttt{lilypond-book}}{Migration from lilypond-book}}\label{migration-from-lilypond-book}
+
+In order to facilitate the migration from \texttt{lilypond-book},
+\texttt{lyluatex} defines the command
+\texttt{\textbackslash{}lilypondfile} with the same arguments as
+\texttt{\textbackslash{}includely}. There is also the environment
+\texttt{lilypond} which is the same as \texttt{ly}, and the command
+\texttt{\textbackslash{}lilypond} should work as with
+\texttt{lilypond-book}.
+
+In this manner, documents typeset with \texttt{lilypond-book} can be
+adapted to use \texttt{lyluatex} without much difficulty. Just keep in
+mind that apart from the \texttt{staffsize} parameter, the optional
+parameters that \texttt{lilypond-book} supports are not supported by
+\texttt{lyluatex} (at least for now).
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/support/lyluatex/lyluatex.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/scripts/lyluatex/lyluatex.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/lyluatex/lyluatex.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/scripts/lyluatex/lyluatex.lua	2017-11-22 22:44:42 UTC (rev 45886)
@@ -0,0 +1,186 @@
+local err, warn, info, log = luatexbase.provides_module({
+    name               = "lyluatex",
+    version            = '0',
+    greinternalversion = internalversion,
+    date               = "2017/11/19",
+    description        = "Module lyluatex.",
+    author             = "The Gregorio Project (see CONTRIBUTORS.md)",
+    copyright          = "2008-2017 - The Gregorio Project",
+    license            = "MIT",
+})
+
+local md5 = require 'md5'
+
+
+LILYPOND = 'lilypond'
+TMP = 'tmp_ly'
+N = 0
+
+
+function ly_definir_programme(lilypond)
+    if lilypond then LILYPOND = lilypond end
+end
+
+
+function contenuIntegral(contenu)
+    local content =""
+    for i, Line in ipairs(contenu:explode('\n')) do
+	if Line:find("^%s*[^%%]*\\include") then
+	    local i = io.open(Line:gsub('%s*\\include%s*"(.*)"%s*$', "%1"), 'r')
+	    if i then
+		content = content .. contenuIntegral(i:read('*a'))
+	    else
+		content = content .. Line .. "\n"
+	    end
+	else
+	    content = content .. Line .. "\n"
+	end
+    end
+    return content
+end
+
+
+function direct_ly(ly, largeur, facteur)
+    N = N + 1
+    facteur = calcul_facteur(facteur)
+    ly = ly:gsub('\\par ', '\n'):gsub('\\([^%s]*) %-([^%s])', '\\%1-%2')
+    local sortie = TMP..'/'..string.gsub(md5.sumhexa(contenuIntegral(ly))..'-'..facteur..'-'..largeur, '%.', '-')
+    if not lfs.isfile(sortie..'-systems.tex') then
+        compiler_ly(entete_lilypond(facteur, largeur - 10)..'\n'..ly, sortie)
+    end
+    retour_tex(sortie)
+end
+
+
+function inclure_ly(entree, currfiledir, largeur, facteur)
+    facteur = calcul_facteur(facteur)
+    nom = splitext(entree, 'ly')
+    entree = currfiledir..nom..'.ly'
+    if not lfs.isfile(entree) then entree = kpse.find_file(nom..'.ly') end
+    if not lfs.isfile(entree) then err("Le fichier %s.ly n'existe pas.", nom) end
+    local i = io.open(entree, 'r')
+    ly = i:read('*a')
+    i:close()
+    local sortie = TMP..'/' ..string.gsub(md5.sumhexa(contenuIntegral(ly))..'-'..facteur..'-'..largeur, '%.', '-')
+    if not lfs.isfile(sortie..'-systems.tex') then
+        compiler_ly(entete_lilypond(facteur, largeur - 10)..'\n'..ly, sortie, dirname(entree))
+    end
+    retour_tex(sortie)
+end
+
+
+function compiler_ly(ly, sortie, include)
+    mkdirs(dirname(sortie))
+    local commande = LILYPOND.." "..
+        "-dno-point-and-click "..
+        "-dbackend=eps "..
+        "-djob-count=2 "..
+        "-ddelete-intermediate-files "
+    if include then commande = commande.."-I '"..lfs.currentdir().."/"..include.."' " end
+    commande = commande.."-o "..sortie.." -"
+    local p = io.popen(commande, 'w')
+    p:write(ly)
+    p:close()
+end
+
+
+function entete_lilypond(facteur, largeur)
+    return string.format(
+[[%%En-tête
+\version "2.18.2"
+#(define default-toplevel-book-handler
+  print-book-with-defaults-as-systems )
+
+#(define toplevel-book-handler
+  (lambda ( . rest)
+  (set! output-empty-score-list #f)
+  (apply print-book-with-defaults rest)))
+
+#(define toplevel-music-handler
+  (lambda ( . rest)
+   (apply collect-music-for-book rest)))
+
+#(define toplevel-score-handler
+  (lambda ( . rest)
+   (apply collect-scores-for-book rest)))
+
+#(define toplevel-text-handler
+  (lambda ( . rest)
+   (apply collect-scores-for-book rest)))
+
+
+#(set-global-staff-size %s)
+
+
+%%Paramètres de la partition
+\paper{
+    indent = 0\mm
+    line-width = %s\pt
+}
+
+%%Partition originale
+]],
+facteur,
+largeur
+)
+end
+
+
+function calcul_facteur(facteur)
+    if facteur == 0 then facteur = fontinfo(font.current()).size/39321.6 end
+    return facteur
+end
+
+
+function retour_tex(sortie)
+    local i = io.open(sortie..'-systems.tex', 'r')
+    contenu = i:read("*all")
+    i:close()
+    texoutput, _ = string.gsub(
+        contenu,
+        [[includegraphics{]], [[includegraphics{]]..dirname(sortie)
+    )
+    tex.print(([[\noindent]]..texoutput):explode('\n'))
+end
+
+
+function dirname(str)
+    if str:match(".-/.-") then
+        local name = string.gsub(str, "(.*/)(.*)", "%1")
+        return name
+    else
+        return ''
+    end
+end
+
+
+function splitext(str, ext)
+    if str:match(".-%..-") then
+        local name = string.gsub(str, "(.*)(%." .. ext .. ")", "%1")
+        return name
+    else
+        return str
+    end
+end
+
+
+function mkdirs(str)
+    path = '.'
+    for dir in string.gmatch(str, '([^%/]+)') do
+        path = path .. '/' .. dir
+        lfs.mkdir(path)
+    end
+end
+
+
+local fontdata = fonts.hashes.identifiers
+function fontinfo(id)
+    local f = fontdata[id]
+    if f then
+        return f
+    end
+    return font.fonts[id]
+end
+
+
+mkdirs(TMP)


Property changes on: trunk/Master/texmf-dist/scripts/lyluatex/lyluatex.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty	2017-11-22 22:44:42 UTC (rev 45886)
@@ -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 at 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 at a{lilypond}%
+  \ifx\reserved at a\@currenvir \expandafter \ly
+  \else \expandafter\lily \fi}
+\let\endlilypond\endly


Property changes on: trunk/Master/texmf-dist/tex/latex/lyluatex/lyluatex.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2017-11-22 22:42:40 UTC (rev 45885)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2017-11-22 22:44:42 UTC (rev 45886)
@@ -398,7 +398,7 @@
     luamesh luamplib luaotfload luapackageloader
     luasseq luatex85 luatexbase luatexja luatexko luatextra
     luatodonotes luaxml
-    lwarp lxfonts ly1
+    lwarp lxfonts ly1 lyluatex
   m-tx macros2e macroswap mafr magaz mailing mailmerge
     make4ht makebarcode makebase makebox makecell makecirc makecmds
     makedtx makeglos makeplot maker

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2017-11-22 22:42:40 UTC (rev 45885)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2017-11-22 22:44:42 UTC (rev 45886)
@@ -2792,6 +2792,7 @@
  'lualatex-math'        => '\.lua$',
  'luamesh'		=> '\.lua$',
  'luasseq'              => '\.lua$',
+ 'lyluatex'		=> '\.lua$',
  'make4ht'		=> 'filters|\.lua$',
  'mycv'                 => 'mycv_split_contents\.pl',
  'pgfmolbio'		=> '\.lua$',

Modified: trunk/Master/tlpkg/tlpsrc/collection-music.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-music.tlpsrc	2017-11-22 22:42:40 UTC (rev 45885)
+++ trunk/Master/tlpkg/tlpsrc/collection-music.tlpsrc	2017-11-22 22:44:42 UTC (rev 45886)
@@ -16,6 +16,7 @@
 depend harmony
 depend leadsheets
 depend lilyglyphs
+depend lyluatex
 depend m-tx
 depend musicography
 depend musixguit

Added: trunk/Master/tlpkg/tlpsrc/lyluatex.tlpsrc
===================================================================


More information about the tex-live-commits mailing list