Browse Source

metacrep attempt

pull/220/head
Oliverpool 9 years ago
parent
commit
87c34fdec1
  1. 1
      patacrep/data/templates/songs/chordpro/chordpro/content_meta
  2. 1
      patacrep/data/templates/songs/chordpro/latex/content_meta
  3. 10
      patacrep/data/templates/styles/patacrep.sty
  4. 3
      patacrep/songs/chordpro/ast.py
  5. 31
      test/test_book/syntax.tex.control
  6. 9
      test/test_book/syntax_datadir/songs/metacrep.csg
  7. 13
      test/test_song/metacrep.csg
  8. 9
      test/test_song/metacrep.csg.source
  9. 26
      test/test_song/metacrep.tsg

1
patacrep/data/templates/songs/chordpro/chordpro/content_meta

@ -0,0 +1 @@
{meta: (( content.argument[0] )):(( content.argument[1] ))}

1
patacrep/data/templates/songs/chordpro/latex/content_meta

@ -0,0 +1 @@
\metacrep{((- content.argument[0] -))}{((- content.argument[1] -))}

10
patacrep/data/templates/styles/patacrep.sty

@ -468,4 +468,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Handle metacrep key (skip if the \metacrep<keyname> is not defined)
\newcommand{\metacrep}[2]{%
\ifcsname metacrep#1\endcsname%
\csname metacrep#1\endcsname{#2}%
\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput

3
patacrep/songs/chordpro/ast.py

@ -43,6 +43,7 @@ INLINE_DIRECTIVES = {
"guitar_comment",
"image",
"newline",
"meta",
}
#: Some directive have alternative names. For instance `{title: Foo}` and `{t:
@ -355,6 +356,8 @@ class Directive(AST):
def __init__(self, keyword, argument=None):
super().__init__()
self.keyword = directive_name(keyword.strip())
if keyword == 'meta':
argument = argument.split(':')
self.argument = argument
@property

31
test/test_book/syntax.tex.control

@ -34,6 +34,7 @@ guitar,
\usepackage{lmodern}
\PassOptionsToPackage{german}{babel}
\PassOptionsToPackage{english}{babel}
\usepackage[english]{babel}
\lang{english}
@ -91,6 +92,36 @@ guitar,
\addcontentsline{toc}{section}{\songlistname}
\begin{songs}{titleidx,authidx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% songs/./metacrep.csg
\selectlanguage{german}
\beginsong{Der kleine Troll}[
by={
},
]
\metacrep{liederbock}{ 292}
\begin{verse}
Let's sing and test a
\end{verse}
\metacrep{undefined}{ whatever}
\begin{verse}
directive between verses
\end{verse}
\endsong
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% songs/./musicnote.csg

9
test/test_book/syntax_datadir/songs/metacrep.csg

@ -0,0 +1,9 @@
{lang: de}
{title: Der kleine Troll}
{meta: liederbock: 292}
Let's sing and test a
{meta: undefined: whatever}
directive between verses

13
test/test_song/metacrep.csg

@ -0,0 +1,13 @@
{lang: de}
{title: Der kleine Troll}
{meta: liederbock: 292}
Let's sing and test a
{meta: undefined: whatever}
directive between verses

9
test/test_song/metacrep.csg.source

@ -0,0 +1,9 @@
{lang: de}
{title: Der kleine Troll}
{meta: liederbock: 292}
Let's sing and test a
{meta: undefined: whatever}
directive between verses

26
test/test_song/metacrep.tsg

@ -0,0 +1,26 @@
\selectlanguage{german}
\beginsong{Der kleine Troll}[
by={
},
]
\metacrep{liederbock}{ 292}
\begin{verse}
Let's sing and test a
\end{verse}
\metacrep{undefined}{ whatever}
\begin{verse}
directive between verses
\end{verse}
\endsong
Loading…
Cancel
Save