From cfcfe719baac6fb5379b6afb9ab858da48c62a17 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Mon, 14 Apr 2014 21:45:42 +0100 Subject: [PATCH 01/17] WIP: gestion des problemes d'encodages des index --- songbook_core/build.py | 4 ++-- songbook_core/index.py | 29 +++++++++++++++++------------ songbook_core/plastex.py | 4 +++- 3 files changed, 22 insertions(+), 15 deletions(-) mode change 100644 => 100755 songbook_core/index.py diff --git a/songbook_core/build.py b/songbook_core/build.py index bd50d0a3..a3bb9adb 100644 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -253,8 +253,8 @@ class SongbookBuilder(object): for sxd_file in sxd_files: LOGGER.debug("Processing " + sxd_file) idx = process_sxd(sxd_file) - with open(sxd_file[:-3] + "sbx", "w") as index_file: - index_file.write(idx.entries_to_str().encode('utf8')) + with codecs.open(sxd_file[:-3] + "sbx", "w", "utf-8") as index_file: + index_file.write(idx.entries_to_str()) @staticmethod def build_custom(command): diff --git a/songbook_core/index.py b/songbook_core/index.py old mode 100644 new mode 100755 index 75045c2d..504082d9 --- a/songbook_core/index.py +++ b/songbook_core/index.py @@ -11,11 +11,12 @@ from a file generated by the latex compilation of the songbook (.sxd). from unidecode import unidecode import locale import re +import codecs from songbook_core.authors import processauthors from songbook_core.plastex import simpleparse -EOL = "\n" +EOL = u"\n" # Pattern set to ignore latex command in title prefix KEYWORD_PATTERN = re.compile(r"^%(\w+)\s?(.*)$") @@ -37,11 +38,10 @@ def process_sxd(filename): Return an Index object. """ - index_file = open(filename) data = [] - for line in index_file: - data.append(line.strip()) - index_file.close() + with codecs.open(filename, 'r', 'utf-8') as index_file: + for line in index_file: + data.append(line.strip()) i = 1 idx = Index(data[0]) @@ -124,7 +124,7 @@ class Index(object): def _raw_add(self, key, number, link): """Add a song to the list. - No processing is done one data. It is added raw. See add() for a + No processing is done on data. It is added raw. See add() for a similar method with processing. """ first = self.get_first_letter(key) @@ -142,13 +142,16 @@ class Index(object): if self.indextype == "TITLE": # Removing prefixes before titles for pattern in self.prefix_patterns: - match = pattern.match(key) + match = pattern.match(key.encode('utf-8')) if match: self._raw_add( "{} ({})".format( match.group(2) + match.group(3), - match.group(1)), - number, link) + match.group(1) + ), + number, + link + ) return self._raw_add(key, number, link) @@ -162,13 +165,15 @@ class Index(object): @staticmethod def ref_to_str(ref): """Return the LaTeX code corresponding to the reference.""" - return r'\hyperlink{{{0[link]}}}{{{0[num]}}}'.format(ref) + return r'\hyperlink{{{0[link]}}}{{{0[num]}}}'.format(ref) def entry_to_str(self, key, entry): """Return the LaTeX code corresponding to the entry.""" - return unicode(r'\idxentry{{{0}}}{{{1}}}' + EOL).format( + if not isinstance(key, unicode): + key = unicode(key, "UTF-8") + return unicode(ur'\idxentry{{{0}}}{{{1}}}' + EOL).format( key, - r'\\'.join([self.ref_to_str(ref) for ref in entry]), + ur'\\'.join([self.ref_to_str(ref) for ref in entry]), ) def idxblock_to_str(self, letter, entries): diff --git a/songbook_core/plastex.py b/songbook_core/plastex.py index 3f3cefc9..84b29b96 100644 --- a/songbook_core/plastex.py +++ b/songbook_core/plastex.py @@ -38,7 +38,9 @@ def simpleparse(text): """Parse a simple LaTeX string. """ tex = TeX() - tex.input(text.decode('utf8')) + if not isinstance(text, unicode): + text = text.decode("utf-8") + tex.input(text) doc = tex.parse() return process_unbr_spaces(doc.textContent) From 8b0313692aae13a841278250b50276427b85b681 Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 16 Apr 2014 21:16:14 +0200 Subject: [PATCH 02/17] =?UTF-8?q?Ajout=20des=20d=C3=A9pendances=20au=20paq?= =?UTF-8?q?uet=20Deb=20#26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdeb.cfg | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 stdeb.cfg diff --git a/stdeb.cfg b/stdeb.cfg new file mode 100644 index 00000000..c680156b --- /dev/null +++ b/stdeb.cfg @@ -0,0 +1,4 @@ +[DEFAULT] +Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode +XS-Python-Version: >=2.7 + From 4b1b70d2f16083f82d44d702403cb532554c4dfe Mon Sep 17 00:00:00 2001 From: Louis Date: Sun, 27 Apr 2014 19:25:44 +0200 Subject: [PATCH 03/17] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20xstring.sty?= =?UTF-8?q?=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/data/latex/xstring.sty | 881 +++++++++++++++++---------- 1 file changed, 552 insertions(+), 329 deletions(-) diff --git a/songbook_core/data/latex/xstring.sty b/songbook_core/data/latex/xstring.sty index 80f46620..9949d02b 100644 --- a/songbook_core/data/latex/xstring.sty +++ b/songbook_core/data/latex/xstring.sty @@ -1,9 +1,9 @@ % __________________________________________________ % | | % | | -% | xstring v1.5d | +% | xstring v1.7c | % | | -% | March 28 2010 | +% | 13 octobre 2013 | % | | % |__________________________________________________| % @@ -17,7 +17,7 @@ % xstring_doc_fr.tex, xstring_doc_fr.pdf (manual in french) % xstring_doc_en.tex, xstring_doc_en.pdf (manual in english) % -% Christian Tellechea 2008-2010 +% Christian Tellechea 2008-2013 % email : unbonpetit@gmail.com % ------------------------------------------------------------------- % This work may be distributed and/or modified under the @@ -34,19 +34,19 @@ % % The Current Maintainer of this work is Christian Tellechea % ------------------------------------------------------------------- +\def\xstringversion {1.7c} +\def\xstringdate {2013/10/13} +\def\xstringfrenchdate {13 octobre 2013} +\def\xstringenglishdate {13 october 2013} \ProvidesPackage{xstring}[\xstringdate\space\space v\xstringversion\space\space String manipulations (C Tellechea)] -\def\xstringversion {1.5d} -\def\xstringdate {2010/03/28} -\def\xstringfrenchdate {28 mars 2010} -\def\xstringenglishdate {March $28^{\mathrm{th}}$ 2010} \edef\CurrentAtCatcode {\the\catcode`\@} \catcode`\@=11 \newwrite\@xs@message% canal pour les messages -\newcount\integerpart\newcount\decimalpart% compteurs utilis\'es par xstring -\newif\if@xs@empty +\newcount\integerpart +\newcount\decimalpart% compteurs utilis\'es par xstring \expandafter\ifx\csname @latexerr\endcsname\relax% on n'utilise pas LaTeX ? - \immediate\write\m@ne{Package: xstring \xstringdate\space\space v\xstringversion\space\space String manipulations (C Tellechea)}% + \immediate\write\m@ne{Package: xstring \xstringdate\space\space v\xstringversion\space\space String manipulations}% \long\def\@firstoftwo#1#2{#1} \long\def\@secondoftwo#1#2{#2} \long\def\@gobble#1{} @@ -73,9 +73,13 @@ \def\@empty{} \fi% fin des d\'efinitions LaTeX -\def\@xs@testempty#1{% - \expandafter\ifx\expandafter\@empty\detokenize{#1}\@empty\@xs@emptytrue\else\@xs@emptyfalse\fi} - +\long\def\@xs@ifempty#1{% + \expandafter\ifx\expandafter\relax\detokenize{#1}\relax + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} % Ouvre un groupe o\`u les catcodes sont \`a 12 et \`a 10 pour les espaces % ensuite, appelle \@xs@ReadVerb qui lit un argument entre d\'elimiteurs verb \def\@xs@MakeVerb{% lit 1 argument et le transforme en verb @@ -83,78 +87,87 @@ \def\do##1{\catcode`##112\relax}% \dospecials% on entre dans le mode verb \obeyspaces% et on tient compte des espaces - \@xs@ReadVerb}% et on va lire l'argument + \@xs@ReadVerb% et on va lire l'argument +} % D\'efinit \@xs@ReadVerb qui lit un argument entre d\'elimiteurs verb \def\setverbdelim#1{% d\'efinit quel est le d\'elimiteur de verb - \expandafter\@xs@testempty\expandafter{\@gobble#1}% - \if@xs@empty - \else - \begingroup + \expandafter\@xs@ifempty\expandafter{\@gobble#1}% + \relax + {\begingroup \newlinechar`\^^J% \immediate\write\@xs@message {Package xstring Warning: verb delimiter is not a single token on input line \the\inputlineno^^J}% \endgroup - \fi + }% \def\@xs@ReadVerb##1#1##2#1{% lit ##2 qui est entre les d\'elimiteurs de verb \endgroup% on ferme le groupe - \@xs@afterreadverb{##2}}}% on appelle l'ex\'ecution de fin + \@xs@afterreadverb{##2}}% on appelle l'ex\'ecution de fin +} % Assigne l'argument entre d\'elimiteur verb dans la sc #1' + \def\verbtocs#1{% \def\@xs@afterreadverb##1{\def#1{##1}}% - \@xs@MakeVerb} + \@xs@MakeVerb +} + +\begingroup + \catcode\z@3 \def\@xs@twochars{^^00}% + \catcode\z@7 \xdef\@xs@twochars{\@xs@twochars^^00}% +\endgroup + +\edef\@xs@reserved@A{\long\def\noexpand\@xs@AssignResult##1\@xs@twochars} -% Cette macro d\'eveloppe \'eventuellement #2 -% puis le transforme en token et l'assigne \`a #1 -\begingroup% on ouvre un groupe o\`u... -\catcode\z@12\relax% ...le caract\`ere 0 a 12 pour catcode -\gdef\tokenize#1#2{% +\@xs@reserved@A#2{\endgroup\expandafter\def\expandafter#2\expandafter{\@gobble#1}} + +\def\tokenize#1#2{% \begingroup \@xs@def\@xs@reserved@A{#2}% on d\'eveloppe en accord avec \fullexpandarg ou \noexpandarg - \def\@xs@AssignResult^^00##1^^00\@xs@nil{\gdef#1{##1}}% on assigne en tenant compte du \@xs@nil qui vient de la fin du fichier virtuel - \everyeof{\@xs@nil}% met un \@xs@nil \`a la fin du fichier virtuel + \everyeof\expandafter{\@xs@twochars#1}% met "^^@^^@#1" \`a la fin du fichier virtuel \endlinechar\m@ne - \catcode\z@12\relax - \expandafter\@xs@AssignResult\scantokens\expandafter{\expandafter^^00\@xs@reserved@A^^00}% on fait l'assignation - \endgroup}% -\endgroup + \expandafter\@xs@AssignResult\scantokens\expandafter{\expandafter\relax\@xs@reserved@A}% on fait l'assignation +}% % Macro tr\`es simple qui assigne ou affiche le r\'esultat, selon la pr\'esence % ou non de #2 qui est l'argument optionnel venant en derni\`ere position des macros -\def\@xs@ReturnResult#1#2{% +\long\def\@xs@ReturnResult#1#2{% \def\@xs@argument@A{#1}% - \@xs@testempty{#2}% - \if@xs@empty + \@xs@ifempty{#2}% \@xs@argument@A - \else - \let#2\@xs@argument@A - \fi} + {\let#2\@xs@argument@A}% +} + +\def\@xs@ldef{\long\def} + +\def\@xs@ledef{\long\edef} % Pas d'expansion des arguments \def\normalexpandarg{% - \let\@xs@def\def% on d\'efinit \@xs@call avec \def + \let\@xs@def\@xs@ldef% on d\'efinit \@xs@call avec \def \def\@xs@expand##1{\unexpanded\expandafter{##1}}} \let\noexpandarg\normalexpandarg% synonyme % 1-d\'eveloppement du premier token des arguments \def\expandarg{% - \let\@xs@def\def% on d\'efinit \@xs@call avec \def - \def\@xs@expand##1{\unexpanded\expandafter\expandafter\expandafter{##1}}} + \let\@xs@def\@xs@ldef% on d\'efinit \@xs@call avec \def + \def\@xs@expand##1{\unexpanded\expandafter\expandafter\expandafter{##1}}% +} % D\'eveloppement maximum des arguments \def\fullexpandarg{% - \let\@xs@def\edef% on d\'efinit\@xs@call avec \edef - \def\@xs@expand##1{##1}}% et on neutralise \@xs@expand + \let\@xs@def\@xs@ledef% on d\'efinit\@xs@call avec \edef + \def\@xs@expand##1{##1}% et on neutralise \@xs@expand +} \def\saveexpandmode{\let\@xs@saved@def\@xs@defarg\let\@xs@saved@expand\@xs@expand} + \def\restoreexpandmode{\let\@xs@defarg\@xs@saved@def\let\@xs@expand\@xs@saved@expand} % Macro interne renvoyant #2 si son argument commence par une accolade ouvrante "{" % et #3 sinon (Ulrich Diez sur comp.text.tex) -\def\@xs@ifbeginwithbrace#1{% +\long\def\@xs@ifbeginwithbrace#1{% \csname @% - \expandafter\@gobble\string{% ne sert à rien si ce n'est \'equilibrer les accolades dans la d\'efinition + \expandafter\@gobble\string{% \expandafter\@gobble\expandafter{\expandafter{\string#1}% \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\@firstoftwo \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\@gobble @@ -162,12 +175,13 @@ \expandafter\expandafter\expandafter{\expandafter\string\expandafter}\string}% \expandafter\@gobble\string}% \@secondoftwo{first}{second}oftwo% - \endcsname} + \endcsname +} % Cette macro interne prend la 1ere unit\'e syntaxique de #1 et assigne le r\'esultat \`a #2 -\def\@xs@returnfirstsyntaxunit#1#2{% +\long\def\@xs@returnfirstsyntaxunit#1#2{% \def\@xs@groupfound{\expandafter\def\expandafter#2\expandafter{\expandafter{#2}}\@xs@gobbleall}% on met #2 dans des accolades et on finit - \def\@xs@assignfirsttok##1##2\@xs@nil{\let\@xs@toks0\def#2{##1}}% + \long\def\@xs@assignfirsttok##1##2\@xs@nil{\let\@xs@toks0\def#2{##1}}% \def\@xs@testfirsttok{% \let\@xs@next\@xs@assignfirsttok \ifx\@xs@toks\bgroup @@ -176,65 +190,76 @@ \@xs@next}% \def\@xs@argument{#1}% \edef\@xs@next{\expandafter\@xs@beforespace\detokenize{#1} \@xs@nil}% #1 commence par un espace ? - %\expandafter\expandafter\expandafter\@xs@testempty\expandafter\expandafter\expandafter{\expandafter\@xs@beforespace\detokenize{#1} \@xs@nil} \ifx\@xs@next\@empty \def\@xs@next{\expandafter\ifx\expandafter\@empty\detokenize\expandafter{\@xs@argument}\@empty\let#2\@empty\else\def#2{ }\let\@xs@toks0\fi}% \else \def\@xs@next{\expandafter\futurelet\expandafter\@xs@toks\expandafter\@xs@testfirsttok\@xs@argument\@xs@nil}% \fi - \@xs@next} + \@xs@next +} % Cette macro interne enl\`eve la 1ere unit\'e syntaxique de #1 et assigne le r\'esultat \`a #2 -\def\@xs@testsecondtoken#1\@xs@nil{\@xs@ifbeginwithbrace{#1}} -\def\@xs@gobblespacebeforebrace#1#{}% supprime tout ce qui est avant la 1ere accolade ouvrante -\def\@xs@removefirstsyntaxunit#1#2{% +\long\def\@xs@testsecondtoken#1\@xs@nil{\@xs@ifbeginwithbrace{#1}} + +\long\def\@xs@gobblespacebeforebrace#1#{}% supprime tout ce qui est avant la 1ere accolade ouvrante + +\long\def\@xs@removefirstsyntaxunit#1#2{% \def\@xs@argument{#1}% \expandafter\expandafter\expandafter\ifx\expandafter\expandafter\expandafter\@empty\expandafter\@xs@beforespace\detokenize\expandafter{\@xs@argument} \@xs@nil\@empty% #1 commence par un espace ? - \expandafter\@xs@testempty\expandafter{\@xs@argument}% - \if@xs@empty - \let#2\@empty - \else - \afterassignment\@xs@testsecondtoken% après avoir mangé le 1er token, on va tester si la suite commence par «{» + \expandafter\@xs@ifempty\expandafter{\@xs@argument}% + {\let#2\@empty} + {\afterassignment\@xs@testsecondtoken% après avoir mangé le 1er token, on va tester si la suite commence par «{» \expandafter\let\expandafter\@xs@secontoken\expandafter=\expandafter\@sptoken\@xs@argument\@xs@@nil\@xs@nil% on mange le 1er token et on rajoute \@xs@@nil à la fin pour éviter de perdre les accolades du groupe {\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{\expandafter\@xs@gobblespacebeforebrace\@xs@argument}}% {\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{\expandafter\@xs@behindspace\@xs@argument\@xs@nil}}% - \fi + }% \else \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2% \expandafter\expandafter\expandafter{\expandafter\@gobble\@xs@argument}% - \fi} + \fi +} % Macros \`a arguments d\'elimit\'es pour les macros ci dessus -\def\@xs@beforespace#1 #2\@xs@nil{#1} -\def\@xs@behindspace#1 #2\@xs@nil{#2} -\def\@xs@returnfirstsyntaxunit@ii#1#2\@xs@nil{#1} -\def\@xs@gobbleall#1\@xs@nil{} +\long\def\@xs@beforespace#1 #2\@xs@nil{#1} + +\long\def\@xs@behindspace#1 #2\@xs@nil{#2} + +\long\def\@xs@returnfirstsyntaxunit@ii#1#2\@xs@nil{#1} + +\long\def\@xs@gobbleall#1\@xs@nil{} % Cette macro interne est utilis\'ee dans les macros \'etoil\'ees pour : % 1) d\'evelopper l'argument selon qu'on a choisit \fullexpandarg % ou \normalexpandarg, et ceci \`a l'aide de la macro \@xs@def % 2) Ensuite, on d\'etokenize ce d\'eveloppement de façon n'avoir plus que % des catcodes de 10 pour les espaces et 12 pour le reste. -\def\@xs@expand@and@detokenize#1#2{% - \def#1{#2}% +\long\def\@xs@expand@and@detokenize#1#2{% + \long\def#1{#2}% \expandafter\edef\expandafter#1\expandafter{\@xs@expand#1}% on d\'eveloppe #2 selon le mode de d\'eveloppement - \edef#1{\detokenize\expandafter{#1}}}% puis on d\'etokenize et on assigne \`a #1 + \long\edef#1{\detokenize\expandafter{#1}}% puis on d\'etokenize et on assigne \`a #1 +} + +\long\def\@xs@expand@and@assign#1#2{\@xs@def#1{#2}}% on d\'eveloppe #2 selon \fullexpandarg ou \normalexpandarg -\def\@xs@expand@and@assign#1#2{\@xs@def#1{#2}}% on d\'eveloppe #2 selon \fullexpandarg ou \normalexpandarg +\long\def\@xs@edefaddtomacro#1#2{\edef#1{\unexpanded\expandafter{#1}#2}} -\def\@xs@edefaddtomacro#1#2{\edef#1{\unexpanded\expandafter{#1}#2}} -\def\@xs@addtomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} +\long\def\@xs@addtomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} \def\@xs@argstring{0########1########2########3########4########5########6########7########8########9} + % \@xs@DefArg{3} met dans la sc \@xs@myarg les tokens "####1####2####3" \def\@xs@DefArg#1{\def\@xs@defarg0##1#1##2\@xs@nil{\def\@xs@myarg{##1#1}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil} + % \@xs@DefArg@{3} met dans la sc \@xs@myarg les tokens "[####1]####2####3####4" \def\@xs@DefArg@#1{\expandafter\@xs@defarg@\expandafter{\number\numexpr#1+1}} + \def\@xs@defarg@#1{\def\@xs@defarg0##11##2#1##3\@xs@nil{\def\@xs@myarg{[##11]##2#1}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil} + % \@xs@OneArg{3} met dans la sc \@xs@myarg les tokens "####3" \def\@xs@OneArg#1{\expandafter\@xs@onearg\expandafter{\number\numexpr#1-1}{#1}} + \def\@xs@onearg#1#2{\def\@xs@defarg##1#1##2#2##3\@xs@nil{\def\@xs@myarg{##2#2}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil} % #1 : num\'ero du 1er argument; #2 : nombre de lignes; #3 argument optionnel; #4 : dernier num\'ero de l'argument devant être d\'etokenis\'e si \'etoile @@ -245,14 +270,13 @@ \expandafter\@xs@OneArg\expandafter{\number\numexpr##1+#1-1}% \edef\@xs@reserved@B{\noexpand\@xs@expand\csname @xs@arg@\romannumeral\numexpr##1\endcsname}% \ifnum##1=\@ne% si c'est le premier argument - \@xs@testempty{#3}% - \if@xs@empty - \expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}% + \@xs@ifempty{#3}% + {\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}% \edef\@xs@reserved@B{\ifnum##1>#4 @xs@def\else @xs@assign\fi}% - \else% et s'il y a un argument optionnel alors, on met des crochets - \expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter[\@xs@reserved@B]}% + }% et s'il y a un argument optionnel alors, on met des crochets + {\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter[\@xs@reserved@B]}% \def\@xs@reserved@B{@xs@def}% ne pas d\'etok\'eniser l'argument optionnel grace au \@xs@def - \fi + } \else \expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}% \edef\@xs@reserved@B{\ifnum##1>#4 @xs@def\else @xs@assign\fi}% @@ -262,9 +286,15 @@ \def\@xs@next{\expandafter\@xs@buildlines\expandafter{\number\numexpr##1+1}}% \expandafter\@xs@next \fi}% - \@xs@buildlines\@ne} + \@xs@buildlines\@ne +} + +\def\@xs@newmacro{% + \@ifstar + {\let\@xs@reserved@D\@empty\@xs@newmacro@} + {\let\@xs@reserved@D\relax\@xs@newmacro@0}% +} -\def\@xs@newmacro{\@ifstar{\let\@xs@reserved@D\@empty\@xs@newmacro@}{\let\@xs@reserved@D\relax\@xs@newmacro@0}} % #1 : dernier num\'ero de l'argument devant être d\'etokenis\'e % #2 : nom de la macro publique % #3 : argument optionnel (vide si pas d'arg optionnel) @@ -278,20 +308,22 @@ \ifx\@empty\@xs@reserved@D \def\noexpand#2{\noexpand\@ifstar {\let\noexpand\@xs@assign\noexpand\@xs@expand@and@detokenize\expandafter\noexpand\@xs@reserved@C}% - {\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}}% + {\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}% + }% \else \def\noexpand#2{\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}% \fi \ifx\@empty#3\@empty \else \def\expandafter\noexpand\@xs@reserved@C{% - \noexpand\@testopt{\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname}{\ifx\@xs@def\edef#3\else\unexpanded{#3}\fi}}% - \fi}% + \noexpand\@testopt{\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname}{\ifx\@xs@def\@xs@ledef#3\else\unexpanded{#3}\fi}}% + \fi + }% % Que fait \@xs@reserved@B ? Il d\'efinit : % si #3 est vide : \NOM{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@NOM@@}{\let\@xs@assign\@xs@expand@and@assign\@xs@NOM@@}} % si #3 existe : \NOM{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@NOM@}{\let\@xs@assign\@xs@expand@and@assign\@xs@NOM@}} % \@xs@NOM@{\@testopt{\@xs@NOM@@}{#3}}} - \@xs@reserved@B + \long\@xs@reserved@B \ifx\@empty#3\@empty \@xs@BuildLines1{#4}{#3}{#1}% \@xs@DefArg{#4}% @@ -301,7 +333,9 @@ \fi \edef\@xs@reserved@B{\def\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname\@xs@myarg}% \edef\@xs@reserved@C{\unexpanded\expandafter{\@xs@newlines}\edef\noexpand\@xs@call}% - \edef\@xs@reserved@D{\noexpand\noexpand\expandafter\noexpand\csname\@xs@reserved@A\endcsname\unexpanded\expandafter{\@xs@newargs}}% + \edef\@xs@reserved@D{% + \noexpand\noexpand\expandafter\noexpand\csname\@xs@reserved@A\endcsname\unexpanded\expandafter{\@xs@newargs}% + }% \ifnum#5=\@ne\edef\@xs@reserved@D{\noexpand\noexpand\noexpand\@testopt{\unexpanded\expandafter{\@xs@reserved@D}}{}}\fi \@xs@edefaddtomacro\@xs@reserved@C{{\unexpanded\expandafter{\@xs@reserved@D}}\noexpand\@xs@call}% \@xs@edefaddtomacro\@xs@reserved@B{{\unexpanded\expandafter{\@xs@reserved@C}}}% @@ -311,11 +345,15 @@ % si #5=0: \edef\@xs@call{\noexpand\@xs@NOM[\@xs@expand\@xs@arg@i]{\@xs@expand\@xs@arg@ii}{\@xs@expand\@xs@arg@iii}{\@xs@expand\@xs@arg@iv}}% % si #5=1: \edef\@xs@call{\noexpand\@testopt{\noexpand\@xs@NOM[\@xs@expand\@xs@arg@i]{\@xs@expand\@xs@arg@i}{\@xs@expand\@xs@arg@ii}{\@xs@expand\@xs@arg@iii}{\@xs@expand\@xs@arg@iv}}{}}% % \@xs@call} - \@xs@reserved@B - \edef\@xs@reserved@B{\def\expandafter\noexpand\csname\@xs@reserved@A\endcsname\@xs@myarg\ifnum#5=\@ne[\unexpanded{##}\number\numexpr\ifx\@empty#3\@empty#4+1\else#4+2\fi]\fi}% + \long\@xs@reserved@B + \edef\@xs@reserved@B{% + \def\expandafter\noexpand\csname\@xs@reserved@A\endcsname + \@xs@myarg\ifnum#5=\@ne[\unexpanded{##}\number\numexpr\ifx\@empty#3\@empty#4+1\else#4+2\fi]\fi + }% % Que fait \@xs@reserved@B ? Il d\'efinit par exemple pour 3 arguments obligatoires et 1 facultatif : % \def \@xs@NOM[##2]##3##4##5[##6]{#6} - \@xs@reserved@B} + \long\@xs@reserved@B +} % macro g\'en\'erique qui lit \@xs@reserved@C us par us % 3 sous-routines sont appel\'ees \`a des moments cl\'e : @@ -323,15 +361,14 @@ % \@xs@atbegingroup (un groupe vient d'être ouvert) % \@xs@atnextsyntaxunit (la future US n'est pas un groupe) \def\@xs@read@reserved@C{% - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \ifnum\@xs@nestlevel=\z@ + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\ifnum\@xs@nestlevel=\z@ \let\@xs@next\relax \else \let\@xs@next\@xs@atendofgroup \fi - \else - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A + } + {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C \let\@xs@next\@xs@read@reserved@C \@xs@exploregroups @@ -347,63 +384,67 @@ \global\advance\decimalpart\@ne \@xs@atnextsyntaxunit \fi - \fi - \@xs@next} + }% + \@xs@next +} % macro g\'en\'erique qui lit \@xs@reserved@D en proc\'edant \`a des tests avec \IfBeginWith % 2 sous-routines sont appel\'ees \`a des moments cl\'e : % \@xs@atendofgroup (un groupe se finit, appel r\'ecursif) % \@xs@atoccurfound (une occurrence a \'et\'e trouv\'ee) \def\@xs@read@reserved@D{% - \expandafter\@xs@testempty\expandafter{\@xs@reserved@D}% - \if@xs@empty - \ifnum\@xs@nestlevel=\z@ + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}% + {\ifnum\@xs@nestlevel=\z@ \let\@xs@next\relax \else \let\@xs@next\@xs@atendofgroup \fi - \else - \expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@D\expandafter}\expandafter{\@xs@reserved@E}% - {\global\advance\decimalpart\@ne - \let\@xs@reserved@D\@xs@reserved@A - \@xs@atoccurfound}% - {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@A - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@D - \let\@xs@next\@xs@read@reserved@D - \@xs@exploregroups - \ifx\bgroup\@xs@toks - \advance\integerpart\@ne - \begingroup - \expandafter\def\expandafter\@xs@reserved@D\@xs@reserved@A - \@xs@manage@groupID - \let\@xs@reserved@C\@empty - \let\@xs@nestlevel\@ne - \integerpart\z@ - \else - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}% - \fi}% - \fi - \@xs@next} + }% + {\expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter + {\expandafter\@xs@reserved@D\expandafter}\expandafter{\@xs@reserved@E}% + {\global\advance\decimalpart\@ne + \let\@xs@reserved@D\@xs@reserved@A + \@xs@atoccurfound + }% + {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@A + \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@D + \let\@xs@next\@xs@read@reserved@D + \@xs@exploregroups + \ifx\bgroup\@xs@toks + \advance\integerpart\@ne + \begingroup + \expandafter\def\expandafter\@xs@reserved@D\@xs@reserved@A + \@xs@manage@groupID + \let\@xs@reserved@C\@empty + \let\@xs@nestlevel\@ne + \integerpart\z@ + \else + \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}% + \fi + }% + }% + \@xs@next +} \@xs@newmacro\StrRemoveBraces{}{1}{1}{% \def\@xs@reserved@C{#1}% \let\@xs@reserved@B\@empty \let\@xs@nestlevel\z@ \@xs@StrRemoveBraces@i - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#2}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#2}% +} \def\@xs@StrRemoveBraces@i{% - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \ifnum\@xs@nestlevel=\z@ + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\ifnum\@xs@nestlevel=\z@ \let\@xs@next\relax \else \expandafter\endgroup \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@B}% \let\@xs@next\@xs@StrRemoveBraces@i \fi - \else - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A + } + {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C \let\@xs@next\@xs@StrRemoveBraces@i \ifx\bgroup\@xs@toks @@ -419,26 +460,38 @@ \else \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@A}% \fi - \fi - \@xs@next} + }% + \@xs@next +} % \@xs@cutafteroccur coupe l'argument #1 apr\`es la #3\`eme occurrence de #2 % \@xs@reserved@C : contient ce qui se trouve avant cette occurrence % \@xs@reserved@D : contient ce qui se trouve avant cette occurrence y compris cette occurrence % \@xs@reserved@E : contient ce qui se trouve apr\`es l'occurrence % si l'occurrence n'existe pas ou qu'un des arguments est vide, toutes les chaines renvoy\'ees sont vides -\def\@xs@cutafteroccur#1#2#3{% +\long\def\@xs@cutafteroccur#1#2#3{% + \ifnum#3<\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + {\let\@xs@reserved@C\@empty + \let\@xs@reserved@E\@empty + \global\let\groupID\@empty + } + {\@xs@cutafteroccur@i{#1}{#2}{#3}}% +} + +\long\def\@xs@cutafteroccur@i#1#2#3{% \def\@xs@reserved@D{#1}\let\@xs@reserved@C\@empty\def\@xs@reserved@E{#2}% - \decimalpart\z@\integerpart\z@\def\groupID{0}\let\@xs@nestlevel\z@ + \decimalpart\z@ + \integerpart\z@ + \gdef\groupID{0}% + \let\@xs@nestlevel\z@ \def\@xs@atendofgroup{% \expandafter\endgroup \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% \@xs@read@reserved@D}% \def\@xs@atoccurfound{% - \ifnum\decimalpart=#3 + \ifnum\decimalpart=\numexpr(#3)\relax \global\let\@xs@reserved@D\@xs@reserved@D \global\let\@xs@reserved@C\@xs@reserved@C - \global\let\groupID\groupID \@xs@exitallgroups \let\@xs@next\relax \else @@ -447,83 +500,83 @@ \fi}% \@xs@read@reserved@D \def\@xs@argument@A{#2}% - \ifnum\decimalpart=#3% occurrence trouv\'ee ? + \ifnum\decimalpart=\numexpr(#3)\relax % occurrence trouv\'ee ? \let\@xs@reserved@E\@xs@reserved@D \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\@xs@reserved@D\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\@xs@argument@A}% \else - \let\@xs@reserved@C\@empty\let\@xs@reserved@E\@empty\let\groupID\@empty - \fi} + \let\@xs@reserved@C\@empty + \let\@xs@reserved@E\@empty + \global\let\groupID\@empty + \fi +} \@xs@newmacro*3\IfSubStr{1}{2}{0}{% \def\@xs@argument@A{#2}\def\@xs@argument@B{#3}% \expandafter\expandafter\expandafter\@xs@cutafteroccur \expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter{\@xs@argument@B}{#1}% - \expandafter\@xs@testempty\expandafter{\@xs@reserved@D}% - \if@xs@empty - \expandafter\@secondoftwo - \else - \expandafter\@firstoftwo - \fi} + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}% + \@secondoftwo + \@firstoftwo +} \@xs@newmacro*2\IfBeginWith{}{2}{0}{% \def\@xs@argument@A{#1}\def\@xs@argument@B{#2}% - \expandafter\@xs@testempty\expandafter{\@xs@argument@B}% - \if@xs@empty - \let\@xs@next\@secondoftwo - \else - \def\@xs@next{\expandafter\expandafter\expandafter\@xs@IfBeginWith@i - \expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter{\@xs@argument@B}}% - \fi - \@xs@next} - -\def\@xs@IfBeginWith@i#1#2{% + \expandafter\@xs@ifempty\expandafter{\@xs@argument@B}% + {\let\@xs@next\@secondoftwo + } + {\def\@xs@next{% + \expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter + {\expandafter\@xs@argument@A\expandafter}\expandafter + {\@xs@argument@B}}% + }% + \@xs@next +} + +\long\def\@xs@IfBeginWith@i#1#2{% \def\@xs@argument@A{#1}\def\@xs@argument@B{#2}% - \expandafter\@xs@testempty\expandafter{\@xs@argument@B}% - \if@xs@empty% #2 est vide, tous les tests sont pass\'es avec succ\`es : on renvoie #3 - \let\@xs@next\@firstoftwo - \else - \expandafter\@xs@testempty\expandafter{\@xs@argument@A}%\@xs@testempty{#1}% - \if@xs@empty - \let\@xs@next\@secondoftwo% #1 est vide, c'est que #2 est + long que #1 : on renvoie #4 - \else - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B + \expandafter\@xs@ifempty\expandafter{\@xs@argument@B}% + {\let\@xs@next\@firstoftwo% #2 est vide, tous les tests sont pass\'es avec succ\`es : on renvoie #3 + } + {\expandafter\@xs@ifempty\expandafter{\@xs@argument@A}% + {\let\@xs@next\@secondoftwo% #1 est vide, c'est que #2 est + long que #1 : on renvoie #4 + } + {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A \ifx\@xs@reserved@A\@xs@reserved@B% il y a \'egalit\'e... \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A% on enl\`eve les 1ere unit\'es syntaxiques + \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A% on enl\`eve les 1ere unit\'es syntaxiques \def\@xs@next{% et on recommence avec ces arguments racourcis d'1 unit\'e syntaxique \expandafter\expandafter\expandafter\@xs@IfBeginWith@i \expandafter\expandafter\expandafter{\expandafter\@xs@reserved@A\expandafter}\expandafter{\@xs@reserved@B}}% \else \let\@xs@next\@secondoftwo \fi - \fi - \fi - \@xs@next} + }% + }% + \@xs@next +} \@xs@newmacro*2\IfEndWith{}{2}{0}{% \def\@xs@argument@A{#1}\def\@xs@argument@B{#2}% - \@xs@testempty{#2}% - \if@xs@empty - \let\@xs@reserved@A\@secondoftwo - \else - \expandafter\expandafter\expandafter\@xs@StrCount + \@xs@ifempty{#2}% + {\let\@xs@reserved@A\@secondoftwo + } + {\expandafter\expandafter\expandafter\@xs@StrCount \expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter {\@xs@argument@B}[\@xs@reserved@A]% \ifnum\@xs@reserved@A=\z@ \let\@xs@reserved@A\@secondoftwo \else - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \let\@xs@reserved@A\@firstoftwo - \else - \let\@xs@reserved@A\@secondoftwo - \fi + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\let\@xs@reserved@A\@firstoftwo} + {\let\@xs@reserved@A\@secondoftwo}% \fi - \fi - \@xs@reserved@A} + }% + \@xs@reserved@A +} \@xs@newmacro*4\IfSubStrBefore{1,1}{3}{0}{\@xs@IfSubStrBefore@i[#1]{#2}{#3}{#4}} + \def\@xs@IfSubStrBefore@i[#1,#2]#3#4#5{% \def\@xs@reserved@C{#3}% \ifx\@xs@exploregroups\relax% si on explore les groupes @@ -536,48 +589,41 @@ \expandafter\expandafter\expandafter\@xs@cutafteroccur\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@A}{#2}% \def\@xs@reserved@A{#4}% \expandafter\expandafter\expandafter\@xs@cutafteroccur\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@A}{#1}% - \let\groupID\@empty - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \expandafter\@secondoftwo - \else - \expandafter\@firstoftwo - \fi} + \global\let\groupID\@empty + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + \@secondoftwo + \@firstoftwo +} \@xs@newmacro*4\IfSubStrBehind{1,1}{3}{0}{\@xs@IfSubStrBehind@i[#1]{#2}{#3}{#4}} -\def\@xs@IfSubStrBehind@i[#1,#2]#3#4#5{\@xs@IfSubStrBefore@i[#2,#1]{#3}{#5}{#4}} -\def\@xs@formatnumber#1#2{% +\long\def\@xs@IfSubStrBehind@i[#1,#2]#3#4#5{\@xs@IfSubStrBefore@i[#2,#1]{#3}{#5}{#4}} + +\long\def\@xs@formatnumber#1#2{% \def\@xs@argument@A{#1}% - \@xs@testempty{#1}% - \if@xs@empty - \def#2{0X}% si vide, renvoie 0X - \else - \@xs@returnfirstsyntaxunit{#1}\@xs@reserved@A + \@xs@ifempty{#1}% + {\def#2{0X}% si vide, renvoie 0X + } + {\@xs@returnfirstsyntaxunit{#1}\@xs@reserved@A \def\@xs@reserved@B{+}% \ifx\@xs@reserved@A\@xs@reserved@B \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@C - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \def#2{+0X}% - \else - \expandafter\def\expandafter#2\expandafter{\expandafter+\expandafter0\@xs@reserved@C}% - \fi + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\def#2{+0X}} + {\expandafter\def\expandafter#2\expandafter{\expandafter+\expandafter0\@xs@reserved@C}}% \else \def\@xs@reserved@B{-}% \ifx\@xs@reserved@A\@xs@reserved@B \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A - \expandafter\@xs@testempty\expandafter{\@xs@reserved@A}% - \if@xs@empty - \def#2{-0X}% - \else - \expandafter\def\expandafter#2\expandafter{\expandafter-\expandafter0\@xs@reserved@A}% - \fi + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@A}% + {\def#2{-0X}}% + {\expandafter\def\expandafter#2\expandafter{\expandafter-\expandafter0\@xs@reserved@A}}% \else \expandafter\def\expandafter#2\expandafter{\expandafter0\@xs@argument@A}% \fi \fi - \fi} + }% +} \@xs@newmacro\IfInteger{}{1}{0}{% \@xs@formatnumber{#1}\@xs@reserved@A @@ -596,10 +642,11 @@ \let\@xs@afterinteger\@xs@after@intpart \let\@xs@next\@secondoftwo \fi - \@xs@next} + \@xs@next +} \@xs@newmacro\IfDecimal{}{1}{0}{% - \expandafter\@xs@formatnumber\expandafter{\detokenize{#1}}\@xs@reserved@A + \@xs@formatnumber{#1}\@xs@reserved@A \decimalpart\z@ \afterassignment\@xs@defafterinteger\integerpart\@xs@reserved@A\relax\@xs@nil \expandafter\@xs@testdot\@xs@afterinteger\@xs@nil @@ -607,76 +654,117 @@ \expandafter\@firstoftwo \else \expandafter\@secondoftwo - \fi} - -\def\@xs@defafterinteger#1\relax\@xs@nil{\def\@xs@afterinteger{#1}} -\def\@xs@testdot{\let\xs@decsep\@empty\@ifnextchar.{\def\xs@decsep{.}\@xs@readdecimalpart}{\@xs@testcomma}} -\def\@xs@testcomma{\@ifnextchar,{\def\xs@dessep{,}\@xs@readdecimalpart}{\@xs@endnumber}} -\def\@xs@readdecimalpart#1#2\@xs@nil{% - \ifx\@empty#2\@empty\def\@xs@reserved@A{0X}\else\def\@xs@reserved@A{0#2}\fi + \fi +} + +\long\def\@xs@defafterinteger#1\relax\@xs@nil{\def\@xs@afterinteger{#1}} + +\def\@xs@testdot{% + \let\xs@decsep\@empty + \@ifnextchar.% + {\def\xs@decsep{.}\@xs@readdecimalpart}% + {\@xs@testcomma}% +} + +\def\@xs@testcomma{% + \@ifnextchar,% + {\def\xs@dessep{,}\@xs@readdecimalpart}% + {\@xs@endnumber}% +} + +\long\def\@xs@readdecimalpart#1#2\@xs@nil{% + \ifx\@empty#2\@empty + \def\@xs@reserved@A{0X}% + \else + \def\@xs@reserved@A{0#2}% + \fi \afterassignment\@xs@defafterinteger\decimalpart\@xs@reserved@A\relax\@xs@nil - \expandafter\@xs@endnumber\@xs@afterinteger\@xs@nil} -\def\@xs@endnumber#1\@xs@nil{\def\@xs@afterdecimal{#1}} + \expandafter\@xs@endnumber\@xs@afterinteger\@xs@nil +} + +\long\def\@xs@endnumber#1\@xs@nil{\def\@xs@afterdecimal{#1}} % test d'\'egalit\'e sur des chaines (et des chaines contenant des nombres) -\def\@xs@IfStrEqFalse@i#1#2{\let\@xs@reserved@A\@secondoftwo} -\def\@xs@IfStrEqFalse@ii#1#2{% renvoie vrai si les 2 arg sont d\'ecimaux et s'ils sont \'egaux, faux sinon +\long\def\@xs@IfStrEqFalse@i#1#2{\let\@xs@reserved@A\@secondoftwo} +\long\def\@xs@IfStrEqFalse@ii#1#2{% renvoie vrai si les 2 arg sont d\'ecimaux et s'ils sont \'egaux, faux sinon \@xs@IfDecimal{#1}% {\@xs@IfDecimal{#2}% - {\ifdim#1pt=#2pt\let\@xs@reserved@A\@firstoftwo\else\let\@xs@reserved@A\@secondoftwo\fi}% les 2 sont d\'ecimaux : on fait le test - {\let\@xs@reserved@A\@secondoftwo}}% un seul est d\'ecimal - {\let\@xs@reserved@A\@secondoftwo}}% #1 n'est pas d\'ecimal - -\def\@xs@TestEqual#1#2{% teste si les 2 arguments sont \'egaux + {\ifdim#1pt=#2pt + \let\@xs@reserved@A\@firstoftwo + \else + \let\@xs@reserved@A\@secondoftwo + \fi% les 2 sont d\'ecimaux : on fait le test + }% + {\let\@xs@reserved@A\@secondoftwo}% un seul est d\'ecimal + }% + {\let\@xs@reserved@A\@secondoftwo}% #1 n'est pas d\'ecimal +} + +\long\def\@xs@TestEqual#1#2{% teste si les 2 arguments sont \'egaux \def\@xs@reserved@A{#1}\def\@xs@reserved@B{#2}% \ifx\@xs@reserved@A\@xs@reserved@B \let\@xs@reserved@A\@firstoftwo% \'egalit\'e parfaite des 2 chaines \else \expandafter\expandafter\expandafter\@xs@reserved@D\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@A\expandafter}\expandafter{\@xs@reserved@B}% \fi - \@xs@reserved@A} + \@xs@reserved@A +} \@xs@newmacro*2\IfStrEq{}{2}{0}{% teste si les deux chaines sont \'egales \let\@xs@reserved@D\@xs@IfStrEqFalse@i - \@xs@TestEqual{#1}{#2}} + \@xs@TestEqual{#1}{#2}% +} \@xs@newmacro*2\IfEq{}{2}{0}{% teste si les 2 arguments (chaine ou nombre) sont \'egaux \let\@xs@reserved@D\@xs@IfStrEqFalse@ii - \@xs@TestEqual{#1}{#2}} + \@xs@TestEqual{#1}{#2}% +} + +\def\IfStrEqCase{% + \@ifstar + {\def\@xs@reserved@E{\IfStrEq*}\@xs@IfStrCase}% + {\def\@xs@reserved@E{\IfStrEq}\@xs@IfStrCase}% +} + +\long\def\@xs@IfStrCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}} -\def\IfStrEqCase{\@ifstar{\def\@xs@reserved@E{\IfStrEq*}\@xs@IfStrCase}{\def\@xs@reserved@E{\IfStrEq}\@xs@IfStrCase}} -\def\@xs@IfStrCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}} +\def\IfEqCase{% + \@ifstar + {\def\@xs@reserved@E{\IfEq*}\@xs@IfEqCase}% + {\def\@xs@reserved@E{\IfEq}\@xs@IfEqCase}% +} -\def\IfEqCase{\@ifstar{\def\@xs@reserved@E{\IfEq*}\@xs@IfEqCase}{\def\@xs@reserved@E{\IfEq}\@xs@IfEqCase}} -\def\@xs@IfEqCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}} +\long\def\@xs@IfEqCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}} -\def\@xs@IfStringCase#1#2[#3]{% - \def\@xs@testcase##1##2##3\@xs@nil{% lit les 2 premieres unit\'es syntaxiques dans ##1 et ##2. Les autres dans ##3 +\long\def\@xs@IfStringCase#1#2[#3]{% + \long\def\@xs@testcase##1##2##3\@xs@nil{% lit les 2 premieres unit\'es syntaxiques dans ##1 et ##2. Les autres dans ##3 \@xs@reserved@E{#1}{##1}% {##2}% le test est positif, on ex\'ecute le code correspondant - {\@xs@testempty{##3}% - \if@xs@empty% le test est n\'egatif - \def\@xs@next{#3}% s'il n'y a plus de cas, on ex\'ecute le code - \else - \def\@xs@next{\@xs@testcase##3\@xs@nil}% sinon, on recommence avec ce qui reste - \fi - \@xs@next}}% - \@xs@testcase#2\@xs@nil} - -% Renvoie ce qui est \`a gauche de l'occurence n°#1 de la sous chaine #3 dans la chaine + {\@xs@ifempty{##3}% + {#3}% s'il n'y a plus de cas, on ex\'ecute le code + {\@xs@testcase##3\@xs@nil}% sinon, on recommence avec ce qui reste + }% + }% + \@xs@testcase#2\@xs@nil +} + +% Renvoie ce qui est \`a gauche de l'occurence n°#1 de la sous chaine #3 dans la chaine #2 \@xs@newmacro*3\StrBefore{1}{2}{1}{% \@xs@cutafteroccur{#2}{#3}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}% +} % Renvoie ce qui est \`a droite de l'occurence n°#1 de la sous chaine #3 dans la chaine #2 \@xs@newmacro*3\StrBehind{1}{2}{1}{% \@xs@cutafteroccur{#2}{#3}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#4}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#4}% +} % Renvoie ce qui est strictement compris entre les occurrences n°#1 et n°#2 % des chaines #4 et #5 dans la chaine #3 \@xs@newmacro*4\StrBetween{1,1}{3}{1}{\@xs@StrBetween@i[#1]{#2}{#3}{#4}[#5]} -\def\@xs@StrBetween@i[#1,#2]#3#4#5[#6]{% + +\long\def\@xs@StrBetween@i[#1,#2]#3#4#5[#6]{% \begingroup \noexploregroups \@xs@cutafteroccur{#3}{#5}{#2}% @@ -684,11 +772,15 @@ \expandafter \endgroup \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#6}% - \let\groupID\@empty} + \global\let\groupID\@empty +} \def\exploregroups{\let\@xs@exploregroups\relax} + \def\noexploregroups{\def\@xs@exploregroups{\let\@xs@toks0\relax}} + \def\saveexploremode{\let\@xs@saveexploremode\@xs@exploregroups} + \def\restoreexploremode{\let\@xs@exploregroups\@xs@saveexploremode} % Remplace les #1 premi\`eres occurences de la chaine #3 @@ -696,11 +788,15 @@ \@xs@newmacro\StrSubstitute{0}{3}{1}{% \def\@xs@reserved@D{#2}\let\@xs@reserved@C\@empty\def\@xs@reserved@E{#3}% \def\@xs@argument@C{#3}\def\@xs@argument@D{#4}% - \decimalpart\z@\integerpart\z@\def\groupID{0}\let\@xs@nestlevel\z@ + \decimalpart\z@ + \integerpart\z@ + \gdef\groupID{0}% + \let\@xs@nestlevel\z@ \def\@xs@atendofgroup{% \expandafter\endgroup \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% - \@xs@read@reserved@D}% + \@xs@read@reserved@D + }% \def\@xs@atoccurfound{% \ifnum#1<\@ne \let\@xs@reserved@A\@xs@argument@D @@ -712,14 +808,15 @@ \fi \fi \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}% - \@xs@read@reserved@D}% - \@xs@testempty{#3}% - \if@xs@empty - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@D}{#5}% - \else \@xs@read@reserved@D + }% + \@xs@ifempty{#3}% + {\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@D}{#5}% + } + {\@xs@read@reserved@D \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#5}% - \fi} + }% +} % Supprime les #1 premi\`eres occurrences de #3 dans #2 \@xs@newmacro\StrDel{0}{2}{1}{\@xs@StrSubstitute[#1]{#2}{#3}{}[#4]} @@ -731,44 +828,61 @@ \def\@xs@reserved@C{#1}% \decimalpart\z@ \let\@xs@nestlevel\z@ - \def\groupID{0}% + \gdef\groupID{0}% \let\@xs@atbegingroup\relax \def\@xs@atendofgroup{\endgroup\@xs@read@reserved@C}% \let\@xs@atnextsyntaxunit\relax \@xs@read@reserved@C - \expandafter\@xs@ReturnResult\expandafter{\number\decimalpart}{#2}} + \expandafter\@xs@ReturnResult\expandafter{\number\decimalpart}{#2}% +} % Macro interne fermant autant de groupes que n\'ecessaire pour trouver une unit\'e syntaxique derri\`ere \def\@xs@continuetonext{% - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \ifnum\@xs@nestlevel>\z@ + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\ifnum\@xs@nestlevel>\z@ \expandafter\endgroup\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% on concat\`ene \expandafter\expandafter\expandafter\@xs@continuetonext% on recommence - \fi - \fi}% + \fi} + \relax +}% \def\@xs@manage@groupID{% \begingroup\def\@xs@reserved@A{0}% \ifx\@xs@reserved@A\groupID% si on arrive du groupe de niveau 0 - \endgroup\edef\groupID{\number\integerpart}% on met simplement le niveau + \endgroup + \xdef\groupID{\number\integerpart}% on met simplement le niveau \else - \endgroup\expandafter\@xs@addtomacro\expandafter\groupID\expandafter{\expandafter,\number\integerpart}% - \fi} + \endgroup + \expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\groupID\expandafter\expandafter\expandafter{\expandafter\groupID\expandafter,\number\integerpart}% + \fi +} % Cette macro coupe la chaine #1 apr\`es l'unit\'e syntaxique n°#2 -\def\StrSplit{\@ifstar{\let\@xs@reserved@E\@xs@continuetonext\StrSpl@t}{\let\@xs@reserved@E\relax\StrSpl@t}} +\def\StrSplit{% + \@ifstar + {\let\@xs@reserved@E\@xs@continuetonext\StrSpl@t}% + {\let\@xs@reserved@E\relax\StrSpl@t}% +} + \@xs@newmacro\StrSpl@t{}{2}{0}{\@xs@StrSplit@i{#2}{#1}\@xs@StrSplit@ii} + % Cette macro interne coupe la chaine #2 apr\`es l'unit\'e syntaxique n°#1 % Le d\'ebut est assign\'e dans \@xs@reserved@B et la fin dans \@xs@reserved@C -\def\@xs@StrSplit@i#1#2{% - \def\@xs@reserved@D{#1}\def\@xs@reserved@C{#2}\let\@xs@reserved@B\@empty\let\groupID\@empty +\long\def\@xs@StrSplit@i#1#2{% + \def\@xs@reserved@D{#1}% + \def\@xs@reserved@C{#2}% + \let\@xs@reserved@B\@empty + \global\let\groupID\@empty \ifnum#1>\z@ - \decimalpart\z@\integerpart\z@\def\groupID{0}\let\@xs@nestlevel\z@ + \decimalpart\z@ + \integerpart\z@ + \gdef\groupID{0}% + \let\@xs@nestlevel\z@ \def\@xs@atendofgroup{% \expandafter\endgroup \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% - \@xs@read@reserved@C}% + \@xs@read@reserved@C + }% \def\@xs@atbegingroup{\let\@xs@reserved@B\@empty}% \def\@xs@atnextsyntaxunit{% \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@A}% @@ -776,14 +890,68 @@ \ifx\@xs@reserved@C\@empty\@xs@reserved@E\fi \global\let\@xs@reserved@B\@xs@reserved@B \global\let\@xs@reserved@C\@xs@reserved@C - \global\let\groupID\groupID \@xs@exitallgroups \let\@xs@next\relax - \fi}% + \fi + }% \@xs@read@reserved@C - \fi} + \fi +} + \def\@xs@StrSplit@ii#1#2{\let#1\@xs@reserved@B\let#2\@xs@reserved@C} +% StrCut[n]{}{}\macroA\macroB +% \macroA reçoit ce qui se trouve avant la n ème occurrence dans +% \macroB reçoit ce qui est après cette n ème occurrence +\@xs@newmacro*3\StrCut{1}{2}{0}{% + \@xs@ifempty{#3}% + {\global\let\groupID\@empty + \let\@xs@reserved@C\@empty + \let\@xs@reserved@E\@empty + } + {\ifnum#1<\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + {\@xs@StrCut@ii{#2}{#3}1} + {\@xs@StrCut@ii{#2}{#3}{#1}}% + }% + \@xs@StrCut@iii +} + +\long\def\@xs@StrCut@ii#1#2#3{% + \def\@xs@reserved@D{#1}% + \let\@xs@reserved@C\@empty + \def\@xs@reserved@E{#2}% + \decimalpart\z@\integerpart\z@ + \gdef\groupID{0}% + \let\@xs@nestlevel\z@ + \def\@xs@atendofgroup{% + \expandafter\endgroup + \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% + \@xs@read@reserved@D + }% + \def\@xs@atoccurfound{% + \ifnum\decimalpart=\numexpr(#3)\relax + \global\let\@xs@reserved@D\@xs@reserved@D + \global\let\@xs@reserved@C\@xs@reserved@C + \@xs@exitallgroups + \let\@xs@next\relax + \else + \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@E}% + \let\@xs@next\@xs@read@reserved@D + \fi + }% + \@xs@read@reserved@D + \def\@xs@argument@A{#2}% + \let\@xs@reserved@E\@xs@reserved@D + \expandafter\expandafter\expandafter + \def + \expandafter\expandafter\expandafter + \@xs@reserved@D + \expandafter\expandafter\expandafter + {\expandafter\@xs@reserved@C\@xs@argument@A}% +} + +\long\def\@xs@StrCut@iii#1#2{\let#1\@xs@reserved@C\let#2\@xs@reserved@E} + % De la chaine #1, renvoie ce qui se trouve entre les positions % #2 et #3, unit\'es syntaxiques aux positions compris ! \@xs@newmacro\StrMid{}{3}{1}{% @@ -796,33 +964,38 @@ \expandafter\expandafter\expandafter\@xs@StrSplit@i\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@B}% \expandafter\endgroup \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}% - \let\groupID\@empty} + \global\let\groupID\@empty +} % supprime #2 unit\'es syntaxiques \`a gauche dans la chaine #1 \@xs@newmacro\StrGobbleLeft{}{2}{1}{% \let\@xs@reserved@E\relax \@xs@StrSplit@i{#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}% +} % extrait de #1 la chaine \`a gauche de longueur #2 \@xs@newmacro\StrLeft{}{2}{1}{% \let\@xs@reserved@E\relax \@xs@StrSplit@i{#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}% +} % supprime #2 unit\'es syntaxiques \`a droite dans la chaine #1 \@xs@newmacro\StrGobbleRight{}{2}{1}{% \@xs@StrLen{#1}[\@xs@reserved@D]% \let\@xs@reserved@E\relax \expandafter\@xs@StrSplit@i\expandafter{\number\numexpr\@xs@reserved@D-#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}% +} % renvoie #2 unit\'es syntaxiques \`a la droite de la chaine #1 \@xs@newmacro\StrRight{}{2}{1}{% \@xs@StrLen{#1}[\@xs@reserved@D]% \let\@xs@reserved@E\relax \expandafter\@xs@StrSplit@i\expandafter{\number\numexpr\@xs@reserved@D-#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}} + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}% +} \@xs@newmacro\StrChar{}{2}{1}{% \let\@xs@reserved@B\@empty @@ -834,32 +1007,37 @@ \def\@xs@atnextsyntaxunit{% \ifnum\decimalpart=\@xs@reserved@D% la n i\`eme US est atteinte ? \global\let\@xs@reserved@B\@xs@reserved@A% on capture l'US en cours qui est celle cherch\'ee - \global\let\groupID\groupID \@xs@exitallgroups \let\@xs@next\relax - \fi}% + \fi + }% \@xs@read@reserved@C \fi - \expandafter\@xs@testempty\expandafter{\@xs@reserved@B}% - \if@xs@empty\let\groupID\@empty\fi - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}} + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@B}% + {\global\let\groupID\@empty} + \relax + \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}% +} % Combien de fois compte t-on #2 dans #1 ? \@xs@newmacro\StrCount{}{2}{1}{% - \@xs@testempty{#2}% \def\@xs@reserved@D{#1}\def\@xs@reserved@E{#2}\let\@xs@reserved@C\@empty - \if@xs@empty - \@xs@ReturnResult{0}{#3}% - \else - \decimalpart\z@\integerpart\z@\def\groupID{0}\let\@xs@nestlevel\z@ + \@xs@ifempty{#2}% + {\@xs@ReturnResult{0}{#3}} + {\decimalpart\z@ + \integerpart\z@ + \gdef\groupID{0}% + \let\@xs@nestlevel\z@ \def\@xs@atendofgroup{% \expandafter\endgroup \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% - \@xs@read@reserved@D}% + \@xs@read@reserved@D + }% \def\@xs@atoccurfound{\let\@xs@reserved@C\@empty\@xs@read@reserved@D}% \@xs@read@reserved@D \expandafter\@xs@ReturnResult\expandafter{\number\decimalpart}{#3}% - \fi} + }% +} % renvoie la position de l'occurrence #1 de la sous chaine #3 dans la chaine #2 \@xs@newmacro\StrPosition{1}{2}{1}{% @@ -872,12 +1050,17 @@ \expandafter\@xs@StrLen\expandafter{\@xs@reserved@C}[\@xs@reserved@C]% \expandafter\@xs@ReturnResult\expandafter{\number\numexpr\@xs@reserved@C+1}{#4}% \fi - \let\groupID\@xs@reserved@E} + \global\let\groupID\@xs@reserved@E +} \def\comparestrict{\let\@xs@comparecoeff\@ne} + \def\comparenormal{\let\@xs@comparecoeff\z@} + \def\savecomparemode{\let\@xs@saved@comparecoeff\@xs@comparecoeff} + \def\restorecomparemode{\let\@xs@comparecoeff\@xs@saved@comparecoeff} + % Compare les deux arguments #1 et #2 % Renvoie 0 s'ils sont \'egaux et renvoie la % position de la premiere unit\'e syntaxiques diff\'erente sinon @@ -889,41 +1072,42 @@ \else \def\@xs@next{\@xs@StrCompare@i{#1}{#2}{#3}}% \expandafter\@xs@next - \fi} + \fi +} -\def\@xs@StrCompare@i#1#2#3{% +\long\def\@xs@StrCompare@i#1#2#3{% \def\@xs@StrCompare@iii##1{% \let\@xs@reserved@A\@empty - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \def\@xs@reserved@A{*\@xs@comparecoeff}% - \else - \expandafter\@xs@testempty\expandafter{\@xs@reserved@D}% - \if@xs@empty - \def\@xs@reserved@A{*\@xs@comparecoeff}% - \fi - \fi + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\def\@xs@reserved@A{*\@xs@comparecoeff}}% + {\expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}% + {\def\@xs@reserved@A{*\@xs@comparecoeff}} + \relax + }% \def\@xs@next{% \expandafter\@xs@ReturnResult\expandafter - {\number\numexpr##1\@xs@reserved@A\relax}{#3}}}% + {\number\numexpr##1\@xs@reserved@A\relax}{#3}% + }% + }% \def\@xs@StrCompare@ii##1{% ##1 est la position \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@B \ifx\@xs@reserved@B\@xs@reserved@A - \expandafter\@xs@testempty\expandafter{\@xs@reserved@A}% - \if@xs@empty - \@xs@StrCompare@iii{##1}% les 2 unit\'es syntaxiques sont \'egales, on renvoie la position - \else - \def\@xs@next{\expandafter\@xs@StrCompare@ii\expandafter{\number\numexpr##1+1}}% les 2 unit\'es syntaxiques sont \'egales et non vides, on recommence + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@A}% + {\@xs@StrCompare@iii{##1}% les 2 unit\'es syntaxiques sont \'egales, on renvoie la position + } + {\def\@xs@next{\expandafter\@xs@StrCompare@ii\expandafter{\number\numexpr##1+1}}% les 2 unit\'es syntaxiques sont \'egales et non vides, on recommence \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@D - \fi + }% \else% les 2 unit\'es syntaxiques sont diff\'erentes : on renvoie la position \@xs@StrCompare@iii{##1}% \fi - \@xs@next}% + \@xs@next + }% \def\@xs@reserved@C{#1}\def\@xs@reserved@D{#2}% - \@xs@StrCompare@ii1} + \@xs@StrCompare@ii1% +} \@xs@newmacro\StrFindGroup{}{2}{1}{% \def\@xs@reserved@A{#2}\def\@xs@reserved@B{0}% @@ -932,14 +1116,15 @@ \else \def\@xs@next{\@xs@StrFindGroup@i{#1}{#2}[#3]}% \fi - \@xs@next} -\def\@xs@StrFindGroup@i#1#2[#3]{% + \@xs@next +} + +\long\def\@xs@StrFindGroup@i#1#2[#3]{% \def\@xs@StrFindGroup@ii{% - \expandafter\@xs@testempty\expandafter{\@xs@reserved@C}% - \if@xs@empty - \def\@xs@next{\@xs@ReturnResult{}{#3}}% s'il ne reste plus rien, on renvoie vide - \else - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@D + \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% + {\def\@xs@next{\@xs@ReturnResult{}{#3}}% s'il ne reste plus rien, on renvoie vide + } + {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@D \ifx\bgroup\@xs@toks% si la 1\`ere unit\'e syntaxique est un groupe explicite \advance\decimalpart\@ne% on augmente le compteur \ifnum\decimalpart=\@xs@reserved@A% on est au groupe cherch\'e lors de la profondeur courante ? @@ -957,36 +1142,45 @@ \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C \let\@xs@next\@xs@StrFindGroup@ii \fi - \fi - \@xs@next}% + }% + \@xs@next + }% \@xs@extractgroupnumber{#2}\@xs@reserved@A\@xs@reserved@B \decimalpart\z@ \ifnum\@xs@reserved@A>\z@\def\@xs@reserved@C{#1}\else\let\@xs@reserved@C\@empty\fi - \@xs@StrFindGroup@ii} + \@xs@StrFindGroup@ii +} \def\@xs@extractgroupnumber#1#2#3{% \def\@xs@extractgroupnumber@i##1,##2\@xs@nil{\def#2{##1}\def#3{##2}}% \@xs@extractgroupnumber@i#1,\@xs@nil - \ifx\@empty#3\else\@xs@extractgroupnumber@i#1\@xs@nil\fi} + \ifx\@empty#3\else\@xs@extractgroupnumber@i#1\@xs@nil\fi +} \def\expandingroups{\let\@xs@expandingroups\exploregroups} + \def\noexpandingroups{\let\@xs@expandingroups\noexploregroups} + \def\StrExpand{\@testopt{\@xs@StrExpand}{1}} -\def\@xs@StrExpand[#1]#2#3{% +\long\def\@xs@StrExpand[#1]#2#3{% \begingroup \@xs@expandingroups \ifnum#1>\z@ \integerpart#1\relax - \decimalpart\z@\def\groupID{0}\let\@xs@nestlevel\z@ + \decimalpart\z@ + \gdef\groupID{0}% + \let\@xs@nestlevel\z@ \def\@xs@atendofgroup{% \expandafter\endgroup \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% - \@xs@read@reserved@C}% + \@xs@read@reserved@C + }% \def\@xs@atbegingroup{\let\@xs@reserved@B\@empty}% \def\@xs@atnextsyntaxunit{% \expandafter\expandafter\expandafter\@xs@addtomacro \expandafter\expandafter\expandafter\@xs@reserved@B - \expandafter\expandafter\expandafter{\@xs@reserved@A}}% + \expandafter\expandafter\expandafter{\@xs@reserved@A}% + }% \def\@xs@reserved@C{#2}% \@xs@StrExpand@i{#1}% Appel de la macro r\'ecursive \else @@ -995,8 +1189,10 @@ \global\let\@xs@reserved@B\@xs@reserved@B \endgroup \let#3\@xs@reserved@B - \let\groupID\@empty} -\def\@xs@StrExpand@i#1{% + \global\let\groupID\@empty +} + +\long\def\@xs@StrExpand@i#1{% \ifnum#1>\z@ \let\@xs@reserved@B\@empty \@xs@read@reserved@C @@ -1005,15 +1201,18 @@ \else \let\@xs@reserved@A\relax \fi - \@xs@reserved@A} + \@xs@reserved@A +} \def\scancs{\@testopt{\@xs@scancs}{1}} -\def\@xs@scancs[#1]#2#3{% +\long\def\@xs@scancs[#1]#2#3{% \@xs@StrExpand[#1]{#3}{#2}% - \edef#2{\detokenize\expandafter{#2}}} + \edef#2{\detokenize\expandafter{#2}}% +} % Restaure le code de @ \catcode`\@=\CurrentAtCatcode\relax + % D\'efinit le d\'elimiteur verb % d\'efinit les diff\'erents modes et les m\'emorise \setverbdelim{|}% @@ -1021,6 +1220,7 @@ \comparenormal\savecomparemode \noexploregroups\saveexploremode \expandingroups + \endinput % % Historique @@ -1067,7 +1267,7 @@ % toutes les macros r\'ecursives, simplification de \@xs@TestEqual en % utilisant \ifx % - Nouvelles macros \IfStrEqCase et \IfEqCase -% Teste si une chaîne est \'egale \`a plusieurs chaînes donn\'ee et +% Teste si une chaîne est \'egale \`a plusieurs cha\^ines donn\'ee et % ex\'ecute un code sp\'ecifique % - Cr\'eation de la macro publique \StrSplit % Coupe la chaine en 2 \`a une position donn\'ee @@ -1165,4 +1365,27 @@ % - \xs@formatnumber ne detokenize plus ses arguments (que m'est-il pass\'e % par la t\^ete pour que je code un truc comme ca ?), et donc % \@xs@afterinteger et \@xs@afterdecimal ont des tokens ayant le bon -% catcode \ No newline at end of file +% catcode +%------------------------------------------------------------------------------ +% v1.6 24/10/2012 +% - Correction d'un bug dans \@xs@cutafteroccur au cas o\`u #3<1 +% - \IfDecimal ne \detokenize plus l'argument. +% - Nouvelle version de \tokenize qui enlevait les accolades si son argument +% \'etait entre accolades +% - Nouvelle macro \StrCut +% - \@xs@cutafteroccur@i ne produit plus d'espace indésirable si #3 était +% évalué par \numexpr +%------------------------------------------------------------------------------ +% v1.7 13/1/2013 +% - Correction d'un manque de rigueur dans les assignations concernant +% \groupID : elles sont toutes globales d\'esormais +% - Les macros de xstring sont \long +%------------------------------------------------------------------------------ +% v1.7a 28/2/2013 +% - Correction d'un espace parasite dans \@xs@removefirstsyntaxunit +%------------------------------------------------------------------------------ +% v1.7b 29/7/2013 +% - La date contenue dans \xstringdate est désormais conforme +%------------------------------------------------------------------------------ +% v1.7c 13/10/2013 +% - les macros impliquées dans \IfStrCase et \IfStrEqCase sont désormais \long From ef9a4497e6216f0fa3c7d90a9ea35c6efd559da3 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 28 Apr 2014 09:47:17 +0200 Subject: [PATCH 04/17] =?UTF-8?q?Am=C3=A9lioration=20du=20paquet=20debian?= =?UTF-8?q?=20#26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le principe est : - songbook-core peut être utilisé avec les dépendences de ce paquet - songbook-data peut être compilé avec les paquets recommandés par ce paquet --- stdeb.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdeb.cfg b/stdeb.cfg index c680156b..be040279 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -1,4 +1,6 @@ [DEFAULT] -Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode +Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, lilypond, texlive-fonts-recommended +Recommends: texlive-lang-english, texlive-lang-french, texlive-lang-portuguese, texlive-lang-spanish, texlive-fonts-extra XS-Python-Version: >=2.7 +Section: tex From 9d2033504f54713b0ed22d1448fef498eabdccb2 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 28 Apr 2014 09:58:14 +0200 Subject: [PATCH 05/17] Message d'erreur plus clair en cas d'erreur json dans les fichiers.sb --- songbook | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/songbook b/songbook index 9a814474..678e243e 100755 --- a/songbook +++ b/songbook @@ -100,8 +100,14 @@ def main(): basename = os.path.basename(songbook_path)[:-3] - with open(songbook_path) as songbook_file: - songbook = json.load(songbook_file) + try: + with open(songbook_path) as songbook_file: + songbook = json.load(songbook_file) + except Exception as error: # pylint: disable=broad-except + LOGGER.error(error) + LOGGER.error("Error while loading file '{}'.".format(songbook_path)) + sys.exit(1) + if options.datadir is not None: songbook['datadir'] = options.datadir[0] From 96e5a1f2e92446ddf0b77598dff9ecce428ab6f2 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 28 Apr 2014 18:14:41 +0200 Subject: [PATCH 06/17] Corrected indentation errors (tabs instead of spaces) --- songbook_core/index.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/songbook_core/index.py b/songbook_core/index.py index 504082d9..78b64165 100755 --- a/songbook_core/index.py +++ b/songbook_core/index.py @@ -40,7 +40,7 @@ def process_sxd(filename): """ data = [] with codecs.open(filename, 'r', 'utf-8') as index_file: - for line in index_file: + for line in index_file: data.append(line.strip()) i = 1 @@ -148,10 +148,10 @@ class Index(object): "{} ({})".format( match.group(2) + match.group(3), match.group(1) - ), + ), number, - link - ) + link + ) return self._raw_add(key, number, link) @@ -165,13 +165,13 @@ class Index(object): @staticmethod def ref_to_str(ref): """Return the LaTeX code corresponding to the reference.""" - return r'\hyperlink{{{0[link]}}}{{{0[num]}}}'.format(ref) + return r'\hyperlink{{{0[link]}}}{{{0[num]}}}'.format(ref) def entry_to_str(self, key, entry): """Return the LaTeX code corresponding to the entry.""" - if not isinstance(key, unicode): - key = unicode(key, "UTF-8") - return unicode(ur'\idxentry{{{0}}}{{{1}}}' + EOL).format( + if not isinstance(key, unicode): + key = unicode(key, "UTF-8") + return unicode(ur'\idxentry{{{0}}}{{{1}}}' + EOL).format( key, ur'\\'.join([self.ref_to_str(ref) for ref in entry]), ) From 9bb910b1b9868da18fc87a7c47900917deef511d Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 28 Apr 2014 18:15:27 +0200 Subject: [PATCH 07/17] Added parsing of songs \[ macros [#15](/patacrep/songbook-web/issues/15) --- songbook_core/plastex.py | 1 + songbook_core/plastex_chord.py | 110 +++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 songbook_core/plastex_chord.py diff --git a/songbook_core/plastex.py b/songbook_core/plastex.py index 84b29b96..7f5980ea 100644 --- a/songbook_core/plastex.py +++ b/songbook_core/plastex.py @@ -59,6 +59,7 @@ class SongParser(object): tex.ownerDocument.context.loadBaseMacros() sys.path.append(os.path.dirname(__file__)) tex.ownerDocument.context.loadPackage(tex, "plastex_patchedbabel") + tex.ownerDocument.context.loadPackage(tex, "plastex_chord") tex.ownerDocument.context.loadPackage(tex, "plastex_songs") sys.path.pop() return tex diff --git a/songbook_core/plastex_chord.py b/songbook_core/plastex_chord.py new file mode 100644 index 00000000..b3a71eee --- /dev/null +++ b/songbook_core/plastex_chord.py @@ -0,0 +1,110 @@ +# -*- coding: utf-8 -*- + +r"""PlasTeX module to deal with chords commands of the songs LaTeX package + +Chords are set using commands like \[C]. This package parses those commands. +""" + +from plasTeX import Command, Environment, Macro +from plasTeX.Base.LaTeX.Math import BeginDisplayMath + +# Count the number of levels of 'verse' environment: IN_VERSE==1 means that we +# are in a 'verse' environment; IN_VERSE==2 means that we are in two included +# 'verse' environment, and so on. +IN_VERSE = 0 + +def wrap_displaymath(cls): + """Decorator to store the depth of 'verse' environment + + In the invoke() method classes, global variable IN_VERSE indicates the + number of 'verse' (or 'chorus' or 'verse*') environment we are in. + """ + + # pylint: disable=no-init,too-few-public-methods + class DisplayMath(cls): + """Wrapper to LaTeX environment updating IN_VERSE""" + blockType = True + # pylint: disable=super-on-old-class,global-statement,no-member + def invoke(self, tex): + """Wrapper to invoke() to update global variable IN_VERSE.""" + global IN_VERSE + if self.macroMode == Macro.MODE_BEGIN: + IN_VERSE += 1 + else: + IN_VERSE -= 1 + super(DisplayMath, self).invoke(tex) + return DisplayMath + +# pylint: disable=too-many-public-methods +@wrap_displaymath +class Verse(Environment): + """LaTeX 'verse' environment""" + macroName = 'verse' + +# pylint: disable=too-many-public-methods +@wrap_displaymath +class VerseStar(Environment): + """LaTeX 'verse*' environment""" + macroName = 'verse*' + +# pylint: disable=too-many-public-methods +@wrap_displaymath +class Chorus(Environment): + """LaTeX 'chorus' environment""" + macroName = 'chorus' + + + +class BeginChord(Command): + """Beginning of a chord notation""" + macroName = 'chord' + macroMode = Command.MODE_BEGIN + + @property + def source(self): + """Return chord LaTeX code.""" + return r'\[{}]'.format(''.join([str(item) for item in self.childNodes])) + +class EndChord(Command): + """End of a chord notation""" + macroMode = Command.MODE_END + +class BeginChordOrDisplayMath(BeginDisplayMath): + r"""Wrapper to BeginDisplayMath + + In a 'verse' (or 'verse*' or 'chorus') environment, the '\[' macro + displays a chord. Otherwise, it corresponds to the usual LaTeX math mode. + This class calls the right method, depending on the inclusion of this + macro in a verse environment. + """ + macroName = '[' + + def digest(self, tokens): + """Consume the tokens corresponding to the arguments of this macro""" + if IN_VERSE: + for item in tokens: + if item.nodeType == item.TEXT_NODE and item.nodeValue == ']': + break + self.appendChild(item) + else: + return super(BeginChordOrDisplayMath, self).digest(tokens) + + def invoke(self, tex): + """Process this macro""" + if IN_VERSE: + begin = BeginChord() + self.ownerDocument.context.push(begin) # pylint: disable=no-member + self.parse(tex) + + for token in tex: + if token.nodeType == token.TEXT_NODE and token.nodeValue == ']': + break + else: + begin.appendChild(token) + + end = EndChord() + self.ownerDocument.context.push(end) # pylint: disable=no-member + + return [begin] + else: + return super(BeginChordOrDisplayMath, self).invoke(tex) From 60bee0ea62c77bfc78ac6e98f8199c200d42c6c7 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 6 May 2014 14:53:56 +0200 Subject: [PATCH 08/17] typo --- songbook_core/data/templates/layout.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/songbook_core/data/templates/layout.tex b/songbook_core/data/templates/layout.tex index a0d50dcc..008420ad 100644 --- a/songbook_core/data/templates/layout.tex +++ b/songbook_core/data/templates/layout.tex @@ -19,7 +19,7 @@ %! https://github.com/patacrep/ -%% Automaticly generated document. +%% Automatically generated document. %% You may edit this file but all changes will be overwritten. %% If you want to change this document, have a look at %% the templating system. From 4592c577105bdca7aa062ec22f55127301f0def0 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 6 May 2014 14:54:03 +0200 Subject: [PATCH 09/17] =?UTF-8?q?D=C3=A9sactivation=20de=20l'entr=C3=A9e?= =?UTF-8?q?=20standard=20de=20la=20compilation=20pdflatex.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/songbook_core/build.py b/songbook_core/build.py index a3bb9adb..54287413 100644 --- a/songbook_core/build.py +++ b/songbook_core/build.py @@ -232,8 +232,11 @@ class SongbookBuilder(object): self._run_once(self._set_latex) process = Popen( ["pdflatex"] + self._pdflatex_options + [self.basename], + stdin=PIPE, stdout=PIPE, stderr=PIPE) + if not self.interactive: + process.stdin.close() log = '' line = process.stdout.readline() while line: From 758c12b6680884c5c29dc73e3578431bf93492f7 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Sat, 10 May 2014 11:21:50 +0100 Subject: [PATCH 10/17] Configuration file for RPMs. --- setup.cfg | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..5d58cdcf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +[bdist_rpm] +requires = python >= 2.7 + python-unidecode + python-jinja2 + texlive + texlive-framed + texlive-nfssext-cfr + lilypond + + From 0dac850d909957c9e7607172eb8aeed8ce85cae2 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 12 May 2014 13:54:37 +0200 Subject: [PATCH 11/17] =?UTF-8?q?Suppression=20de=20paquets=20pr=C3=A9sent?= =?UTF-8?q?s=20dans=20CTAN=20(#28)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/data/latex/venturisold.sty | 30 - songbook_core/data/latex/xstring.sty | 1391 ---------------------- stdeb.cfg | 2 +- 3 files changed, 1 insertion(+), 1422 deletions(-) delete mode 100644 songbook_core/data/latex/venturisold.sty delete mode 100644 songbook_core/data/latex/xstring.sty diff --git a/songbook_core/data/latex/venturisold.sty b/songbook_core/data/latex/venturisold.sty deleted file mode 100644 index 0fa21368..00000000 --- a/songbook_core/data/latex/venturisold.sty +++ /dev/null @@ -1,30 +0,0 @@ -%% Copyright 2010 Clea F. Rees -% -% This work may be distributed and/or modified under the -% conditions of the LaTeX Project Public License, either version 1.3 -% of this license or (at your option) any later version. -% The latest version of this license is in -% 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. -% -% This work has the LPPL maintenance status `maintained'. -% -% The Current Maintainer of this work is Clea F. Rees. -% -% This work consists of all files listed in manifest.txt. -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{venturisold}[2010/07/03 v1.005 VenturisOldADF PS] -\RequirePackage[T1]{fontenc} -\RequirePackage{textcomp} -\RequirePackage{nfssext-cfr} -%:Make Venturis Old default for roman text -\renewcommand{\rmdefault}{yvo} -%:introduce special titling commands -\DeclareRobustCommand{\vtstyle}[1][]{% allow an optional argument for consistency with venturis.sty - \not@math@alphabet\vtstyle\relax - \fontfamily{yvod}\selectfont} -\DeclareTextFontCommand{\textvt}{\vtstyle} -\DeclareTextFontCommand{\textvtl}{\vtstyle} -\endinput -%% end venturisold.sty diff --git a/songbook_core/data/latex/xstring.sty b/songbook_core/data/latex/xstring.sty deleted file mode 100644 index 9949d02b..00000000 --- a/songbook_core/data/latex/xstring.sty +++ /dev/null @@ -1,1391 +0,0 @@ -% __________________________________________________ -% | | -% | | -% | xstring v1.7c | -% | | -% | 13 octobre 2013 | -% | | -% |__________________________________________________| -% -% This is xtring.tex -% -% "xstring" package consists of the 7 following files: -% xstring.tex (this file) -% xstring.sty -% .tex and .sty file have been mixed in this single file. -% README -% xstring_doc_fr.tex, xstring_doc_fr.pdf (manual in french) -% xstring_doc_en.tex, xstring_doc_en.pdf (manual in english) -% -% Christian Tellechea 2008-2013 -% email : unbonpetit@gmail.com -% ------------------------------------------------------------------- -% This work may be distributed and/or modified under the -% conditions of the LaTeX Project Public License, either version 1.3 -% of this license or (at your option) any later version. -% The latest version of this license is in -% -% 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. -% ------------------------------------------------------------------- -% This work has the LPPL maintenance status `maintained'. -% -% The Current Maintainer of this work is Christian Tellechea -% ------------------------------------------------------------------- -\def\xstringversion {1.7c} -\def\xstringdate {2013/10/13} -\def\xstringfrenchdate {13 octobre 2013} -\def\xstringenglishdate {13 october 2013} -\ProvidesPackage{xstring}[\xstringdate\space\space v\xstringversion\space\space String manipulations (C Tellechea)] -\edef\CurrentAtCatcode {\the\catcode`\@} -\catcode`\@=11 -\newwrite\@xs@message% canal pour les messages -\newcount\integerpart -\newcount\decimalpart% compteurs utilis\'es par xstring - -\expandafter\ifx\csname @latexerr\endcsname\relax% on n'utilise pas LaTeX ? - \immediate\write\m@ne{Package: xstring \xstringdate\space\space v\xstringversion\space\space String manipulations}% - \long\def\@firstoftwo#1#2{#1} - \long\def\@secondoftwo#1#2{#2} - \long\def\@gobble#1{} - \long\def\@ifnextchar#1#2#3{% - \let\reserved@d=#1% - \def\reserved@a{#2}% - \def\reserved@b{#3}% - \futurelet\@let@arg\@ifnch} - \def\@ifnch{% - \ifx\@let@arg\@sptoken - \let\reserved@c\@xifnch - \else - \ifx\@let@arg\reserved@d - \let\reserved@c\reserved@a - \else - \let\reserved@c\reserved@b - \fi - \fi - \reserved@c} - \def\:{\let\@sptoken= } \: - \def\:{\@xifnch} \expandafter\def\: {\futurelet\@let@arg\@ifnch} - \def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} - \long\def\@testopt#1#2{\@ifnextchar[{#1}{#1[{#2}]}} - \def\@empty{} -\fi% fin des d\'efinitions LaTeX - -\long\def\@xs@ifempty#1{% - \expandafter\ifx\expandafter\relax\detokenize{#1}\relax - \expandafter\@firstoftwo - \else - \expandafter\@secondoftwo - \fi -} -% Ouvre un groupe o\`u les catcodes sont \`a 12 et \`a 10 pour les espaces -% ensuite, appelle \@xs@ReadVerb qui lit un argument entre d\'elimiteurs verb -\def\@xs@MakeVerb{% lit 1 argument et le transforme en verb - \begingroup% groupe o\`u les catcodes sont \`a 12 pour la lecture suivante - \def\do##1{\catcode`##112\relax}% - \dospecials% on entre dans le mode verb - \obeyspaces% et on tient compte des espaces - \@xs@ReadVerb% et on va lire l'argument -} - -% D\'efinit \@xs@ReadVerb qui lit un argument entre d\'elimiteurs verb -\def\setverbdelim#1{% d\'efinit quel est le d\'elimiteur de verb - \expandafter\@xs@ifempty\expandafter{\@gobble#1}% - \relax - {\begingroup - \newlinechar`\^^J% - \immediate\write\@xs@message - {Package xstring Warning: verb delimiter is not a single token on input line \the\inputlineno^^J}% - \endgroup - }% - \def\@xs@ReadVerb##1#1##2#1{% lit ##2 qui est entre les d\'elimiteurs de verb - \endgroup% on ferme le groupe - \@xs@afterreadverb{##2}}% on appelle l'ex\'ecution de fin -} - -% Assigne l'argument entre d\'elimiteur verb dans la sc #1' + -\def\verbtocs#1{% - \def\@xs@afterreadverb##1{\def#1{##1}}% - \@xs@MakeVerb -} - -\begingroup - \catcode\z@3 \def\@xs@twochars{^^00}% - \catcode\z@7 \xdef\@xs@twochars{\@xs@twochars^^00}% -\endgroup - -\edef\@xs@reserved@A{\long\def\noexpand\@xs@AssignResult##1\@xs@twochars} - -\@xs@reserved@A#2{\endgroup\expandafter\def\expandafter#2\expandafter{\@gobble#1}} - -\def\tokenize#1#2{% - \begingroup - \@xs@def\@xs@reserved@A{#2}% on d\'eveloppe en accord avec \fullexpandarg ou \noexpandarg - \everyeof\expandafter{\@xs@twochars#1}% met "^^@^^@#1" \`a la fin du fichier virtuel - \endlinechar\m@ne - \expandafter\@xs@AssignResult\scantokens\expandafter{\expandafter\relax\@xs@reserved@A}% on fait l'assignation -}% - -% Macro tr\`es simple qui assigne ou affiche le r\'esultat, selon la pr\'esence -% ou non de #2 qui est l'argument optionnel venant en derni\`ere position des macros -\long\def\@xs@ReturnResult#1#2{% - \def\@xs@argument@A{#1}% - \@xs@ifempty{#2}% - \@xs@argument@A - {\let#2\@xs@argument@A}% -} - -\def\@xs@ldef{\long\def} - -\def\@xs@ledef{\long\edef} - -% Pas d'expansion des arguments -\def\normalexpandarg{% - \let\@xs@def\@xs@ldef% on d\'efinit \@xs@call avec \def - \def\@xs@expand##1{\unexpanded\expandafter{##1}}} -\let\noexpandarg\normalexpandarg% synonyme - -% 1-d\'eveloppement du premier token des arguments -\def\expandarg{% - \let\@xs@def\@xs@ldef% on d\'efinit \@xs@call avec \def - \def\@xs@expand##1{\unexpanded\expandafter\expandafter\expandafter{##1}}% -} - -% D\'eveloppement maximum des arguments -\def\fullexpandarg{% - \let\@xs@def\@xs@ledef% on d\'efinit\@xs@call avec \edef - \def\@xs@expand##1{##1}% et on neutralise \@xs@expand -} - -\def\saveexpandmode{\let\@xs@saved@def\@xs@defarg\let\@xs@saved@expand\@xs@expand} - -\def\restoreexpandmode{\let\@xs@defarg\@xs@saved@def\let\@xs@expand\@xs@saved@expand} - -% Macro interne renvoyant #2 si son argument commence par une accolade ouvrante "{" -% et #3 sinon (Ulrich Diez sur comp.text.tex) -\long\def\@xs@ifbeginwithbrace#1{% - \csname @% - \expandafter\@gobble\string{% - \expandafter\@gobble\expandafter{\expandafter{\string#1}% - \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\@firstoftwo - \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\@gobble - \expandafter\expandafter\expandafter\@gobble - \expandafter\expandafter\expandafter{\expandafter\string\expandafter}\string}% - \expandafter\@gobble\string}% - \@secondoftwo{first}{second}oftwo% - \endcsname -} - -% Cette macro interne prend la 1ere unit\'e syntaxique de #1 et assigne le r\'esultat \`a #2 -\long\def\@xs@returnfirstsyntaxunit#1#2{% - \def\@xs@groupfound{\expandafter\def\expandafter#2\expandafter{\expandafter{#2}}\@xs@gobbleall}% on met #2 dans des accolades et on finit - \long\def\@xs@assignfirsttok##1##2\@xs@nil{\let\@xs@toks0\def#2{##1}}% - \def\@xs@testfirsttok{% - \let\@xs@next\@xs@assignfirsttok - \ifx\@xs@toks\bgroup - \expandafter\@xs@ifbeginwithbrace\expandafter{\@xs@argument}{\def\@xs@next{\afterassignment\@xs@groupfound\def#2}}{}% - \fi - \@xs@next}% - \def\@xs@argument{#1}% - \edef\@xs@next{\expandafter\@xs@beforespace\detokenize{#1} \@xs@nil}% #1 commence par un espace ? - \ifx\@xs@next\@empty - \def\@xs@next{\expandafter\ifx\expandafter\@empty\detokenize\expandafter{\@xs@argument}\@empty\let#2\@empty\else\def#2{ }\let\@xs@toks0\fi}% - \else - \def\@xs@next{\expandafter\futurelet\expandafter\@xs@toks\expandafter\@xs@testfirsttok\@xs@argument\@xs@nil}% - \fi - \@xs@next -} - -% Cette macro interne enl\`eve la 1ere unit\'e syntaxique de #1 et assigne le r\'esultat \`a #2 -\long\def\@xs@testsecondtoken#1\@xs@nil{\@xs@ifbeginwithbrace{#1}} - -\long\def\@xs@gobblespacebeforebrace#1#{}% supprime tout ce qui est avant la 1ere accolade ouvrante - -\long\def\@xs@removefirstsyntaxunit#1#2{% - \def\@xs@argument{#1}% - \expandafter\expandafter\expandafter\ifx\expandafter\expandafter\expandafter\@empty\expandafter\@xs@beforespace\detokenize\expandafter{\@xs@argument} \@xs@nil\@empty% #1 commence par un espace ? - \expandafter\@xs@ifempty\expandafter{\@xs@argument}% - {\let#2\@empty} - {\afterassignment\@xs@testsecondtoken% après avoir mangé le 1er token, on va tester si la suite commence par «{» - \expandafter\let\expandafter\@xs@secontoken\expandafter=\expandafter\@sptoken\@xs@argument\@xs@@nil\@xs@nil% on mange le 1er token et on rajoute \@xs@@nil à la fin pour éviter de perdre les accolades du groupe - {\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2% - \expandafter\expandafter\expandafter{\expandafter\@xs@gobblespacebeforebrace\@xs@argument}}% - {\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2% - \expandafter\expandafter\expandafter{\expandafter\@xs@behindspace\@xs@argument\@xs@nil}}% - }% - \else - \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#2% - \expandafter\expandafter\expandafter{\expandafter\@gobble\@xs@argument}% - \fi -} - -% Macros \`a arguments d\'elimit\'es pour les macros ci dessus -\long\def\@xs@beforespace#1 #2\@xs@nil{#1} - -\long\def\@xs@behindspace#1 #2\@xs@nil{#2} - -\long\def\@xs@returnfirstsyntaxunit@ii#1#2\@xs@nil{#1} - -\long\def\@xs@gobbleall#1\@xs@nil{} - -% Cette macro interne est utilis\'ee dans les macros \'etoil\'ees pour : -% 1) d\'evelopper l'argument selon qu'on a choisit \fullexpandarg -% ou \normalexpandarg, et ceci \`a l'aide de la macro \@xs@def -% 2) Ensuite, on d\'etokenize ce d\'eveloppement de façon n'avoir plus que -% des catcodes de 10 pour les espaces et 12 pour le reste. -\long\def\@xs@expand@and@detokenize#1#2{% - \long\def#1{#2}% - \expandafter\edef\expandafter#1\expandafter{\@xs@expand#1}% on d\'eveloppe #2 selon le mode de d\'eveloppement - \long\edef#1{\detokenize\expandafter{#1}}% puis on d\'etokenize et on assigne \`a #1 -} - -\long\def\@xs@expand@and@assign#1#2{\@xs@def#1{#2}}% on d\'eveloppe #2 selon \fullexpandarg ou \normalexpandarg - -\long\def\@xs@edefaddtomacro#1#2{\edef#1{\unexpanded\expandafter{#1}#2}} - -\long\def\@xs@addtomacro#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} - -\def\@xs@argstring{0########1########2########3########4########5########6########7########8########9} - -% \@xs@DefArg{3} met dans la sc \@xs@myarg les tokens "####1####2####3" -\def\@xs@DefArg#1{\def\@xs@defarg0##1#1##2\@xs@nil{\def\@xs@myarg{##1#1}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil} - -% \@xs@DefArg@{3} met dans la sc \@xs@myarg les tokens "[####1]####2####3####4" -\def\@xs@DefArg@#1{\expandafter\@xs@defarg@\expandafter{\number\numexpr#1+1}} - -\def\@xs@defarg@#1{\def\@xs@defarg0##11##2#1##3\@xs@nil{\def\@xs@myarg{[##11]##2#1}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil} - -% \@xs@OneArg{3} met dans la sc \@xs@myarg les tokens "####3" -\def\@xs@OneArg#1{\expandafter\@xs@onearg\expandafter{\number\numexpr#1-1}{#1}} - -\def\@xs@onearg#1#2{\def\@xs@defarg##1#1##2#2##3\@xs@nil{\def\@xs@myarg{##2#2}}\expandafter\@xs@defarg\@xs@argstring\@xs@nil} - -% #1 : num\'ero du 1er argument; #2 : nombre de lignes; #3 argument optionnel; #4 : dernier num\'ero de l'argument devant être d\'etokenis\'e si \'etoile -\def\@xs@BuildLines#1#2#3#4{% - \let\@xs@newlines\@empty - \let\@xs@newargs\@empty - \def\@xs@buildlines##1{% - \expandafter\@xs@OneArg\expandafter{\number\numexpr##1+#1-1}% - \edef\@xs@reserved@B{\noexpand\@xs@expand\csname @xs@arg@\romannumeral\numexpr##1\endcsname}% - \ifnum##1=\@ne% si c'est le premier argument - \@xs@ifempty{#3}% - {\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}% - \edef\@xs@reserved@B{\ifnum##1>#4 @xs@def\else @xs@assign\fi}% - }% et s'il y a un argument optionnel alors, on met des crochets - {\expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter[\@xs@reserved@B]}% - \def\@xs@reserved@B{@xs@def}% ne pas d\'etok\'eniser l'argument optionnel grace au \@xs@def - } - \else - \expandafter\@xs@addtomacro\expandafter\@xs@newargs\expandafter{\expandafter{\@xs@reserved@B}}% - \edef\@xs@reserved@B{\ifnum##1>#4 @xs@def\else @xs@assign\fi}% - \fi - \edef\@xs@newlines{\unexpanded\expandafter{\@xs@newlines}\expandafter\noexpand\csname\@xs@reserved@B\endcsname\expandafter\noexpand\csname @xs@arg@\romannumeral\numexpr##1\endcsname{\@xs@myarg}}% - \ifnum##1<#2\relax - \def\@xs@next{\expandafter\@xs@buildlines\expandafter{\number\numexpr##1+1}}% - \expandafter\@xs@next - \fi}% - \@xs@buildlines\@ne -} - -\def\@xs@newmacro{% - \@ifstar - {\let\@xs@reserved@D\@empty\@xs@newmacro@} - {\let\@xs@reserved@D\relax\@xs@newmacro@0}% -} - -% #1 : dernier num\'ero de l'argument devant être d\'etokenis\'e -% #2 : nom de la macro publique -% #3 : argument optionnel (vide si pas d'arg optionnel) -% #4 : nombre d'arguments obligatoires -% #5 : utilisation de testopt (1 si oui, 0 si non) -% #6 : code de la macro -\def\@xs@newmacro@#1#2#3#4#5{% - \edef\@xs@reserved@A{@xs@\expandafter\@gobble\string#2}% - \edef\@xs@reserved@C{\expandafter\noexpand\csname\@xs@reserved@A @\ifx\@empty#3\@empty @\fi\endcsname}% - \edef\@xs@reserved@B{% - \ifx\@empty\@xs@reserved@D - \def\noexpand#2{\noexpand\@ifstar - {\let\noexpand\@xs@assign\noexpand\@xs@expand@and@detokenize\expandafter\noexpand\@xs@reserved@C}% - {\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}% - }% - \else - \def\noexpand#2{\let\noexpand\@xs@assign\noexpand\@xs@expand@and@assign\expandafter\noexpand\@xs@reserved@C}% - \fi - \ifx\@empty#3\@empty - \else - \def\expandafter\noexpand\@xs@reserved@C{% - \noexpand\@testopt{\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname}{\ifx\@xs@def\@xs@ledef#3\else\unexpanded{#3}\fi}}% - \fi - }% - % Que fait \@xs@reserved@B ? Il d\'efinit : - % si #3 est vide : \NOM{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@NOM@@}{\let\@xs@assign\@xs@expand@and@assign\@xs@NOM@@}} - % si #3 existe : \NOM{\@ifstar{\let\@xs@assign\@xs@expand@and@detokenize\@xs@NOM@}{\let\@xs@assign\@xs@expand@and@assign\@xs@NOM@}} - % \@xs@NOM@{\@testopt{\@xs@NOM@@}{#3}}} - \long\@xs@reserved@B - \ifx\@empty#3\@empty - \@xs@BuildLines1{#4}{#3}{#1}% - \@xs@DefArg{#4}% - \else - \expandafter\@xs@BuildLines\expandafter1\expandafter{\number\numexpr#4+1}{#3}{#1}% - \@xs@DefArg@{#4}% - \fi - \edef\@xs@reserved@B{\def\expandafter\noexpand\csname\@xs@reserved@A @@\endcsname\@xs@myarg}% - \edef\@xs@reserved@C{\unexpanded\expandafter{\@xs@newlines}\edef\noexpand\@xs@call}% - \edef\@xs@reserved@D{% - \noexpand\noexpand\expandafter\noexpand\csname\@xs@reserved@A\endcsname\unexpanded\expandafter{\@xs@newargs}% - }% - \ifnum#5=\@ne\edef\@xs@reserved@D{\noexpand\noexpand\noexpand\@testopt{\unexpanded\expandafter{\@xs@reserved@D}}{}}\fi - \@xs@edefaddtomacro\@xs@reserved@C{{\unexpanded\expandafter{\@xs@reserved@D}}\noexpand\@xs@call}% - \@xs@edefaddtomacro\@xs@reserved@B{{\unexpanded\expandafter{\@xs@reserved@C}}}% - % Que fait \@xs@reserved@B ? Il d\'efinit par exemple pour 3 arguments obligatoires et 1 facultatif : - % \def\@xs@NOM@@[##2]##3##4##5{% - % \@xs@def\@xs@arg@i{##2}\@xs@assign\@xs@arg@ii{##3}\@xs@assign\@xs@arg@iii{##4}\@xs@asign\@xs@arg@iv{##5}% - % si #5=0: \edef\@xs@call{\noexpand\@xs@NOM[\@xs@expand\@xs@arg@i]{\@xs@expand\@xs@arg@ii}{\@xs@expand\@xs@arg@iii}{\@xs@expand\@xs@arg@iv}}% - % si #5=1: \edef\@xs@call{\noexpand\@testopt{\noexpand\@xs@NOM[\@xs@expand\@xs@arg@i]{\@xs@expand\@xs@arg@i}{\@xs@expand\@xs@arg@ii}{\@xs@expand\@xs@arg@iii}{\@xs@expand\@xs@arg@iv}}{}}% - % \@xs@call} - \long\@xs@reserved@B - \edef\@xs@reserved@B{% - \def\expandafter\noexpand\csname\@xs@reserved@A\endcsname - \@xs@myarg\ifnum#5=\@ne[\unexpanded{##}\number\numexpr\ifx\@empty#3\@empty#4+1\else#4+2\fi]\fi - }% - % Que fait \@xs@reserved@B ? Il d\'efinit par exemple pour 3 arguments obligatoires et 1 facultatif : - % \def \@xs@NOM[##2]##3##4##5[##6]{#6} - \long\@xs@reserved@B -} - -% macro g\'en\'erique qui lit \@xs@reserved@C us par us -% 3 sous-routines sont appel\'ees \`a des moments cl\'e : -% \@xs@atendofgroup (un groupe se finit, appel r\'ecursif) -% \@xs@atbegingroup (un groupe vient d'être ouvert) -% \@xs@atnextsyntaxunit (la future US n'est pas un groupe) -\def\@xs@read@reserved@C{% - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\ifnum\@xs@nestlevel=\z@ - \let\@xs@next\relax - \else - \let\@xs@next\@xs@atendofgroup - \fi - } - {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C - \let\@xs@next\@xs@read@reserved@C - \@xs@exploregroups - \ifx\bgroup\@xs@toks - \advance\integerpart\@ne - \begingroup - \expandafter\def\expandafter\@xs@reserved@C\@xs@reserved@A - \@xs@manage@groupID - \let\@xs@nestlevel\@ne - \integerpart\z@ - \@xs@atbegingroup - \else - \global\advance\decimalpart\@ne - \@xs@atnextsyntaxunit - \fi - }% - \@xs@next -} - -% macro g\'en\'erique qui lit \@xs@reserved@D en proc\'edant \`a des tests avec \IfBeginWith -% 2 sous-routines sont appel\'ees \`a des moments cl\'e : -% \@xs@atendofgroup (un groupe se finit, appel r\'ecursif) -% \@xs@atoccurfound (une occurrence a \'et\'e trouv\'ee) -\def\@xs@read@reserved@D{% - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}% - {\ifnum\@xs@nestlevel=\z@ - \let\@xs@next\relax - \else - \let\@xs@next\@xs@atendofgroup - \fi - }% - {\expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter - {\expandafter\@xs@reserved@D\expandafter}\expandafter{\@xs@reserved@E}% - {\global\advance\decimalpart\@ne - \let\@xs@reserved@D\@xs@reserved@A - \@xs@atoccurfound - }% - {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@A - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@D - \let\@xs@next\@xs@read@reserved@D - \@xs@exploregroups - \ifx\bgroup\@xs@toks - \advance\integerpart\@ne - \begingroup - \expandafter\def\expandafter\@xs@reserved@D\@xs@reserved@A - \@xs@manage@groupID - \let\@xs@reserved@C\@empty - \let\@xs@nestlevel\@ne - \integerpart\z@ - \else - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}% - \fi - }% - }% - \@xs@next -} - -\@xs@newmacro\StrRemoveBraces{}{1}{1}{% - \def\@xs@reserved@C{#1}% - \let\@xs@reserved@B\@empty - \let\@xs@nestlevel\z@ - \@xs@StrRemoveBraces@i - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#2}% -} - -\def\@xs@StrRemoveBraces@i{% - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\ifnum\@xs@nestlevel=\z@ - \let\@xs@next\relax - \else - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@B}% - \let\@xs@next\@xs@StrRemoveBraces@i - \fi - } - {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C - \let\@xs@next\@xs@StrRemoveBraces@i - \ifx\bgroup\@xs@toks - \ifx\@xs@exploregroups\relax% on explore les groupes ? - \begingroup - \expandafter\def\expandafter\@xs@reserved@C\@xs@reserved@A - \let\@xs@nestlevel\@ne - \integerpart\z@ - \let\@xs@reserved@B\@empty - \else - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\@xs@reserved@A - \fi - \else - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@A}% - \fi - }% - \@xs@next -} - -% \@xs@cutafteroccur coupe l'argument #1 apr\`es la #3\`eme occurrence de #2 -% \@xs@reserved@C : contient ce qui se trouve avant cette occurrence -% \@xs@reserved@D : contient ce qui se trouve avant cette occurrence y compris cette occurrence -% \@xs@reserved@E : contient ce qui se trouve apr\`es l'occurrence -% si l'occurrence n'existe pas ou qu'un des arguments est vide, toutes les chaines renvoy\'ees sont vides -\long\def\@xs@cutafteroccur#1#2#3{% - \ifnum#3<\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi - {\let\@xs@reserved@C\@empty - \let\@xs@reserved@E\@empty - \global\let\groupID\@empty - } - {\@xs@cutafteroccur@i{#1}{#2}{#3}}% -} - -\long\def\@xs@cutafteroccur@i#1#2#3{% - \def\@xs@reserved@D{#1}\let\@xs@reserved@C\@empty\def\@xs@reserved@E{#2}% - \decimalpart\z@ - \integerpart\z@ - \gdef\groupID{0}% - \let\@xs@nestlevel\z@ - \def\@xs@atendofgroup{% - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% - \@xs@read@reserved@D}% - \def\@xs@atoccurfound{% - \ifnum\decimalpart=\numexpr(#3)\relax - \global\let\@xs@reserved@D\@xs@reserved@D - \global\let\@xs@reserved@C\@xs@reserved@C - \@xs@exitallgroups - \let\@xs@next\relax - \else - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@E}% - \let\@xs@next\@xs@read@reserved@D - \fi}% - \@xs@read@reserved@D - \def\@xs@argument@A{#2}% - \ifnum\decimalpart=\numexpr(#3)\relax % occurrence trouv\'ee ? - \let\@xs@reserved@E\@xs@reserved@D - \expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\@xs@reserved@D\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\@xs@argument@A}% - \else - \let\@xs@reserved@C\@empty - \let\@xs@reserved@E\@empty - \global\let\groupID\@empty - \fi -} - -\@xs@newmacro*3\IfSubStr{1}{2}{0}{% - \def\@xs@argument@A{#2}\def\@xs@argument@B{#3}% - \expandafter\expandafter\expandafter\@xs@cutafteroccur - \expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter{\@xs@argument@B}{#1}% - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}% - \@secondoftwo - \@firstoftwo -} - -\@xs@newmacro*2\IfBeginWith{}{2}{0}{% - \def\@xs@argument@A{#1}\def\@xs@argument@B{#2}% - \expandafter\@xs@ifempty\expandafter{\@xs@argument@B}% - {\let\@xs@next\@secondoftwo - } - {\def\@xs@next{% - \expandafter\expandafter\expandafter\@xs@IfBeginWith@i\expandafter\expandafter\expandafter - {\expandafter\@xs@argument@A\expandafter}\expandafter - {\@xs@argument@B}}% - }% - \@xs@next -} - -\long\def\@xs@IfBeginWith@i#1#2{% - \def\@xs@argument@A{#1}\def\@xs@argument@B{#2}% - \expandafter\@xs@ifempty\expandafter{\@xs@argument@B}% - {\let\@xs@next\@firstoftwo% #2 est vide, tous les tests sont pass\'es avec succ\`es : on renvoie #3 - } - {\expandafter\@xs@ifempty\expandafter{\@xs@argument@A}% - {\let\@xs@next\@secondoftwo% #1 est vide, c'est que #2 est + long que #1 : on renvoie #4 - } - {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A - \ifx\@xs@reserved@A\@xs@reserved@B% il y a \'egalit\'e... - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@B}\@xs@reserved@B - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A% on enl\`eve les 1ere unit\'es syntaxiques - \def\@xs@next{% et on recommence avec ces arguments racourcis d'1 unit\'e syntaxique - \expandafter\expandafter\expandafter\@xs@IfBeginWith@i - \expandafter\expandafter\expandafter{\expandafter\@xs@reserved@A\expandafter}\expandafter{\@xs@reserved@B}}% - \else - \let\@xs@next\@secondoftwo - \fi - }% - }% - \@xs@next -} - -\@xs@newmacro*2\IfEndWith{}{2}{0}{% - \def\@xs@argument@A{#1}\def\@xs@argument@B{#2}% - \@xs@ifempty{#2}% - {\let\@xs@reserved@A\@secondoftwo - } - {\expandafter\expandafter\expandafter\@xs@StrCount - \expandafter\expandafter\expandafter{\expandafter\@xs@argument@A\expandafter}\expandafter - {\@xs@argument@B}[\@xs@reserved@A]% - \ifnum\@xs@reserved@A=\z@ - \let\@xs@reserved@A\@secondoftwo - \else - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\let\@xs@reserved@A\@firstoftwo} - {\let\@xs@reserved@A\@secondoftwo}% - \fi - }% - \@xs@reserved@A -} - -\@xs@newmacro*4\IfSubStrBefore{1,1}{3}{0}{\@xs@IfSubStrBefore@i[#1]{#2}{#3}{#4}} - -\def\@xs@IfSubStrBefore@i[#1,#2]#3#4#5{% - \def\@xs@reserved@C{#3}% - \ifx\@xs@exploregroups\relax% si on explore les groupes - \let\@xs@reserved@B\@empty - \let\@xs@nestlevel\z@ - \@xs@StrRemoveBraces@i% on retire les accolades - \let\@xs@reserved@C\@xs@reserved@B - \fi - \def\@xs@reserved@A{#5}% - \expandafter\expandafter\expandafter\@xs@cutafteroccur\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@A}{#2}% - \def\@xs@reserved@A{#4}% - \expandafter\expandafter\expandafter\@xs@cutafteroccur\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@A}{#1}% - \global\let\groupID\@empty - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - \@secondoftwo - \@firstoftwo -} - -\@xs@newmacro*4\IfSubStrBehind{1,1}{3}{0}{\@xs@IfSubStrBehind@i[#1]{#2}{#3}{#4}} - -\long\def\@xs@IfSubStrBehind@i[#1,#2]#3#4#5{\@xs@IfSubStrBefore@i[#2,#1]{#3}{#5}{#4}} - -\long\def\@xs@formatnumber#1#2{% - \def\@xs@argument@A{#1}% - \@xs@ifempty{#1}% - {\def#2{0X}% si vide, renvoie 0X - } - {\@xs@returnfirstsyntaxunit{#1}\@xs@reserved@A - \def\@xs@reserved@B{+}% - \ifx\@xs@reserved@A\@xs@reserved@B - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@C - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\def#2{+0X}} - {\expandafter\def\expandafter#2\expandafter{\expandafter+\expandafter0\@xs@reserved@C}}% - \else - \def\@xs@reserved@B{-}% - \ifx\@xs@reserved@A\@xs@reserved@B - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@argument@A}\@xs@reserved@A - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@A}% - {\def#2{-0X}}% - {\expandafter\def\expandafter#2\expandafter{\expandafter-\expandafter0\@xs@reserved@A}}% - \else - \expandafter\def\expandafter#2\expandafter{\expandafter0\@xs@argument@A}% - \fi - \fi - }% -} - -\@xs@newmacro\IfInteger{}{1}{0}{% - \@xs@formatnumber{#1}\@xs@reserved@A - \decimalpart\z@ - \afterassignment\@xs@defafterinteger\integerpart\@xs@reserved@A\relax\@xs@nil - \let\@xs@after@intpart\@xs@afterinteger - \expandafter\@xs@testdot\@xs@afterinteger\@xs@nil - \ifx\@empty\@xs@afterdecimal - \ifnum\decimalpart=\z@ - \let\@xs@next\@firstoftwo% partie décimale constituée de 0 --> seul cas où on renvoie vrai - \else - \let\@xs@afterinteger\@xs@after@intpart - \let\@xs@next\@secondoftwo - \fi - \else - \let\@xs@afterinteger\@xs@after@intpart - \let\@xs@next\@secondoftwo - \fi - \@xs@next -} - -\@xs@newmacro\IfDecimal{}{1}{0}{% - \@xs@formatnumber{#1}\@xs@reserved@A - \decimalpart\z@ - \afterassignment\@xs@defafterinteger\integerpart\@xs@reserved@A\relax\@xs@nil - \expandafter\@xs@testdot\@xs@afterinteger\@xs@nil - \ifx\@empty\@xs@afterdecimal - \expandafter\@firstoftwo - \else - \expandafter\@secondoftwo - \fi -} - -\long\def\@xs@defafterinteger#1\relax\@xs@nil{\def\@xs@afterinteger{#1}} - -\def\@xs@testdot{% - \let\xs@decsep\@empty - \@ifnextchar.% - {\def\xs@decsep{.}\@xs@readdecimalpart}% - {\@xs@testcomma}% -} - -\def\@xs@testcomma{% - \@ifnextchar,% - {\def\xs@dessep{,}\@xs@readdecimalpart}% - {\@xs@endnumber}% -} - -\long\def\@xs@readdecimalpart#1#2\@xs@nil{% - \ifx\@empty#2\@empty - \def\@xs@reserved@A{0X}% - \else - \def\@xs@reserved@A{0#2}% - \fi - \afterassignment\@xs@defafterinteger\decimalpart\@xs@reserved@A\relax\@xs@nil - \expandafter\@xs@endnumber\@xs@afterinteger\@xs@nil -} - -\long\def\@xs@endnumber#1\@xs@nil{\def\@xs@afterdecimal{#1}} - -% test d'\'egalit\'e sur des chaines (et des chaines contenant des nombres) -\long\def\@xs@IfStrEqFalse@i#1#2{\let\@xs@reserved@A\@secondoftwo} -\long\def\@xs@IfStrEqFalse@ii#1#2{% renvoie vrai si les 2 arg sont d\'ecimaux et s'ils sont \'egaux, faux sinon - \@xs@IfDecimal{#1}% - {\@xs@IfDecimal{#2}% - {\ifdim#1pt=#2pt - \let\@xs@reserved@A\@firstoftwo - \else - \let\@xs@reserved@A\@secondoftwo - \fi% les 2 sont d\'ecimaux : on fait le test - }% - {\let\@xs@reserved@A\@secondoftwo}% un seul est d\'ecimal - }% - {\let\@xs@reserved@A\@secondoftwo}% #1 n'est pas d\'ecimal -} - -\long\def\@xs@TestEqual#1#2{% teste si les 2 arguments sont \'egaux - \def\@xs@reserved@A{#1}\def\@xs@reserved@B{#2}% - \ifx\@xs@reserved@A\@xs@reserved@B - \let\@xs@reserved@A\@firstoftwo% \'egalit\'e parfaite des 2 chaines - \else - \expandafter\expandafter\expandafter\@xs@reserved@D\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@A\expandafter}\expandafter{\@xs@reserved@B}% - \fi - \@xs@reserved@A -} - -\@xs@newmacro*2\IfStrEq{}{2}{0}{% teste si les deux chaines sont \'egales - \let\@xs@reserved@D\@xs@IfStrEqFalse@i - \@xs@TestEqual{#1}{#2}% -} - -\@xs@newmacro*2\IfEq{}{2}{0}{% teste si les 2 arguments (chaine ou nombre) sont \'egaux - \let\@xs@reserved@D\@xs@IfStrEqFalse@ii - \@xs@TestEqual{#1}{#2}% -} - -\def\IfStrEqCase{% - \@ifstar - {\def\@xs@reserved@E{\IfStrEq*}\@xs@IfStrCase}% - {\def\@xs@reserved@E{\IfStrEq}\@xs@IfStrCase}% -} - -\long\def\@xs@IfStrCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}} - -\def\IfEqCase{% - \@ifstar - {\def\@xs@reserved@E{\IfEq*}\@xs@IfEqCase}% - {\def\@xs@reserved@E{\IfEq}\@xs@IfEqCase}% -} - -\long\def\@xs@IfEqCase#1#2{\@testopt{\@xs@IfStringCase{#1}{#2}}{}} - -\long\def\@xs@IfStringCase#1#2[#3]{% - \long\def\@xs@testcase##1##2##3\@xs@nil{% lit les 2 premieres unit\'es syntaxiques dans ##1 et ##2. Les autres dans ##3 - \@xs@reserved@E{#1}{##1}% - {##2}% le test est positif, on ex\'ecute le code correspondant - {\@xs@ifempty{##3}% - {#3}% s'il n'y a plus de cas, on ex\'ecute le code - {\@xs@testcase##3\@xs@nil}% sinon, on recommence avec ce qui reste - }% - }% - \@xs@testcase#2\@xs@nil -} - -% Renvoie ce qui est \`a gauche de l'occurence n°#1 de la sous chaine #3 dans la chaine #2 -\@xs@newmacro*3\StrBefore{1}{2}{1}{% - \@xs@cutafteroccur{#2}{#3}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}% -} - -% Renvoie ce qui est \`a droite de l'occurence n°#1 de la sous chaine #3 dans la chaine #2 -\@xs@newmacro*3\StrBehind{1}{2}{1}{% - \@xs@cutafteroccur{#2}{#3}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#4}% -} - -% Renvoie ce qui est strictement compris entre les occurrences n°#1 et n°#2 -% des chaines #4 et #5 dans la chaine #3 -\@xs@newmacro*4\StrBetween{1,1}{3}{1}{\@xs@StrBetween@i[#1]{#2}{#3}{#4}[#5]} - -\long\def\@xs@StrBetween@i[#1,#2]#3#4#5[#6]{% - \begingroup - \noexploregroups - \@xs@cutafteroccur{#3}{#5}{#2}% - \expandafter\@xs@cutafteroccur\expandafter{\@xs@reserved@C}{#4}{#1}% - \expandafter - \endgroup - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@E}{#6}% - \global\let\groupID\@empty -} - -\def\exploregroups{\let\@xs@exploregroups\relax} - -\def\noexploregroups{\def\@xs@exploregroups{\let\@xs@toks0\relax}} - -\def\saveexploremode{\let\@xs@saveexploremode\@xs@exploregroups} - -\def\restoreexploremode{\let\@xs@exploregroups\@xs@saveexploremode} - -% Remplace les #1 premi\`eres occurences de la chaine #3 -% par la chaine #4 dans la chaine #2 -\@xs@newmacro\StrSubstitute{0}{3}{1}{% - \def\@xs@reserved@D{#2}\let\@xs@reserved@C\@empty\def\@xs@reserved@E{#3}% - \def\@xs@argument@C{#3}\def\@xs@argument@D{#4}% - \decimalpart\z@ - \integerpart\z@ - \gdef\groupID{0}% - \let\@xs@nestlevel\z@ - \def\@xs@atendofgroup{% - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% - \@xs@read@reserved@D - }% - \def\@xs@atoccurfound{% - \ifnum#1<\@ne - \let\@xs@reserved@A\@xs@argument@D - \else - \ifnum\decimalpart>#1 - \let\@xs@reserved@A\@xs@argument@C - \else - \let\@xs@reserved@A\@xs@argument@D - \fi - \fi - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@A}% - \@xs@read@reserved@D - }% - \@xs@ifempty{#3}% - {\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@D}{#5}% - } - {\@xs@read@reserved@D - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#5}% - }% -} - -% Supprime les #1 premi\`eres occurrences de #3 dans #2 -\@xs@newmacro\StrDel{0}{2}{1}{\@xs@StrSubstitute[#1]{#2}{#3}{}[#4]} - -\def\@xs@exitallgroups{\ifnum\@xs@nestlevel>\z@\endgroup\expandafter\@xs@exitallgroups\fi} - -% Compte combien d'unit\'es syntaxiques contient la chaine #1 ? -\@xs@newmacro\StrLen{}{1}{1}{% - \def\@xs@reserved@C{#1}% - \decimalpart\z@ - \let\@xs@nestlevel\z@ - \gdef\groupID{0}% - \let\@xs@atbegingroup\relax - \def\@xs@atendofgroup{\endgroup\@xs@read@reserved@C}% - \let\@xs@atnextsyntaxunit\relax - \@xs@read@reserved@C - \expandafter\@xs@ReturnResult\expandafter{\number\decimalpart}{#2}% -} - -% Macro interne fermant autant de groupes que n\'ecessaire pour trouver une unit\'e syntaxique derri\`ere -\def\@xs@continuetonext{% - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\ifnum\@xs@nestlevel>\z@ - \expandafter\endgroup\expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% on concat\`ene - \expandafter\expandafter\expandafter\@xs@continuetonext% on recommence - \fi} - \relax -}% - -\def\@xs@manage@groupID{% - \begingroup\def\@xs@reserved@A{0}% - \ifx\@xs@reserved@A\groupID% si on arrive du groupe de niveau 0 - \endgroup - \xdef\groupID{\number\integerpart}% on met simplement le niveau - \else - \endgroup - \expandafter\expandafter\expandafter\gdef\expandafter\expandafter\expandafter\groupID\expandafter\expandafter\expandafter{\expandafter\groupID\expandafter,\number\integerpart}% - \fi -} - -% Cette macro coupe la chaine #1 apr\`es l'unit\'e syntaxique n°#2 -\def\StrSplit{% - \@ifstar - {\let\@xs@reserved@E\@xs@continuetonext\StrSpl@t}% - {\let\@xs@reserved@E\relax\StrSpl@t}% -} - -\@xs@newmacro\StrSpl@t{}{2}{0}{\@xs@StrSplit@i{#2}{#1}\@xs@StrSplit@ii} - -% Cette macro interne coupe la chaine #2 apr\`es l'unit\'e syntaxique n°#1 -% Le d\'ebut est assign\'e dans \@xs@reserved@B et la fin dans \@xs@reserved@C -\long\def\@xs@StrSplit@i#1#2{% - \def\@xs@reserved@D{#1}% - \def\@xs@reserved@C{#2}% - \let\@xs@reserved@B\@empty - \global\let\groupID\@empty - \ifnum#1>\z@ - \decimalpart\z@ - \integerpart\z@ - \gdef\groupID{0}% - \let\@xs@nestlevel\z@ - \def\@xs@atendofgroup{% - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% - \@xs@read@reserved@C - }% - \def\@xs@atbegingroup{\let\@xs@reserved@B\@empty}% - \def\@xs@atnextsyntaxunit{% - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\@xs@reserved@A}% - \ifnum\decimalpart=\@xs@reserved@D\relax - \ifx\@xs@reserved@C\@empty\@xs@reserved@E\fi - \global\let\@xs@reserved@B\@xs@reserved@B - \global\let\@xs@reserved@C\@xs@reserved@C - \@xs@exitallgroups - \let\@xs@next\relax - \fi - }% - \@xs@read@reserved@C - \fi -} - -\def\@xs@StrSplit@ii#1#2{\let#1\@xs@reserved@B\let#2\@xs@reserved@C} - -% StrCut[n]{}{}\macroA\macroB -% \macroA reçoit ce qui se trouve avant la n ème occurrence dans -% \macroB reçoit ce qui est après cette n ème occurrence -\@xs@newmacro*3\StrCut{1}{2}{0}{% - \@xs@ifempty{#3}% - {\global\let\groupID\@empty - \let\@xs@reserved@C\@empty - \let\@xs@reserved@E\@empty - } - {\ifnum#1<\@ne\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi - {\@xs@StrCut@ii{#2}{#3}1} - {\@xs@StrCut@ii{#2}{#3}{#1}}% - }% - \@xs@StrCut@iii -} - -\long\def\@xs@StrCut@ii#1#2#3{% - \def\@xs@reserved@D{#1}% - \let\@xs@reserved@C\@empty - \def\@xs@reserved@E{#2}% - \decimalpart\z@\integerpart\z@ - \gdef\groupID{0}% - \let\@xs@nestlevel\z@ - \def\@xs@atendofgroup{% - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% - \@xs@read@reserved@D - }% - \def\@xs@atoccurfound{% - \ifnum\decimalpart=\numexpr(#3)\relax - \global\let\@xs@reserved@D\@xs@reserved@D - \global\let\@xs@reserved@C\@xs@reserved@C - \@xs@exitallgroups - \let\@xs@next\relax - \else - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\@xs@reserved@E}% - \let\@xs@next\@xs@read@reserved@D - \fi - }% - \@xs@read@reserved@D - \def\@xs@argument@A{#2}% - \let\@xs@reserved@E\@xs@reserved@D - \expandafter\expandafter\expandafter - \def - \expandafter\expandafter\expandafter - \@xs@reserved@D - \expandafter\expandafter\expandafter - {\expandafter\@xs@reserved@C\@xs@argument@A}% -} - -\long\def\@xs@StrCut@iii#1#2{\let#1\@xs@reserved@C\let#2\@xs@reserved@E} - -% De la chaine #1, renvoie ce qui se trouve entre les positions -% #2 et #3, unit\'es syntaxiques aux positions compris ! -\@xs@newmacro\StrMid{}{3}{1}{% - \begingroup - \noexploregroups - \let\@xs@reserved@E\relax - \@xs@StrSplit@i{#3}{#1}% - \edef\@xs@reserved@C{\number\numexpr#2-1}% - \let\@xs@reserved@E\relax - \expandafter\expandafter\expandafter\@xs@StrSplit@i\expandafter\expandafter\expandafter{\expandafter\@xs@reserved@C\expandafter}\expandafter{\@xs@reserved@B}% - \expandafter\endgroup - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#4}% - \global\let\groupID\@empty -} - -% supprime #2 unit\'es syntaxiques \`a gauche dans la chaine #1 -\@xs@newmacro\StrGobbleLeft{}{2}{1}{% - \let\@xs@reserved@E\relax - \@xs@StrSplit@i{#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}% -} - -% extrait de #1 la chaine \`a gauche de longueur #2 -\@xs@newmacro\StrLeft{}{2}{1}{% - \let\@xs@reserved@E\relax - \@xs@StrSplit@i{#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}% -} - -% supprime #2 unit\'es syntaxiques \`a droite dans la chaine #1 -\@xs@newmacro\StrGobbleRight{}{2}{1}{% - \@xs@StrLen{#1}[\@xs@reserved@D]% - \let\@xs@reserved@E\relax - \expandafter\@xs@StrSplit@i\expandafter{\number\numexpr\@xs@reserved@D-#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}% -} - -% renvoie #2 unit\'es syntaxiques \`a la droite de la chaine #1 -\@xs@newmacro\StrRight{}{2}{1}{% - \@xs@StrLen{#1}[\@xs@reserved@D]% - \let\@xs@reserved@E\relax - \expandafter\@xs@StrSplit@i\expandafter{\number\numexpr\@xs@reserved@D-#2}{#1}% - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@C}{#3}% -} - -\@xs@newmacro\StrChar{}{2}{1}{% - \let\@xs@reserved@B\@empty - \def\@xs@reserved@C{#1}\def\@xs@reserved@D{#2}% - \ifnum#2>\z@ - \def\groupID{0}\let\@xs@nestlevel\z@\integerpart\z@\decimalpart\z@ - \let\@xs@atbegingroup\relax - \def\@xs@atendofgroup{\endgroup\@xs@read@reserved@C}% - \def\@xs@atnextsyntaxunit{% - \ifnum\decimalpart=\@xs@reserved@D% la n i\`eme US est atteinte ? - \global\let\@xs@reserved@B\@xs@reserved@A% on capture l'US en cours qui est celle cherch\'ee - \@xs@exitallgroups - \let\@xs@next\relax - \fi - }% - \@xs@read@reserved@C - \fi - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@B}% - {\global\let\groupID\@empty} - \relax - \expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@B}{#3}% -} - -% Combien de fois compte t-on #2 dans #1 ? -\@xs@newmacro\StrCount{}{2}{1}{% - \def\@xs@reserved@D{#1}\def\@xs@reserved@E{#2}\let\@xs@reserved@C\@empty - \@xs@ifempty{#2}% - {\@xs@ReturnResult{0}{#3}} - {\decimalpart\z@ - \integerpart\z@ - \gdef\groupID{0}% - \let\@xs@nestlevel\z@ - \def\@xs@atendofgroup{% - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@C\expandafter{\expandafter{\@xs@reserved@C}}% - \@xs@read@reserved@D - }% - \def\@xs@atoccurfound{\let\@xs@reserved@C\@empty\@xs@read@reserved@D}% - \@xs@read@reserved@D - \expandafter\@xs@ReturnResult\expandafter{\number\decimalpart}{#3}% - }% -} - -% renvoie la position de l'occurrence #1 de la sous chaine #3 dans la chaine #2 -\@xs@newmacro\StrPosition{1}{2}{1}{% - \@xs@cutafteroccur{#2}{#3}{#1}% - \let\@xs@reserved@E\groupID - \ifx\@xs@reserved@C\@xs@reserved@D - \@xs@ReturnResult{0}{#4}% - \let\@xs@reserved@E\@empty - \else - \expandafter\@xs@StrLen\expandafter{\@xs@reserved@C}[\@xs@reserved@C]% - \expandafter\@xs@ReturnResult\expandafter{\number\numexpr\@xs@reserved@C+1}{#4}% - \fi - \global\let\groupID\@xs@reserved@E -} - -\def\comparestrict{\let\@xs@comparecoeff\@ne} - -\def\comparenormal{\let\@xs@comparecoeff\z@} - -\def\savecomparemode{\let\@xs@saved@comparecoeff\@xs@comparecoeff} - -\def\restorecomparemode{\let\@xs@comparecoeff\@xs@saved@comparecoeff} - -% Compare les deux arguments #1 et #2 -% Renvoie 0 s'ils sont \'egaux et renvoie la -% position de la premiere unit\'e syntaxiques diff\'erente sinon -\@xs@newmacro*2\StrCompare{}{2}{1}{% - \def\@xs@reserved@A{#1}% - \def\@xs@reserved@B{#2}% - \ifx\@xs@reserved@B\@xs@reserved@A - \@xs@ReturnResult{0}{#3}% - \else - \def\@xs@next{\@xs@StrCompare@i{#1}{#2}{#3}}% - \expandafter\@xs@next - \fi -} - -\long\def\@xs@StrCompare@i#1#2#3{% - \def\@xs@StrCompare@iii##1{% - \let\@xs@reserved@A\@empty - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\def\@xs@reserved@A{*\@xs@comparecoeff}}% - {\expandafter\@xs@ifempty\expandafter{\@xs@reserved@D}% - {\def\@xs@reserved@A{*\@xs@comparecoeff}} - \relax - }% - \def\@xs@next{% - \expandafter\@xs@ReturnResult\expandafter - {\number\numexpr##1\@xs@reserved@A\relax}{#3}% - }% - }% - \def\@xs@StrCompare@ii##1{% ##1 est la position - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@A - \expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@B - \ifx\@xs@reserved@B\@xs@reserved@A - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@A}% - {\@xs@StrCompare@iii{##1}% les 2 unit\'es syntaxiques sont \'egales, on renvoie la position - } - {\def\@xs@next{\expandafter\@xs@StrCompare@ii\expandafter{\number\numexpr##1+1}}% les 2 unit\'es syntaxiques sont \'egales et non vides, on recommence - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@D}\@xs@reserved@D - }% - \else% les 2 unit\'es syntaxiques sont diff\'erentes : on renvoie la position - \@xs@StrCompare@iii{##1}% - \fi - \@xs@next - }% - \def\@xs@reserved@C{#1}\def\@xs@reserved@D{#2}% - \@xs@StrCompare@ii1% -} - -\@xs@newmacro\StrFindGroup{}{2}{1}{% - \def\@xs@reserved@A{#2}\def\@xs@reserved@B{0}% - \ifx\@xs@reserved@A\@xs@reserved@B - \def\@xs@next{\@xs@ReturnResult{{#1}}{#3}}% - \else - \def\@xs@next{\@xs@StrFindGroup@i{#1}{#2}[#3]}% - \fi - \@xs@next -} - -\long\def\@xs@StrFindGroup@i#1#2[#3]{% - \def\@xs@StrFindGroup@ii{% - \expandafter\@xs@ifempty\expandafter{\@xs@reserved@C}% - {\def\@xs@next{\@xs@ReturnResult{}{#3}}% s'il ne reste plus rien, on renvoie vide - } - {\expandafter\@xs@returnfirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@D - \ifx\bgroup\@xs@toks% si la 1\`ere unit\'e syntaxique est un groupe explicite - \advance\decimalpart\@ne% on augmente le compteur - \ifnum\decimalpart=\@xs@reserved@A% on est au groupe cherch\'e lors de la profondeur courante ? - \ifx\@empty\@xs@reserved@B% on est \`a la profondeur maximale ? - \def\@xs@next{\expandafter\@xs@ReturnResult\expandafter{\@xs@reserved@D}{#3}}% on renvoie ce groupe - \else% sinon - \expandafter\def\expandafter\@xs@next\expandafter{\expandafter\@xs@StrFindGroup@i\@xs@reserved@D}% on recommence avec ce groupe - \expandafter\@xs@addtomacro\expandafter\@xs@next\expandafter{\expandafter{\@xs@reserved@B}[#3]}% et les profondeurs de recherche restantes - \fi - \else - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C - \let\@xs@next\@xs@StrFindGroup@ii - \fi - \else - \expandafter\@xs@removefirstsyntaxunit\expandafter{\@xs@reserved@C}\@xs@reserved@C - \let\@xs@next\@xs@StrFindGroup@ii - \fi - }% - \@xs@next - }% - \@xs@extractgroupnumber{#2}\@xs@reserved@A\@xs@reserved@B - \decimalpart\z@ - \ifnum\@xs@reserved@A>\z@\def\@xs@reserved@C{#1}\else\let\@xs@reserved@C\@empty\fi - \@xs@StrFindGroup@ii -} - -\def\@xs@extractgroupnumber#1#2#3{% - \def\@xs@extractgroupnumber@i##1,##2\@xs@nil{\def#2{##1}\def#3{##2}}% - \@xs@extractgroupnumber@i#1,\@xs@nil - \ifx\@empty#3\else\@xs@extractgroupnumber@i#1\@xs@nil\fi -} - -\def\expandingroups{\let\@xs@expandingroups\exploregroups} - -\def\noexpandingroups{\let\@xs@expandingroups\noexploregroups} - -\def\StrExpand{\@testopt{\@xs@StrExpand}{1}} -\long\def\@xs@StrExpand[#1]#2#3{% - \begingroup - \@xs@expandingroups - \ifnum#1>\z@ - \integerpart#1\relax - \decimalpart\z@ - \gdef\groupID{0}% - \let\@xs@nestlevel\z@ - \def\@xs@atendofgroup{% - \expandafter\endgroup - \expandafter\@xs@addtomacro\expandafter\@xs@reserved@B\expandafter{\expandafter{\@xs@reserved@B}}% - \@xs@read@reserved@C - }% - \def\@xs@atbegingroup{\let\@xs@reserved@B\@empty}% - \def\@xs@atnextsyntaxunit{% - \expandafter\expandafter\expandafter\@xs@addtomacro - \expandafter\expandafter\expandafter\@xs@reserved@B - \expandafter\expandafter\expandafter{\@xs@reserved@A}% - }% - \def\@xs@reserved@C{#2}% - \@xs@StrExpand@i{#1}% Appel de la macro r\'ecursive - \else - \def\@xs@reserved@B{#2}% - \fi - \global\let\@xs@reserved@B\@xs@reserved@B - \endgroup - \let#3\@xs@reserved@B - \global\let\groupID\@empty -} - -\long\def\@xs@StrExpand@i#1{% - \ifnum#1>\z@ - \let\@xs@reserved@B\@empty - \@xs@read@reserved@C - \let\@xs@reserved@C\@xs@reserved@B - \def\@xs@reserved@A{\expandafter\@xs@StrExpand@i\expandafter{\number\numexpr#1-1}}% - \else - \let\@xs@reserved@A\relax - \fi - \@xs@reserved@A -} - -\def\scancs{\@testopt{\@xs@scancs}{1}} -\long\def\@xs@scancs[#1]#2#3{% - \@xs@StrExpand[#1]{#3}{#2}% - \edef#2{\detokenize\expandafter{#2}}% -} - -% Restaure le code de @ -\catcode`\@=\CurrentAtCatcode\relax - -% D\'efinit le d\'elimiteur verb -% d\'efinit les diff\'erents modes et les m\'emorise -\setverbdelim{|}% -\fullexpandarg\saveexpandmode -\comparenormal\savecomparemode -\noexploregroups\saveexploremode -\expandingroups - -\endinput -% -% Historique -%------------------------------------------------------------------------------ -%% v1.0 4/7/2008 : - Package achev\'e. -% 7/7/2008 : - Package publi\'e sur CTAN. -%------------------------------------------------------------------------------ -% v1.1 15/8/2008 -% - Le package ne n\'ecessite plus LaTeX et est d\'esormais utilisable sous -% Plain eTeX. -% - Ajout des macros \IfInteger et \IfDecimal. -% Pour cette derni\`ere, la partie enti\`ere et la partie d\'ecimale sont -% r\'ecup\'erables dans les compteurs \integerpart et \decimalpart. Ce -% qu'il reste apr\`es qu'un caract\`ere non attendu soit rencontr\'e est -% dispo dans \@xs@remainafterdecimal -% - Correction d'un bug dans \tokenize : -% suppression de l'expansion avec \normalexpandarg pour \'eviter le bug -% avec les lettres accentu\'ees dans l'exemple : \tokenize\aa{\'e\`u} -% - Am\'elioration du code de la plupart des macros. -% - \'Ecriture d'une routine \@xs@newmacro d\'efinissant les macros. -% - Suppression de tous les compteurs grace \`a \numexpr. -% - Nouvelles fonctionnalit\'es internes dans : -% \IfSubStr -% ajout des chaines se trouvant avant et apr\`es l'occurrence test\'ee -% dans les sc \@xs@behind@IfSubStr et \@xs@before@IfSubStr -% \StrCount -% a) ajout de ce qui se trouve apr\`es la derni\`ere occurrence dans la -% sc \@xs@StrCount@afterlastocccur -% b) la macro ne d\'epend plus d'aucune autre -%------------------------------------------------------------------------------ -% v1.2 23/8/2008 -% - Am\'elioration du code de \StrMid \StrGobbleLeft, \StrLeft, -% \StrGobbleRight et \StrRight \`a l'aide de la nouvelle macro -% \@xs@StrSplit@i -% - Nouveau test \IfStrEq qui compare 2 chaines -% - Nouveau test \IfEq qui compare 2 chaines (ou 2 nombres si les 2 chaines -% contiennent un nombre) -% - Correction d'un bug dans \@xs@formatnumber. La macro n'envisageait pas le -% cas o\`u son argument \'etait vide ce qui faiasait planter -% \IfDecimal{}{V}{F} et \IfInteger{}{V}{F} -%------------------------------------------------------------------------------ -% v1.3 21/9/2008 -% - Am\'elioration du code, mise en place de r\'ecursivit\'es terminales dans -% toutes les macros r\'ecursives, simplification de \@xs@TestEqual en -% utilisant \ifx -% - Nouvelles macros \IfStrEqCase et \IfEqCase -% Teste si une chaîne est \'egale \`a plusieurs cha\^ines donn\'ee et -% ex\'ecute un code sp\'ecifique -% - Cr\'eation de la macro publique \StrSplit -% Coupe la chaine en 2 \`a une position donn\'ee -% - Nouvelle macro \StrCompare -% Compare 2 chaînes et renvoie la position du 1er caract\`ere diff\'erent. -% Renvoie 0 si elles sont \'egales. -%------------------------------------------------------------------------------ -% v1.3a 29/9/2008 -% - Correction d'un bug : \expandafter#1 -% dans les macros \IfSubStrBefore et \StrBetween qui buggue si #1 est un -% nombre > 9 ! -% - R\'e \'ecriture de \@xs@returnfirstsyntaxunit et \@gobble qui -% deviennent purement d\'eveloppables. -% - R\'e \'ecriture de \StrLen -% - Nouvelle macro interne \@xs@cutafteroccur -% Coupe la chaine apr\`es la ni\`eme occurrence d'une sous chaine. -% - Code am\'elior\'e de \StrMid, \StrLeft, \StrGobbleLeft, \StrRight, -% \StrGobbleRight grace \`a \@xs@cutafteroccur -%------------------------------------------------------------------------------ -% v1.4 4/11/2008 -% - xstring traite ses arguments par unit\'e syntaxique, et donc toutes les -% macros internes ont \'et\'e r\'e-\'ecrites \`a cette fin. -% - Le manuel a \'et\'e r\'e-\'ecrit, rendu plus clair et mieux structur\'e. -% - Nouvelle fonctionnalit\'e : \expandarg -% le 1er lex\`eme de chaque argument est 1-d\'evelopp\'e avant que la -% macro ne soit appel\'ee. Si un argument comporte plus qu'1 lex\`eme, -% il faut passer par \scancs*[1] pour 1-d\'evelopper toutes les unit\'es -% syntaxiques. -% - Correction de 2 erreurs dans le manuel anglais : 0 est la valeur par -% d\'efaut dans \StrSubstitute et \StrDel -% - Coh\'erence dans les nom des s\'equences de contr\^oles temporaires qui -% sont d\'esormais : \@xs@reserved@A \`a \@xs@reserved@E -%------------------------------------------------------------------------------ -% v1.4a 12/11/2008 -% - Correction d'un bug dans \@xs@StrSplit dans le cas o\`u l'argument -% num\'erique est <1 : la 1ere coupure doit être vide et le seconde doit -% être \'egale \`a l'argument. -%------------------------------------------------------------------------------ -% v1.4b 16/11/2008 -% - Correction de 2 bugs dans \@xs@returnfirstsyntaxunit -%------------------------------------------------------------------------------ -% v1.5 31/12/2008 -% - Nouvelles fonctionnalit\'es dans la recherche de groupes par un -% identificateur caract\'erisant leur imbrication. Impl\'ementation de : -% 1) \StrFindGroup -% 2) \groupID -% - Ajout des nouvelles macros g\'en\'eriques \@xs@read@reserved@C et -% \@xs@read@reserved@D -% - Correction d'un bug dans \StrSplit : \StrSplit{{a}bc}{1}[\truc] faisait -% que \truc contenait «a{a}». -% - Correction d'un bug dans \@xs@newmacro : l'argument optionnel \'etait -% d\'etok\'enis\'e \`a tort dans les macros \'etoil\'ees. -% - Dans \@xs@newmacro, on doit choisir le num\'ero du dernier argument devant -% être d\'etok\'enis\'e dans le cas d'une macro \'etoil\'ee (sachant que -% l'argument optionnel ne l'est jamais) -%------------------------------------------------------------------------------ -% v1.5a 09/2/2009 -% - Nouvelle macro \StrExpand, sensible au mode d'exploration. La macro est -% indépendante du mode d'exploration et dispose de ses propres commandes -% d'exploration : \expandingroups et \noexpandingroups -% - R\'e-\'ecriture de \scancs, qui devient triviale puisque d\'ependant de -% \StrExpand. Il n'y a plus de version \'étoil\'ee et d\'esormais, \scancs -% est sensible au mode d'exploration. -% - Correction d'un bug dans \IfInteger : \IfInteger{2.0}{V}{F} affichait F -% - Correction de bugs : mettre \let\@xs@reserved@E\relax avant d'appeler -% \@xs@StrSplit@i -% - Suppression des messages d'erreur, de warning et d'info. xstring devient -% donc silencieux ;) -% - Passage de 3 \'a 2 compteurs -% - Le manuel est d\'esormais plus color\'e, en esp\'erant qu'il sera un peu -% plus agr\'eable \`a lire ! -%------------------------------------------------------------------------------ -% v1.5b 13/3/2009 -% - Modification d'un grand nombre de macros de telle sorte que vraiment -% n'importe quel code peut d\'esormais \^etre plac\'e dans les arguments des -% macros (comme par exemple des \if, \ifx ou autre, m\^eme sans leur \fi, ce -% qui n'\'etait pas possible jusqu'alors) -%------------------------------------------------------------------------------ -% v1.5c 05/6/2009 -% - Correction d'un bug dans \IfBeginWith : il faut appeler -% \@xs@returnfirstsyntaxunit pour l'argument #2 puis pour l'argument #1 et -% non pas l'inverse pour que \@xs@toks reflète ce qui se trouve dans #1 -% - Correction d'un bug dans \@xs@returnfirstsyntaxunit au cas où #1 commence -% par un espace : mettre \@xs@toks à 0 -% - Correction d'un bug dans \@xs@returnfirstsyntaxunit : -% \@xs@returnfirstsyntaxunit{{}}\truc -% faisait que \truc se développait en un espace. -% - Correction d'un bug dans \@xs@removefirstsyntaxunit où le cas -% \@xs@removefirstsyntaxunit{ {b}}\truc -% donnait \truc se développant en «b» au lieu de «{b}». -%------------------------------------------------------------------------------ -% v1.5d 28/3/2010 -% - Correction d'un bug dans \IfInteger : \@xs@afterinteger ne donnait pas le -% bon r\'esultat. Par exemple avec 1.23 il renvoyait {} au lieu de {.23} -% - \xs@formatnumber ne detokenize plus ses arguments (que m'est-il pass\'e -% par la t\^ete pour que je code un truc comme ca ?), et donc -% \@xs@afterinteger et \@xs@afterdecimal ont des tokens ayant le bon -% catcode -%------------------------------------------------------------------------------ -% v1.6 24/10/2012 -% - Correction d'un bug dans \@xs@cutafteroccur au cas o\`u #3<1 -% - \IfDecimal ne \detokenize plus l'argument. -% - Nouvelle version de \tokenize qui enlevait les accolades si son argument -% \'etait entre accolades -% - Nouvelle macro \StrCut -% - \@xs@cutafteroccur@i ne produit plus d'espace indésirable si #3 était -% évalué par \numexpr -%------------------------------------------------------------------------------ -% v1.7 13/1/2013 -% - Correction d'un manque de rigueur dans les assignations concernant -% \groupID : elles sont toutes globales d\'esormais -% - Les macros de xstring sont \long -%------------------------------------------------------------------------------ -% v1.7a 28/2/2013 -% - Correction d'un espace parasite dans \@xs@removefirstsyntaxunit -%------------------------------------------------------------------------------ -% v1.7b 29/7/2013 -% - La date contenue dans \xstringdate est désormais conforme -%------------------------------------------------------------------------------ -% v1.7c 13/10/2013 -% - les macros impliquées dans \IfStrCase et \IfStrEqCase sont désormais \long diff --git a/stdeb.cfg b/stdeb.cfg index be040279..46d7a516 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -1,5 +1,5 @@ [DEFAULT] -Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, lilypond, texlive-fonts-recommended +Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, lilypond, texlive-fonts-recommended, texlive-fonts-extra Recommends: texlive-lang-english, texlive-lang-french, texlive-lang-portuguese, texlive-lang-spanish, texlive-fonts-extra XS-Python-Version: >=2.7 Section: tex From d71e8769130541ed0baedcfba00784b64800171b Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 12 May 2014 15:08:45 +0200 Subject: [PATCH 12/17] =?UTF-8?q?Suppression=20d'un=20paquet=20non=20n?= =?UTF-8?q?=C3=A9cessaire=20par=20d=C3=A9faut=20#28?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdeb.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdeb.cfg b/stdeb.cfg index 46d7a516..be040279 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -1,5 +1,5 @@ [DEFAULT] -Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, lilypond, texlive-fonts-recommended, texlive-fonts-extra +Depends: python-jinja2, python-pkg-resources, python-plastex, python-unidecode, texlive-latex-base, texlive-latex-recommended, texlive-latex-extra, lilypond, texlive-fonts-recommended Recommends: texlive-lang-english, texlive-lang-french, texlive-lang-portuguese, texlive-lang-spanish, texlive-fonts-extra XS-Python-Version: >=2.7 Section: tex From 2867aa3aa2600ec0225b84a52e80655701b1c73a Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 14 May 2014 13:38:47 +0200 Subject: [PATCH 13/17] =?UTF-8?q?Proposition=20de=20r=C3=A9solution=20de?= =?UTF-8?q?=20#34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/data/latex/chords.sty | 430 +++++++++++++------------- songbook_core/data/latex/crepbook.cls | 1 + 2 files changed, 211 insertions(+), 220 deletions(-) diff --git a/songbook_core/data/latex/chords.sty b/songbook_core/data/latex/chords.sty index b4f5e10a..b3d045bf 100644 --- a/songbook_core/data/latex/chords.sty +++ b/songbook_core/data/latex/chords.sty @@ -1,6 +1,7 @@ % Chords package for patacrep songbook % define commands for chord display : guitar chords (\gtab) and ukulele chords (\utab) \ProvidesPackage{chords} +\RequirePackage{songs} \newcommand*{\Sharp}{\nolinebreak\hspace{-.05em}\raisebox{.6ex}{\,\small\bf \#}} \newcommand*{\Flat}{\nolinebreak\hspace{-.05em}\raisebox{.6ex}{\,\small$\mathbf{\flat}$}} \newcommand*{\chordrule}{\mbox{\hspace{1cm}\rule[0.5cm]{15cm}{0.02cm}}\vspace{-.4cm}} @@ -9,39 +10,28 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Multilanguage management +\newcommand{\chordnameAsharp}{\printnoteA{}\Sharp = \printnoteB{}\Flat} +\newcommand{\chordnameA}{\printnoteA{}} +\newcommand{\chordnameB}{\printnoteB{}} +\newcommand{\chordnameCsharp}{\printnoteC{}\Sharp = \printnoteD{}\Flat} +\newcommand{\chordnameC}{\printnoteC{}} +\newcommand{\chordnameDsharp}{\printnoteD{}\Sharp = \printnoteE{}\Flat} +\newcommand{\chordnameD}{\printnoteD{}} +\newcommand{\chordnameE}{\printnoteE{}} +\newcommand{\chordnameFsharp}{\printnoteF{}\Sharp = \printnoteG{}\Flat} +\newcommand{\chordnameF}{\printnoteF{}} +\newcommand{\chordnameGsharp}{\printnoteG{}\Sharp = \printnoteA{}\Flat} +\newcommand{\chordnameG}{\printnoteG{}} + \AtBeginDocument{ % Default names (english) \newcommand{\guitarchordsname}{Guitar chords} \newcommand{\ukulelechordsname}{Ukulele chords} - \newcommand{\chordnameAsharp}{A\Sharp = B\Flat} - \newcommand{\chordnameA}{A} - \newcommand{\chordnameB}{B} - \newcommand{\chordnameCsharp}{C\Sharp = D\Flat} - \newcommand{\chordnameC}{C} - \newcommand{\chordnameDsharp}{D\Sharp = E\Flat} - \newcommand{\chordnameD}{D} - \newcommand{\chordnameE}{E} - \newcommand{\chordnameFsharp}{F\Sharp = G\Flat} - \newcommand{\chordnameF}{F} - \newcommand{\chordnameGsharp}{G\Sharp = A\Flat} - \newcommand{\chordnameG}{G} \IfStrEq{\mainlanguage}{french}{ % French names \renewcommand{\guitarchordsname}{Accords de guitare} \renewcommand{\ukulelechordsname}{Accords de ukulélé} - \renewcommand{\chordnameAsharp}{La\Sharp = Si\Flat} - \renewcommand{\chordnameA}{La} - \renewcommand{\chordnameB}{Si} - \renewcommand{\chordnameCsharp}{Do\Sharp = Ré\Flat} - \renewcommand{\chordnameC}{Do} - \renewcommand{\chordnameDsharp}{Ré\Sharp = Mi\Flat} - \renewcommand{\chordnameD}{Ré} - \renewcommand{\chordnameE}{Mi} - \renewcommand{\chordnameFsharp}{Fa\Sharp = Sol\Flat} - \renewcommand{\chordnameF}{Fa} - \renewcommand{\chordnameGsharp}{Sol\Sharp = La\Flat} - \renewcommand{\chordnameG}{Sol} }{} } @@ -61,151 +51,151 @@ \ifguitar \beginsong{\guitarchordsname} \chordname{\chordnameC} - \gtab{C}{~:X32010} - \gtab{C7}{~:X32310} - \gtab{Cm}{3:X02210} - \gtab{Cm7}{3:X02010} + \gtab{\printnoteC{}}{~:X32010} + \gtab{\printnoteC{}7}{~:X32310} + \gtab{\printnoteC{}m}{3:X02210} + \gtab{\printnoteC{}m7}{3:X02010} \hspace{1cm} - \gtab*{C7M}{~:332000} - \gtab*{C4}{~:X32011} - \gtab*{C7}{1:X2120X} - \gtab*{C6}{~:XX2213} + \gtab*{\printnoteC{}7M}{~:332000} + \gtab*{\printnoteC{}4}{~:X32011} + \gtab*{\printnoteC{}7}{1:X2120X} + \gtab*{\printnoteC{}6}{~:XX2213} \chordrule \chordname{\chordnameCsharp} - \gtab{C\#}{4:X02220} - \gtab{C\#7}{4:X02020} - \gtab{C\#m}{4:X02210} - \gtab{C\#m7}{5:XX2213} + \gtab{\printnoteC{}\#}{4:X02220} + \gtab{\printnoteC{}\#7}{4:X02020} + \gtab{\printnoteC{}\#m}{4:X02210} + \gtab{\printnoteC{}\#m7}{5:XX2213} \hspace{1cm} - \gtab*{C\#7M}{1:X32000} - \gtab*{C\#4}{2:X21000} - \gtab*{C\#7}{2:X2120X} - \gtab*{C\#6}{1:X02010} + \gtab*{\printnoteC{}\#7M}{1:X32000} + \gtab*{\printnoteC{}\#4}{2:X21000} + \gtab*{\printnoteC{}\#7}{2:X2120X} + \gtab*{\printnoteC{}\#6}{1:X02010} \chordrule \chordname{\chordnameD} - \gtab{D}{~:XX0232} - \gtab{D7}{~:XX0212} - \gtab{Dm}{~:XX0231} - \gtab{Dm7}{~:XX0211} + \gtab{\printnoteD{}}{~:XX0232} + \gtab{\printnoteD{}7}{~:XX0212} + \gtab{\printnoteD{}m}{~:XX0231} + \gtab{\printnoteD{}m7}{~:XX0211} \hspace{1cm} - \gtab*{D7M}{~:X00222} - \gtab*{D4}{~:X00233} - \gtab*{D7}{3:X2120X} - \gtab*{D6}{~:X00202} + \gtab*{\printnoteD{}7M}{~:X00222} + \gtab*{\printnoteD{}4}{~:X00233} + \gtab*{\printnoteD{}7}{3:X2120X} + \gtab*{\printnoteD{}6}{~:X00202} \chordrule \chordname{\chordnameDsharp} - \gtab{D\#}{6:X02220} - \gtab{D\#7}{6:X02020} - \gtab{D\#m}{6:X02210} - \gtab{D\#m7}{~:XX1322} + \gtab{\printnoteD{}\#}{6:X02220} + \gtab{\printnoteD{}\#7}{6:X02020} + \gtab{\printnoteD{}\#m}{6:X02210} + \gtab{\printnoteD{}\#m7}{~:XX1322} \hspace{1cm} - \gtab*{D\#7M}{3:022010} - \gtab*{D\#4}{4:X21000} - \gtab*{D\#7}{4:X2120X} - \gtab*{D\#6}{1:X00202} + \gtab*{\printnoteD{}\#7M}{3:022010} + \gtab*{\printnoteD{}\#4}{4:X21000} + \gtab*{\printnoteD{}\#7}{4:X2120X} + \gtab*{\printnoteD{}\#6}{1:X00202} \chordrule \chordname{\chordnameE} - \gtab{E}{~:022100} - \gtab{E7}{~:020100} - \gtab{Em}{~:022000} - \gtab{Em7}{~:022030} + \gtab{\printnoteE{}}{~:022100} + \gtab{\printnoteE{}7}{~:020100} + \gtab{\printnoteE{}m}{~:022000} + \gtab{\printnoteE{}m7}{~:022030} \hspace{1cm} - \gtab*{E7M}{~:021100} - \gtab*{E4}{~:02220} - \gtab*{E7}{5:X2120X} - \gtab*{E6}{~:022120} + \gtab*{\printnoteE{}7M}{~:021100} + \gtab*{\printnoteE{}4}{~:02220} + \gtab*{\printnoteE{}7}{5:X2120X} + \gtab*{\printnoteE{}6}{~:022120} \chordrule \chordname{\chordnameF} - \gtab{F}{1:022100} - \gtab{F7}{1:020100} - \gtab{Fm}{1:022000} - \gtab{Fm7}{1:020000} + \gtab{\printnoteF{}}{1:022100} + \gtab{\printnoteF{}7}{1:020100} + \gtab{\printnoteF{}m}{1:022000} + \gtab{\printnoteF{}m7}{1:020000} \hspace{1cm} - \gtab*{F7M}{~:XX3210} - \gtab*{F4}{1:022200} - \gtab*{F7}{6:X2120X} - \gtab*{F6}{~:XX0211} + \gtab*{\printnoteF{}7M}{~:XX3210} + \gtab*{\printnoteF{}4}{1:022200} + \gtab*{\printnoteF{}7}{6:X2120X} + \gtab*{\printnoteF{}6}{~:XX0211} \chordrule \chordname{\chordnameFsharp} - \gtab{F\#}{2:022100} - \gtab{F\#7}{2:020100} - \gtab{F\#m}{2:022000} - \gtab{F\#m7}{2:020000} + \gtab{\printnoteF{}\#}{2:022100} + \gtab{\printnoteF{}\#7}{2:020100} + \gtab{\printnoteF{}\#m}{2:022000} + \gtab{\printnoteF{}\#m7}{2:020000} \hspace{1cm} - \gtab*{F\#7M}{~:XX4321} - \gtab*{F\#4}{2:022200} - \gtab*{F\#7}{7:X2120X} - \gtab*{F\#6}{~:XX1322} + \gtab*{\printnoteF{}\#7M}{~:XX4321} + \gtab*{\printnoteF{}\#4}{2:022200} + \gtab*{\printnoteF{}\#7}{7:X2120X} + \gtab*{\printnoteF{}\#6}{~:XX1322} \chordrule \chordname{\chordnameG} - \gtab{G}{~:320003} - \gtab{G7}{~:320001} - \gtab{Gm}{3:022000} - \gtab{Gm7}{3:020000} + \gtab{\printnoteG{}}{~:320003} + \gtab{\printnoteG{}7}{~:320001} + \gtab{\printnoteG{}m}{3:022000} + \gtab{\printnoteG{}m7}{3:020000} \hspace{1cm} - \gtab*{G7M}{~:XX0002} - \gtab*{G4}{3:022200} - \gtab*{G7}{3:020200} - \gtab*{G6}{~:320000} + \gtab*{\printnoteG{}7M}{~:XX0002} + \gtab*{\printnoteG{}4}{3:022200} + \gtab*{\printnoteG{}7}{3:020200} + \gtab*{\printnoteG{}6}{~:320000} \chordrule \chordname{\chordnameGsharp} - \gtab{G\#}{4:022100} - \gtab{G\#7}{4:020100} - \gtab{G\#m}{4:022000} - \gtab{G\#m7}{4:020000} + \gtab{\printnoteG{}\#}{4:022100} + \gtab{\printnoteG{}\#7}{4:020100} + \gtab{\printnoteG{}\#m}{4:022000} + \gtab{\printnoteG{}\#m7}{4:020000} \hspace{1cm} - \gtab*{G\#7M}{3:XX4321} - \gtab*{G\#4}{4:022200} - \gtab*{G\#7}{~:XX1122} - \gtab*{G\#6}{~:XX1111} + \gtab*{\printnoteG{}\#7M}{3:XX4321} + \gtab*{\printnoteG{}\#4}{4:022200} + \gtab*{\printnoteG{}\#7}{~:XX1122} + \gtab*{\printnoteG{}\#6}{~:XX1111} \chordrule \chordname{\chordnameA} - \gtab{A}{~:X02220} - \gtab{A7}{~:X02020} - \gtab{Am}{~:X02210} - \gtab{Am7}{~:X02213} + \gtab{\printnoteA{}}{~:X02220} + \gtab{\printnoteA{}7}{~:X02020} + \gtab{\printnoteA{}m}{~:X02210} + \gtab{\printnoteA{}m7}{~:X02213} \hspace{1cm} - \gtab*{A7M}{~:X02120} - \gtab*{A4}{~:X02230} - \gtab*{A7}{~:X02233} - \gtab*{A6}{~:XX2222} + \gtab*{\printnoteA{}7M}{~:X02120} + \gtab*{\printnoteA{}4}{~:X02230} + \gtab*{\printnoteA{}7}{~:X02233} + \gtab*{\printnoteA{}6}{~:XX2222} \chordrule \chordname{\chordnameAsharp} - \gtab{A\#}{1:X02220} - \gtab{A\#7}{1:X02020} - \gtab{A\#m}{1:X02210} - \gtab{A\#m7}{1:X02010} + \gtab{\printnoteA{}\#}{1:X02220} + \gtab{\printnoteA{}\#7}{1:X02020} + \gtab{\printnoteA{}\#m}{1:X02210} + \gtab{\printnoteA{}\#m7}{1:X02010} \hspace{1cm} - \gtab*{A\#7M}{1:X02120} - \gtab*{A\#4}{1:X02230} - \gtab*{A\#7}{~:XX3344} - \gtab*{A\#6}{~:XX3333} + \gtab*{\printnoteA{}\#7M}{1:X02120} + \gtab*{\printnoteA{}\#4}{1:X02230} + \gtab*{\printnoteA{}\#7}{~:XX3344} + \gtab*{\printnoteA{}\#6}{~:XX3333} \chordrule \chordname{\chordnameB} - \gtab{B}{2:X02220} - \gtab{B7}{X21202} - \gtab{Bm}{2:X02210} - \gtab{Bm7}{~:X00202} + \gtab{\printnoteB{}}{2:X02220} + \gtab{\printnoteB{}7}{X21202} + \gtab{\printnoteB{}m}{2:X02210} + \gtab{\printnoteB{}m7}{~:X00202} \hspace{1cm} - \gtab*{B7M}{2:X02120} - \gtab*{B4}{2:X02230} - \gtab*{B7}{~:X22202} - \gtab*{B6}{~:XX4444} + \gtab*{\printnoteB{}7M}{2:X02120} + \gtab*{\printnoteB{}4}{2:X02230} + \gtab*{\printnoteB{}7}{~:X22202} + \gtab*{\printnoteB{}6}{~:XX4444} \begin{verse*} - \musicnote[french]{Accordage standard : {\nolyrics \[E A D G B E]}} - \musicnote[english]{Standard tuning: {\nolyrics \[E A D G B E]}} + \musicnote[french]{Accordage standard : {\nolyrics \[\printnoteE{} \printnoteA{} \printnoteD{} \printnoteG{} \printnoteB{} \printnoteE{}]}} + \musicnote[english]{Standard tuning: {\nolyrics \[\printnoteE{} \printnoteA{} \printnoteD{} \printnoteG{} \printnoteB{} \printnoteE{}]}} \end{verse*} \endsong @@ -215,151 +205,151 @@ \beginsong{\ukulelechordsname} \chordname{\chordnameC} - \utab{C}{~:0003} - \utab{C7}{~:0001} - \utab{Cm}{~:0333} - \utab{Cm7}{3:0000} + \utab{\printnoteC{}}{~:0003} + \utab{\printnoteC{}7}{~:0001} + \utab{\printnoteC{}m}{~:0333} + \utab{\printnoteC{}m7}{3:0000} \hspace{1cm} - \utab*{C7M}{~:0002} - \utab*{C6}{~:0000} - \utab*{Caug}{~:1003} - \utab*{Cdim}{2:3101} + \utab*{\printnoteC{}7M}{~:0002} + \utab*{\printnoteC{}6}{~:0000} + \utab*{\printnoteC{}aug}{~:1003} + \utab*{\printnoteC{}dim}{2:3101} \chordrule \chordname{\chordnameCsharp} - \utab{C\#}{1:0003} - \utab{C\#7}{1:0001} - \utab{C\#m}{~:1104} - \utab{C\#m7}{4:0000} + \utab{\printnoteC{}\#}{1:0003} + \utab{\printnoteC{}\#7}{1:0001} + \utab{\printnoteC{}\#m}{~:1104} + \utab{\printnoteC{}\#m7}{4:0000} \hspace{1cm} - \utab*{C\#7M}{1:0002} - \utab*{C\#6}{1:0000} - \utab*{C\#aug}{~:2110} - \utab*{C\#dim}{~:0104} + \utab*{\printnoteC{}\#7M}{1:0002} + \utab*{\printnoteC{}\#6}{1:0000} + \utab*{\printnoteC{}\#aug}{~:2110} + \utab*{\printnoteC{}\#dim}{~:0104} \chordrule \chordname{\chordnameD} - \utab{D}{~:2220} - \utab{D7}{2:0001} - \utab{Dm}{~:2210} - \utab{Dm7}{1:1102} + \utab{\printnoteD{}}{~:2220} + \utab{\printnoteD{}7}{2:0001} + \utab{\printnoteD{}m}{~:2210} + \utab{\printnoteD{}m7}{1:1102} \hspace{1cm} - \utab*{D7M}{2:0002} - \utab*{D6}{2:0000} - \utab*{Daug}{1:2110} - \utab*{Ddim}{1:0104} + \utab*{\printnoteD{}7M}{2:0002} + \utab*{\printnoteD{}6}{2:0000} + \utab*{\printnoteD{}aug}{1:2110} + \utab*{\printnoteD{}dim}{1:0104} \chordrule \chordname{\chordnameDsharp} - \utab{D\#}{1:2220} - \utab{D\#7}{3:0001} - \utab{D\#m}{1:2210} - \utab{D\#m7}{2:1102} + \utab{\printnoteD{}\#}{1:2220} + \utab{\printnoteD{}\#7}{3:0001} + \utab{\printnoteD{}\#m}{1:2210} + \utab{\printnoteD{}\#m7}{2:1102} \hspace{1cm} - \utab*{D\#7M}{3:0002} - \utab*{D\#6}{3:0000} - \utab*{D\#aug}{~:0332} - \utab*{D\#dim}{~:2320} + \utab*{\printnoteD{}\#7M}{3:0002} + \utab*{\printnoteD{}\#6}{3:0000} + \utab*{\printnoteD{}\#aug}{~:0332} + \utab*{\printnoteD{}\#dim}{~:2320} \chordrule \chordname{\chordnameE} - \utab{E}{2:2220} - \utab{E7}{~:1202} - \utab{Em}{~:0432} - \utab{Em7}{~:0202} + \utab{\printnoteE{}}{2:2220} + \utab{\printnoteE{}7}{~:1202} + \utab{\printnoteE{}m}{~:0432} + \utab{\printnoteE{}m7}{~:0202} \hspace{1cm} - \utab*{E7M}{~:1302} - \utab*{E6}{~:1102} - \utab*{Eaug}{1:0000} - \utab*{Edim}{1:2320} + \utab*{\printnoteE{}7M}{~:1302} + \utab*{\printnoteE{}6}{~:1102} + \utab*{\printnoteE{}aug}{1:0000} + \utab*{\printnoteE{}dim}{1:2320} \chordrule \chordname{\chordnameF} - \utab{F}{~:2010} - \utab{F7}{~:2310} - \utab{Fm}{~:1013} - \utab{Fm7}{1:0202} + \utab{\printnoteF{}}{~:2010} + \utab{\printnoteF{}7}{~:2310} + \utab{\printnoteF{}m}{~:1013} + \utab{\printnoteF{}m7}{1:0202} \hspace{1cm} - \utab*{F7M}{1:1302} - \utab*{F6}{1:1102} - \utab*{Faug}{~:2110} - \utab*{Fdim}{2:2320} + \utab*{\printnoteF{}7M}{1:1302} + \utab*{\printnoteF{}6}{1:1102} + \utab*{\printnoteF{}aug}{~:2110} + \utab*{\printnoteF{}dim}{2:2320} \chordrule \chordname{\chordnameFsharp} - \utab{F\#}{1:2010} - \utab{F\#7}{1:2310} - \utab{F\#m}{~:2120} - \utab{F\#m7}{2:0202} + \utab{\printnoteF{}\#}{1:2010} + \utab{\printnoteF{}\#7}{1:2310} + \utab{\printnoteF{}\#m}{~:2120} + \utab{\printnoteF{}\#m7}{2:0202} \hspace{1cm} - \utab*{F\#7M}{2:1302} - \utab*{F\#6}{~:0202} - \utab*{F\#aug}{1:2110} - \utab*{F\#dim}{~:2020} + \utab*{\printnoteF{}\#7M}{2:1302} + \utab*{\printnoteF{}\#6}{~:0202} + \utab*{\printnoteF{}\#aug}{1:2110} + \utab*{\printnoteF{}\#dim}{~:2020} \chordrule \chordname{\chordnameG} - \utab{G}{~:0232} - \utab{G7}{~:0212} - \utab{Gm}{~:0231} - \utab{Gm7}{~:0211} + \utab{\printnoteG{}}{~:0232} + \utab{\printnoteG{}7}{~:0212} + \utab{\printnoteG{}m}{~:0231} + \utab{\printnoteG{}m7}{~:0211} \hspace{1cm} - \utab*{G7M}{~:0222} - \utab*{G6}{~:0202} - \utab*{Gaug}{~:0332} - \utab*{Gdim}{~:0131} + \utab*{\printnoteG{}7M}{~:0222} + \utab*{\printnoteG{}6}{~:0202} + \utab*{\printnoteG{}aug}{~:0332} + \utab*{\printnoteG{}dim}{~:0131} \chordrule \chordname{\chordnameGsharp} - \utab{G\#}{3:2010} - \utab{G\#7}{1:0212} - \utab{G\#m}{1:0231} - \utab{G\#m7}{1:0211} + \utab{\printnoteG{}\#}{3:2010} + \utab{\printnoteG{}\#7}{1:0212} + \utab{\printnoteG{}\#m}{1:0231} + \utab{\printnoteG{}\#m7}{1:0211} \hspace{1cm} - \utab*{G\#7M}{1:0222} - \utab*{G\#6}{1:0202} - \utab*{G\#aug}{~:1003} - \utab*{G\#dim}{1:0131} + \utab*{\printnoteG{}\#7M}{1:0222} + \utab*{\printnoteG{}\#6}{1:0202} + \utab*{\printnoteG{}\#aug}{~:1003} + \utab*{\printnoteG{}\#dim}{1:0131} \chordrule \chordname{\chordnameA} - \utab{A}{~:2100} - \utab{A7}{~:0100} - \utab{Am}{~:2000} - \utab{Am7}{~:0000} + \utab{\printnoteA{}}{~:2100} + \utab{\printnoteA{}7}{~:0100} + \utab{\printnoteA{}m}{~:2000} + \utab{\printnoteA{}m7}{~:0000} \hspace{1cm} - \utab*{A7M}{~:1100} - \utab*{A6}{2:0202} - \utab*{Aaug}{~:2110} - \utab*{Adim}{2:0131} + \utab*{\printnoteA{}7M}{~:1100} + \utab*{\printnoteA{}6}{2:0202} + \utab*{\printnoteA{}aug}{~:2110} + \utab*{\printnoteA{}dim}{2:0131} \chordrule \chordname{\chordnameAsharp} - \utab{A\#}{1:2100} - \utab{A\#7}{1:0100} - \utab{A\#m}{1:2000} - \utab{A\#m7}{1:0000} + \utab{\printnoteA{}\#}{1:2100} + \utab{\printnoteA{}\#7}{1:0100} + \utab{\printnoteA{}\#m}{1:2000} + \utab{\printnoteA{}\#m7}{1:0000} \hspace{1cm} - \utab*{A\#7M}{1:1100} - \utab*{A\#6}{~:0211} - \utab*{A\#aug}{1:2110} - \utab*{A\#dim}{~:3101} + \utab*{\printnoteA{}\#7M}{1:1100} + \utab*{\printnoteA{}\#6}{~:0211} + \utab*{\printnoteA{}\#aug}{1:2110} + \utab*{\printnoteA{}\#dim}{~:3101} \chordrule \chordname{\chordnameB} - \utab{B}{2:2100} - \utab{B7}{2:0100} - \utab{Bm}{2:2000} - \utab{Bm7}{2:0000} + \utab{\printnoteB{}}{2:2100} + \utab{\printnoteB{}7}{2:0100} + \utab{\printnoteB{}m}{2:2000} + \utab{\printnoteB{}m7}{2:0000} \hspace{1cm} - \utab*{B7M}{2:1100} - \utab*{B6}{1:0211} - \utab*{Baug}{~:0332} - \utab*{Bdim}{1:3101} + \utab*{\printnoteB{}7M}{2:1100} + \utab*{\printnoteB{}6}{1:0211} + \utab*{\printnoteB{}aug}{~:0332} + \utab*{\printnoteB{}dim}{1:3101} \begin{verse*} - \musicnote[french]{Accordage standard : {\nolyrics \[G C E A]}} - \musicnote[english]{Standard tuning: {\nolyrics \[G C E A]}} + \musicnote[french]{Accordage standard : {\nolyrics \[\printnoteG{} \printnoteC{} \printnoteE{} \printnoteA{}]}} + \musicnote[english]{Standard tuning: {\nolyrics \[\printnoteG{} \printnoteC{} \printnoteE{} \printnoteA{}]}} \end{verse*} \endsong diff --git a/songbook_core/data/latex/crepbook.cls b/songbook_core/data/latex/crepbook.cls index 78681d12..060378fa 100644 --- a/songbook_core/data/latex/crepbook.cls +++ b/songbook_core/data/latex/crepbook.cls @@ -116,6 +116,7 @@ \IfStrEq{\mainlanguage}{french}{ % French names + \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} \renewcommand{\songlistname}{Liste des chansons}{} \renewcommand{\labelversionname}{version :} \renewcommand{\labeldatename}{date :} From aa1860cbc1c255939bd7fc31a40721172abbbacb Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 14 May 2014 16:27:20 +0200 Subject: [PATCH 14/17] Suppression de lignes inutiles --- songbook_core/data/templates/default.tex | 4 ---- 1 file changed, 4 deletions(-) diff --git a/songbook_core/data/templates/default.tex b/songbook_core/data/templates/default.tex index a13fa507..821e305f 100644 --- a/songbook_core/data/templates/default.tex +++ b/songbook_core/data/templates/default.tex @@ -106,10 +106,6 @@ (* block index *) \showindex{\songindexname}{titleidx} \showindex{\authorindexname}{authidx} - (* if lang==french *) - \notenamesin{A}{B}{C}{D}{E}{F}{G} - \notenamesout{La}{Si}{Do}{Ré}{Mi}{Fa}{Sol} - (* endif *) (* endblock *) (* block chords *) From 121a8f83ff88ce090f55a02463a6d9ed27b07cd7 Mon Sep 17 00:00:00 2001 From: Luthaf Date: Wed, 14 May 2014 22:41:53 +0100 Subject: [PATCH 15/17] Deplacement de la traduction dans les templates et ajout d'une option. --- songbook_core/data/latex/crepbook.cls | 1 - songbook_core/data/templates/default.tex | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/songbook_core/data/latex/crepbook.cls b/songbook_core/data/latex/crepbook.cls index 060378fa..78681d12 100644 --- a/songbook_core/data/latex/crepbook.cls +++ b/songbook_core/data/latex/crepbook.cls @@ -116,7 +116,6 @@ \IfStrEq{\mainlanguage}{french}{ % French names - \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} \renewcommand{\songlistname}{Liste des chansons}{} \renewcommand{\labelversionname}{version :} \renewcommand{\labeldatename}{date :} diff --git a/songbook_core/data/templates/default.tex b/songbook_core/data/templates/default.tex index 821e305f..bf4282fc 100644 --- a/songbook_core/data/templates/default.tex +++ b/songbook_core/data/templates/default.tex @@ -58,7 +58,11 @@ "authwords": {"description": {"english": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)", "french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"}, "default": {"default": {}} - } + }, +"alphascale": {"description": {"english": "Use alphabetic notes names (A B C ...) in french songbooks", + "french": "Utiliser la notation anglo-saxonne (A B C ...) pour les accords"}, + "default": {"default": false} + } } (* endvariables *) @@ -97,6 +101,11 @@ (* endif *) (* endfor *) (* endfor*) + + %! lang is defined in layout.tex + (* if lang=="french" and not alphascale *) + \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} + (* endif *) (* endblock *) (* block title *) From d124942de6743a29a8f3ee2f1c89da4d387ae146 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 15 May 2014 10:49:31 +0200 Subject: [PATCH 16/17] =?UTF-8?q?Choix=20des=20notes=20moins=20li=C3=A9=20?= =?UTF-8?q?=C3=A0=20la=20langue=20fran=C3=A7aise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- songbook_core/data/templates/default.tex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/songbook_core/data/templates/default.tex b/songbook_core/data/templates/default.tex index bf4282fc..3a413cf0 100644 --- a/songbook_core/data/templates/default.tex +++ b/songbook_core/data/templates/default.tex @@ -59,9 +59,9 @@ "french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"}, "default": {"default": {}} }, -"alphascale": {"description": {"english": "Use alphabetic notes names (A B C ...) in french songbooks", - "french": "Utiliser la notation anglo-saxonne (A B C ...) pour les accords"}, - "default": {"default": false} +"notenamesout": {"description": {"english": "Note names. Can be 'solfedge' (Do, Re, Mi...) or 'alphascale' (A, B, C...).", + "french": "Nom des notes : 'solfedge' (Do, Ré, Mi...) ou 'alphascale' (A, B, C...)."}, + "default": {"default": "alphascale", "french": "solfedge"} } } (* endvariables *) @@ -102,8 +102,9 @@ (* endfor *) (* endfor*) - %! lang is defined in layout.tex - (* if lang=="french" and not alphascale *) + (* if notenamesout=="alphascale" *) + \notenamesout{A}{B}{C}{D}{E}{F}{G} + (* else *) \notenamesout{La}{Si}{Do}{R\'e}{Mi}{Fa}{Sol} (* endif *) (* endblock *) From 5539f957586f02bae273643151297f538c2f0083 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 17 May 2014 09:03:06 +0200 Subject: [PATCH 17/17] Commentaires --- songbook_core/data/latex/chords.sty | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/songbook_core/data/latex/chords.sty b/songbook_core/data/latex/chords.sty index b3d045bf..c3c05caf 100644 --- a/songbook_core/data/latex/chords.sty +++ b/songbook_core/data/latex/chords.sty @@ -1,5 +1,5 @@ % Chords package for patacrep songbook -% define commands for chord display : guitar chords (\gtab) and ukulele chords (\utab) +% Define command \chords to display list of chords, for guitar or ukulele \ProvidesPackage{chords} \RequirePackage{songs} \newcommand*{\Sharp}{\nolinebreak\hspace{-.05em}\raisebox{.6ex}{\,\small\bf \#}} @@ -7,9 +7,6 @@ \newcommand*{\chordrule}{\mbox{\hspace{1cm}\rule[0.5cm]{15cm}{0.02cm}}\vspace{-.4cm}} \newcommand*{\chordname}[1]{\makebox[3cm]{\raisebox{.5cm}{\large \textbf{#1}}}} -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Multilanguage management - \newcommand{\chordnameAsharp}{\printnoteA{}\Sharp = \printnoteB{}\Flat} \newcommand{\chordnameA}{\printnoteA{}} \newcommand{\chordnameB}{\printnoteB{}} @@ -35,9 +32,6 @@ }{} } -% End of multilanguage management -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \newcommand{\chords}{ \begin{songs}{}