update to new lyluatex version
This commit is contained in:
parent
c9ed77b424
commit
14e3703736
4
Makefile
4
Makefile
@ -54,7 +54,7 @@ ${BUILD_OPUS_DIR}:
|
|||||||
|
|
||||||
${TMP_SONG_DIR}/%.pdf: ${SONG_DIR}/%.ly ${SONG_DIR}/%.tex
|
${TMP_SONG_DIR}/%.pdf: ${SONG_DIR}/%.ly ${SONG_DIR}/%.tex
|
||||||
cd ${SRC_DIR} && lualatex --jobname='$(notdir $(basename $@))' --output-directory=${WORKING_DIR}/${TMP_SONG_DIR} --shell-escape ${WORKING_DIR}/${SRC_DIR}/song.tex ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).ly ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).tex
|
cd ${SRC_DIR} && lualatex --jobname='$(notdir $(basename $@))' --output-directory=${WORKING_DIR}/${TMP_SONG_DIR} --shell-escape ${WORKING_DIR}/${SRC_DIR}/song.tex ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).ly ${WORKING_DIR}/${SONG_DIR}/$(notdir $(basename $@)).tex
|
||||||
rm -r ${SRC_DIR}/tmp_ly
|
rm -r ${SRC_DIR}/tmp-ly
|
||||||
|
|
||||||
${BUILD_MIDI_DIR}/%.midi: ${TMP_MIDI_DIR}/%-1.midi
|
${BUILD_MIDI_DIR}/%.midi: ${TMP_MIDI_DIR}/%-1.midi
|
||||||
cp $< $@
|
cp $< $@
|
||||||
@ -67,7 +67,7 @@ ${BUILD_OPUS_DIR}/%.opus: ${BUILD_MIDI_DIR}/%.midi
|
|||||||
|
|
||||||
${TMP_BOOK_DIR}/%.pdf: ${SRC_DIR}/%.tex ${SRC_DIR}/images/title.png
|
${TMP_BOOK_DIR}/%.pdf: ${SRC_DIR}/%.tex ${SRC_DIR}/images/title.png
|
||||||
latexmk -cd -lualatex -e '$$lualatex=q/lualatex %O -shell-escape %S/' -output-directory=${WORKING_DIR}/${TMP_BOOK_DIR} $<
|
latexmk -cd -lualatex -e '$$lualatex=q/lualatex %O -shell-escape %S/' -output-directory=${WORKING_DIR}/${TMP_BOOK_DIR} $<
|
||||||
rm -r ${SRC_DIR}/tmp_ly
|
rm -r ${SRC_DIR}/tmp-ly
|
||||||
|
|
||||||
${TMP_BOOK_DIR}/%-folio.pdf: ${TMP_BOOK_DIR}/%.pdf
|
${TMP_BOOK_DIR}/%-folio.pdf: ${TMP_BOOK_DIR}/%.pdf
|
||||||
cd ${TMP_BOOK_DIR} && \
|
cd ${TMP_BOOK_DIR} && \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
% !Mode:: "TeX:UTF-8"
|
% !Mode:: "TeX:UTF-8"
|
||||||
|
|
||||||
\documentclass[11pt, openany, oneside]{scrbook}
|
\documentclass[11pt, openany, twoside]{scrbook}
|
||||||
\usepackage[utf8]{inputenc}
|
\usepackage[utf8]{inputenc}
|
||||||
\usepackage{fontspec}
|
\usepackage{fontspec}
|
||||||
\usepackage{fancyhdr}
|
\usepackage{fancyhdr}
|
||||||
@ -42,8 +42,25 @@
|
|||||||
|
|
||||||
\renewcommand\addchaptertocentry[2]{\addtocentrydefault{chapter}{}{#2}}
|
\renewcommand\addchaptertocentry[2]{\addtocentrydefault{chapter}{}{#2}}
|
||||||
\renewcommand{\contentsname}{Inhalt}
|
\renewcommand{\contentsname}{Inhalt}
|
||||||
\renewcommand{\cfttoctitlefont}{\huge\textbf\rmfamily}
|
|
||||||
\renewcommand{\cftchapfont}{\large\rmfamily}
|
\setlength{\columnseprule}{0.2pt}
|
||||||
|
|
||||||
|
\hypersetup
|
||||||
|
{
|
||||||
|
bookmarks=true, % show bookmarks bar?
|
||||||
|
unicode=true, % non-Latin characters in Acrobat’s bookmarks
|
||||||
|
pdftoolbar=true, % show Acrobat’s toolbar?
|
||||||
|
pdfmenubar=false, % show Acrobat’s menu?
|
||||||
|
pdffitwindow=false, % window fit to page when opened
|
||||||
|
pdfstartview={FitH}, % fits the width of the page to the window
|
||||||
|
pdftitle={Alcolica Kommersbuch}, % title
|
||||||
|
pdfauthor={Sebastian Hugentobler}, % author
|
||||||
|
pdfsubject={Kantenprügel der Alcolica Verbindung}, % subject of the document
|
||||||
|
pdfcreator={Sebastian Hugentobler}, % creator of the document
|
||||||
|
pdfproducer={Sebastian Hugentobler}, % producer of the document
|
||||||
|
pdfnewwindow=true, % links in new window
|
||||||
|
colorlinks=false, % false: boxed links; true: colored links
|
||||||
|
}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\begin{titlepage}
|
\begin{titlepage}
|
||||||
@ -62,6 +79,12 @@
|
|||||||
\tableofcontents
|
\tableofcontents
|
||||||
\newpage
|
\newpage
|
||||||
|
|
||||||
|
\lysetoption{staffsize}{22}
|
||||||
|
\lysetoption{quote}{true}
|
||||||
|
\lysetoption{indent}{false}
|
||||||
|
\lysetoption{insert}{inline}
|
||||||
|
\lysetoption{pass-fonts}{true}
|
||||||
|
|
||||||
\songs
|
\songs
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
187
src/lyluatex.lua
187
src/lyluatex.lua
@ -1,187 +0,0 @@
|
|||||||
local err, warn, info, log = luatexbase.provides_module({
|
|
||||||
name = "lyluatex",
|
|
||||||
version = '0',
|
|
||||||
greinternalversion = internalversion,
|
|
||||||
date = "2017/09/30",
|
|
||||||
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')
|
|
||||||
print(ly)
|
|
||||||
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)
|
|
@ -1,71 +0,0 @@
|
|||||||
\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
|
|
||||||
\let\lilypond\ly
|
|
||||||
\let\endlilypond\endly
|
|
@ -3,7 +3,6 @@
|
|||||||
\documentclass[11pt, openany, oneside]{scrbook}
|
\documentclass[11pt, openany, oneside]{scrbook}
|
||||||
|
|
||||||
\usepackage{fontspec}
|
\usepackage{fontspec}
|
||||||
%%\usepackage[a4paper,left=3cm,right=3cm, top=3cm, bottom=3cm,includeheadfoot]{geometry}
|
|
||||||
\usepackage[a4paper]{geometry}
|
\usepackage[a4paper]{geometry}
|
||||||
\usepackage{lmodern}
|
\usepackage{lmodern}
|
||||||
\usepackage{tgschola}
|
\usepackage{tgschola}
|
||||||
@ -14,8 +13,14 @@
|
|||||||
|
|
||||||
\pagenumbering{gobble}
|
\pagenumbering{gobble}
|
||||||
|
|
||||||
|
\lysetoption{staffsize}{22}
|
||||||
|
\lysetoption{quote}{true}
|
||||||
|
\lysetoption{indent}{false}
|
||||||
|
\lysetoption{insert}{inline}
|
||||||
|
\lysetoption{pass-fonts}{true}
|
||||||
|
|
||||||
\directlua{
|
\directlua{
|
||||||
tex.sprint("\string\\includely[staffsize=16]{" .. arg[5] .. "}")
|
tex.sprint("\string\\lilypondfile{" .. arg[5] .. "}")
|
||||||
}
|
}
|
||||||
~\\
|
~\\
|
||||||
\directlua{
|
\directlua{
|
||||||
|
@ -28,7 +28,7 @@ function find_songs(dir)
|
|||||||
local ly_title = string.match(ly_content, 'title = "(.-)"')
|
local ly_title = string.match(ly_content, 'title = "(.-)"')
|
||||||
|
|
||||||
tex.sprint('\\unchapter{' .. ly_title .. '}')
|
tex.sprint('\\unchapter{' .. ly_title .. '}')
|
||||||
tex.sprint('\\includely[staffsize=16]{' .. dir .. '/' .. file .. '}')
|
tex.sprint('\\lilypondfile{' .. dir .. '/' .. file .. '}')
|
||||||
tex.sprint('~\\\\')
|
tex.sprint('~\\\\')
|
||||||
tex.sprint('~\\\\')
|
tex.sprint('~\\\\')
|
||||||
tex.sprint('\\input{' .. dir .. '/' .. file:gsub("%.ly", ".tex") .. '}')
|
tex.sprint('\\input{' .. dir .. '/' .. file:gsub("%.ly", ".tex") .. '}')
|
||||||
|
Loading…
Reference in New Issue
Block a user