akkordarbeit 0.0.3c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ = The MIT License
2
+
3
+ * Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ * Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ = Abstract
2
+
3
+ Akkordarbeit[https://JoergWMittag.GitHub.Com/akkordarbeit/] is a
4
+ program for formatting simple leadsheets in a simplified ChordPro
5
+ format to various other formats such as HTML or plaintext.
6
+
7
+ ---
8
+
9
+ = What
10
+
11
+ This program converts leadsheets and songsheets written in a
12
+ subset of the widely used
13
+ ChordPro[http://Vromans.Org/johan/projects/Chordii/chordpro/]
14
+ file format into other formats, more suitable for printing or
15
+ publishing. Currently, the supported formats are plaintext and
16
+ HTML.
17
+
18
+ Akkordarbeit only supports a very small subset of the ChordPro
19
+ format. Specifically, it only supports song lines, no directives.
20
+
21
+ = Installation
22
+
23
+ gem install JoergWMittag-akkordarbeit
24
+
25
+ = Usage
26
+
27
+ akkordarbeit -f html -i input.cho -o output.html
28
+
29
+ = Acknowledgements
30
+
31
+ Akkordarbeit would not be possible without the original Chord
32
+ utility.
33
+
34
+ = License
35
+
36
+ Akkordarbeit is licensed under the {MIT X11 License}[https://GitHub.Com/JoergWMittag/Akkordarbeit/blob/master/LICENSE.rdoc].
37
+
38
+ :include: LICENSE.rdoc
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
3
+
4
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
5
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
6
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
7
+
8
+ libdir = File.expand_path(File.join File.dirname(File.expand_path(__FILE__).gsub(/(.*)bin.*?/, '\1')), 'lib')
9
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
10
+
11
+ require 'optparse'
12
+ require 'akkordarbeit'
13
+
14
+ module Akkordarbeit
15
+ class Main
16
+ def initialize args
17
+ @args = args
18
+ @options = { :format => 'HTML', :input => $stdin, :output => $stdout }
19
+ @option_parser = OptionParser.new do |opts|
20
+ opts.banner = 'Usage: akkordarbeit -f <FORMAT> -t <TITLE> -i <INPUT> -o <OUTPUT>'
21
+ opts.on('-f', '--format [FORMAT]', 'Use output format <FORMAT> instead of HTML') do |format|
22
+ @options[:format] = format
23
+ end
24
+ opts.on '-t', '--title [TITLE]', 'Use title instead of "Song-Sheet"' do |title|
25
+ @options[:title] = title
26
+ end
27
+ opts.on('-i', '--input [INPUTFILE]', 'Use Filename instead of STDIN') do |file|
28
+ @options[:input] = open file
29
+ end
30
+ opts.on('-o', '--output [OUTPUTFILE]', 'Use Filename instead of STDOUT') do |file|
31
+ @options[:output] = open file, 'w'
32
+ end
33
+ end
34
+ end
35
+
36
+ def run!
37
+ @option_parser.parse! @args
38
+ parsetree = Parser.new.parse @options[:input].gets(nil)
39
+ output = case @options[:format]
40
+ when /html/i
41
+ HtmlFormatter.new.format parsetree, @options[:title]
42
+ when /text/i
43
+ TextFormatter.new.format parsetree, @options[:title]
44
+ end
45
+ @options[:output].puts output
46
+ ensure
47
+ @options[:input].close
48
+ @options[:output].close
49
+ end
50
+
51
+ def self.run!
52
+ new(ARGV).run!
53
+ end
54
+ end
55
+
56
+ Main.run!
57
+ end
@@ -0,0 +1,59 @@
1
+ = Examples
2
+
3
+ This directory contains example files in several formats, each
4
+ describing the same song.
5
+
6
+ ---
7
+
8
+ = {ChordPro (+.cho+)}[http://Vromans.Org/johan/projects/Chordii/chordpro/]
9
+
10
+ ChordPro is *the* file format for leadsheets. It all started with
11
+ a Unix utility called +chord+, which set the basis for many
12
+ clones, derivatives, extensions and successors. Unfortunately,
13
+ the format was never formally specified, and so each
14
+ implementation interpreted it in its own way, added incompatible
15
+ extensions and generally made a mess of the format that wasn't
16
+ actually that good to begin with.
17
+
18
+ To see it in action, try:
19
+
20
+ chordii -o message.ps message.cho
21
+
22
+ = {GuitarTeX (+.gtx+)}[http://GuitarTeX.SourceForge.Net/]
23
+
24
+ GuitarTeX is one of those programs that expand upon the original
25
+ ChordPro format. It is a frontend to TeX, LaTeX, MusiXTeX and a
26
+ couple of other TeX-y things. Its file format is a chimera of a
27
+ greatly expanded ChordPro superset and LaTeX. The implementation
28
+ is a very hacky Perl script that uses Regexps to convert the
29
+ input into equally hacky LaTeX.
30
+
31
+ To see it in action, try:
32
+
33
+ gtx2tex message.gtx
34
+
35
+ = {reStructuredText (+.rst+)}[http://DocUtils.SourceForge.Net/rst.html]
36
+
37
+ ReStructuredText is the lightweight markup of the Python-docutils
38
+ project. It is intended to be a documentation language for Python
39
+ sourcecode, and therefore not very friendly to being (ab)used as
40
+ a leadsheet markup language. However, it actually works rather
41
+ well. This is the format that I use to write my leadsheets in.
42
+ (Until Akkordarbeit is finished, of course.) I use
43
+ Python-docutils to convert it to HTML, then a Regexp to mark up
44
+ the chord symbols with nice HTML and lastly a Ruby script using
45
+ Hpricot to clean up the generated HTML.
46
+
47
+ To see it in action, try:
48
+
49
+ rst2html -l de message.rst message.html
50
+
51
+ = {Akkordarbeit (+.akk+)}[https://JoergWMittag.GitHub.Com/akkordarbeit/]
52
+
53
+ This is the holy grail, of course. This file contains just a few
54
+ ideas for some syntactic features of Akkordarbeit. It is meant
55
+ purely as a basis for discussion.
56
+
57
+ To see it in action, try:
58
+
59
+ akkordarbeit -f html -i message.akk -o message.html
@@ -0,0 +1,277 @@
1
+ Feature: HTML Output
2
+ In order to view the chord files
3
+ As a user
4
+ I want to get HTML output
5
+
6
+ Scenario: HTML Output of a simple Song
7
+ Given the parsetree
8
+ """
9
+ [
10
+ [
11
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
12
+ ]
13
+ ]
14
+ """
15
+
16
+ When I format it as HTML
17
+ Then the output should be
18
+ """
19
+ <!DOCTYPE html>
20
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
21
+ <head>
22
+ <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
23
+ <title>Song-Sheet</title>
24
+ <meta http-equiv='content-language' content='en' />
25
+ <style>
26
+ p {
27
+ line-height: 300%;
28
+ max-width: 30em;
29
+ }
30
+ .chord {
31
+ position: relative;
32
+ }
33
+ .chord span {
34
+ position: absolute;
35
+ bottom: 40%;
36
+ font-size: 66%;
37
+ font-weight: bold;
38
+ }
39
+ .chord .brackets {
40
+ display: none;
41
+ }
42
+ </style>
43
+ </head>
44
+ <body>
45
+ <header>
46
+ <h1>Song-Sheet</h1>
47
+ </header>
48
+ <section>
49
+ <p>
50
+ <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span>
51
+ </p>
52
+ </section>
53
+ </body>
54
+ </html>
55
+
56
+ """
57
+
58
+ Scenario: HTML Output of a simple Song with one Section and two lines
59
+ Given the parsetree
60
+ """
61
+ [
62
+ [
63
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
64
+ ['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
65
+ ]
66
+ ]
67
+ """
68
+
69
+ When I format it as HTML
70
+ Then the output should be
71
+ """
72
+ <!DOCTYPE html>
73
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
74
+ <head>
75
+ <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
76
+ <title>Song-Sheet</title>
77
+ <meta http-equiv='content-language' content='en' />
78
+ <style>
79
+ p {
80
+ line-height: 300%;
81
+ max-width: 30em;
82
+ }
83
+ .chord {
84
+ position: relative;
85
+ }
86
+ .chord span {
87
+ position: absolute;
88
+ bottom: 40%;
89
+ font-size: 66%;
90
+ font-weight: bold;
91
+ }
92
+ .chord .brackets {
93
+ display: none;
94
+ }
95
+ </style>
96
+ </head>
97
+ <body>
98
+ <header>
99
+ <h1>Song-Sheet</h1>
100
+ </header>
101
+ <section>
102
+ <p>
103
+ <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
104
+ Do what <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span>
105
+ </p>
106
+ </section>
107
+ </body>
108
+ </html>
109
+
110
+ """
111
+
112
+ Scenario: HTML Output of a simple Song with two Section and two lines
113
+ Given the parsetree
114
+ """
115
+ [
116
+ [
117
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
118
+ ['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
119
+ ],
120
+ [
121
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
122
+ ['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
123
+ ]
124
+ ]
125
+ """
126
+
127
+ When I format it as HTML
128
+ Then the output should be
129
+ """
130
+ <!DOCTYPE html>
131
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
132
+ <head>
133
+ <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
134
+ <title>Song-Sheet</title>
135
+ <meta http-equiv='content-language' content='en' />
136
+ <style>
137
+ p {
138
+ line-height: 300%;
139
+ max-width: 30em;
140
+ }
141
+ .chord {
142
+ position: relative;
143
+ }
144
+ .chord span {
145
+ position: absolute;
146
+ bottom: 40%;
147
+ font-size: 66%;
148
+ font-weight: bold;
149
+ }
150
+ .chord .brackets {
151
+ display: none;
152
+ }
153
+ </style>
154
+ </head>
155
+ <body>
156
+ <header>
157
+ <h1>Song-Sheet</h1>
158
+ </header>
159
+ <section>
160
+ <p>
161
+ <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
162
+ Do what <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span>
163
+ </p>
164
+ <p>
165
+ <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
166
+ Do what <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span>
167
+ </p>
168
+ </section>
169
+ </body>
170
+ </html>
171
+
172
+ """
173
+
174
+ Scenario: HTML Escaping
175
+ Given the parsetree
176
+ """
177
+ [
178
+ [
179
+ ['<']
180
+ ]
181
+ ]
182
+ """
183
+
184
+ When I format it as HTML
185
+ Then the output should be
186
+ """
187
+ <!DOCTYPE html>
188
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
189
+ <head>
190
+ <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
191
+ <title>Song-Sheet</title>
192
+ <meta http-equiv='content-language' content='en' />
193
+ <style>
194
+ p {
195
+ line-height: 300%;
196
+ max-width: 30em;
197
+ }
198
+ .chord {
199
+ position: relative;
200
+ }
201
+ .chord span {
202
+ position: absolute;
203
+ bottom: 40%;
204
+ font-size: 66%;
205
+ font-weight: bold;
206
+ }
207
+ .chord .brackets {
208
+ display: none;
209
+ }
210
+ </style>
211
+ </head>
212
+ <body>
213
+ <header>
214
+ <h1>Song-Sheet</h1>
215
+ </header>
216
+ <section>
217
+ <p>
218
+ &lt;
219
+ </p>
220
+ </section>
221
+ </body>
222
+ </html>
223
+
224
+ """
225
+
226
+ Scenario: Title
227
+ Given the title Awesome Song
228
+ And the parsetree
229
+ """
230
+ [
231
+ [
232
+ ['Text']
233
+ ]
234
+ ]
235
+ """
236
+
237
+ When I format it as HTML
238
+ Then the output should be
239
+ """
240
+ <!DOCTYPE html>
241
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
242
+ <head>
243
+ <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
244
+ <title>Awesome Song</title>
245
+ <meta http-equiv='content-language' content='en' />
246
+ <style>
247
+ p {
248
+ line-height: 300%;
249
+ max-width: 30em;
250
+ }
251
+ .chord {
252
+ position: relative;
253
+ }
254
+ .chord span {
255
+ position: absolute;
256
+ bottom: 40%;
257
+ font-size: 66%;
258
+ font-weight: bold;
259
+ }
260
+ .chord .brackets {
261
+ display: none;
262
+ }
263
+ </style>
264
+ </head>
265
+ <body>
266
+ <header>
267
+ <h1>Awesome Song</h1>
268
+ </header>
269
+ <section>
270
+ <p>
271
+ Text
272
+ </p>
273
+ </section>
274
+ </body>
275
+ </html>
276
+
277
+ """
@@ -0,0 +1,63 @@
1
+ Feature: Parsing
2
+ In order to seperate backend and frontend
3
+ As a backend writer
4
+ I want to get a parsetree
5
+
6
+ Scenario: Simple Song
7
+ Given the song
8
+ """
9
+ [D]Do what I say, [Em]or I will suffer
10
+ """
11
+
12
+ When I parse it
13
+ Then the parsetree should be
14
+ """
15
+ [
16
+ [
17
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
18
+ ]
19
+ ]
20
+ """
21
+
22
+ Scenario: Simple Song Multiline
23
+ Given the song
24
+ """
25
+ [D]Do what I say, [Em]or I will suffer
26
+ [D]Do what I say, [Em]or I will suffer
27
+ """
28
+
29
+ When I parse it
30
+ Then the parsetree should be
31
+ """
32
+ [
33
+ [
34
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
35
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
36
+ ]
37
+ ]
38
+ """
39
+
40
+ Scenario: Song with two sections
41
+ Given the song
42
+ """
43
+ [D]Do what I say, [Em]or I will suffer
44
+ [D]Do what I say, [Em]or I will suffer
45
+
46
+ [D]Do what I say, [Em]or I will suffer
47
+ [D]Do what I say, [Em]or I will suffer
48
+ """
49
+
50
+ When I parse it
51
+ Then the parsetree should be
52
+ """
53
+ [
54
+ [
55
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
56
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
57
+ ],
58
+ [
59
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
60
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
61
+ ]
62
+ ]
63
+ """
@@ -0,0 +1,61 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6
+
7
+ require 'cucumber'
8
+ require 'spec/expectations'
9
+
10
+ stepsdir = File.expand_path(File.dirname __FILE__).gsub(/(.*step_definitions).*?/, '\1')
11
+ featuredir = File.expand_path File.join(stepsdir, '..')
12
+ libdir = File.expand_path File.join(featuredir, '..', 'lib')
13
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
14
+
15
+ require 'akkordarbeit'
16
+
17
+ Before do
18
+ @parser = Akkordarbeit::Parser.new
19
+ end
20
+
21
+ Given 'the song' do |song|
22
+ @song = song
23
+ end
24
+
25
+ When 'I parse it' do
26
+ @result = @parser.parse @song
27
+ end
28
+
29
+ Then 'the parsetree should be' do |parsetree|
30
+ @result.should == eval(parsetree)
31
+ end
32
+
33
+ Before do
34
+ @text_formatter = Akkordarbeit::TextFormatter.new
35
+ @html_formatter = Akkordarbeit::HtmlFormatter.new
36
+ end
37
+
38
+ Given 'the parsetree' do |parsetree|
39
+ @parsetree = eval(parsetree)
40
+ end
41
+
42
+ Given 'the title (.*)' do |title|
43
+ @title = title
44
+ end
45
+
46
+ When 'I format it as (.*)' do |format|
47
+ @result = case format
48
+ when /html/i
49
+ unless @title
50
+ @html_formatter.format @parsetree
51
+ else
52
+ @html_formatter.format @parsetree, @title
53
+ end
54
+ when /text/i
55
+ @text_formatter.format @parsetree, @title
56
+ end
57
+ end
58
+
59
+ Then 'the output should be' do |output|
60
+ @result.should == output
61
+ end
@@ -0,0 +1,95 @@
1
+ Feature: Text Output
2
+ In order to view the chord files
3
+ As a user
4
+ I want to get a text output
5
+
6
+ Scenario: Text Output of a simple Song
7
+ Given the parsetree
8
+ """
9
+ [
10
+ [
11
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
12
+ ]
13
+ ]
14
+ """
15
+
16
+ When I format it as text
17
+ Then the output should be
18
+ """
19
+ [D] [Em]
20
+ Do what I say, or I will suffer
21
+
22
+ """
23
+
24
+ Scenario: Text Output of a simple Song with one Section and two lines
25
+ Given the parsetree
26
+ """
27
+ [
28
+ [
29
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
30
+ ['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
31
+ ]
32
+ ]
33
+ """
34
+
35
+ When I format it as text
36
+ Then the output should be
37
+ """
38
+ [D] [Em]
39
+ Do what I say, or I will suffer
40
+ [D] [Em]
41
+ Do what I say, or I will suffer
42
+
43
+ """
44
+
45
+ Scenario: Text Output of a simple Song with two Section and two lines
46
+ Given the parsetree
47
+ """
48
+ [
49
+ [
50
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
51
+ ['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
52
+ ],
53
+ [
54
+ ['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
55
+ ['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
56
+ ]
57
+ ]
58
+ """
59
+
60
+ When I format it as text
61
+ Then the output should be
62
+ """
63
+ [D] [Em]
64
+ Do what I say, or I will suffer
65
+ [D] [Em]
66
+ Do what I say, or I will suffer
67
+
68
+ [D] [Em]
69
+ Do what I say, or I will suffer
70
+ [D] [Em]
71
+ Do what I say, or I will suffer
72
+
73
+ """
74
+
75
+ Scenario: Title
76
+ Given the title Awesome Song
77
+ And the parsetree
78
+ """
79
+ [
80
+ [
81
+ ['Text']
82
+ ]
83
+ ]
84
+ """
85
+
86
+ When I format it as text
87
+ Then the output should be
88
+ """
89
+ ==============
90
+ Awesome Song
91
+ ==============
92
+
93
+ Text
94
+
95
+ """
@@ -0,0 +1,12 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6
+
7
+ libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
8
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
9
+
10
+ require 'akkordarbeit/parser'
11
+ require 'akkordarbeit/text_formatter'
12
+ require 'akkordarbeit/html_formatter'
@@ -0,0 +1,83 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
5
+
6
+ libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
7
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
8
+
9
+ require 'cgi'
10
+
11
+ module Akkordarbeit
12
+ class HtmlFormatter
13
+ def format(parsetree, title = 'Song-Sheet')
14
+ output = <<-"HERE"
15
+ <!DOCTYPE html>
16
+ <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
17
+ <head>
18
+ <meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
19
+ <title>#{escape(title)}</title>
20
+ <meta http-equiv='content-language' content='en' />
21
+ <style>
22
+ p {
23
+ line-height: 300%;
24
+ max-width: 30em;
25
+ }
26
+ .chord {
27
+ position: relative;
28
+ }
29
+ .chord span {
30
+ position: absolute;
31
+ bottom: 40%;
32
+ font-size: 66%;
33
+ font-weight: bold;
34
+ }
35
+ .chord .brackets {
36
+ display: none;
37
+ }
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <header>
42
+ <h1>#{escape(title)}</h1>
43
+ </header>
44
+ <section>
45
+ HERE
46
+ parsetree.each do |section|
47
+ output << "\t"*3 << "<p>\n"
48
+ section.each do |line|
49
+ output << "\t"*4
50
+ last_chord = nil
51
+ line.each do |token|
52
+ regex = /(?:\[(.*?)\])/
53
+ if regex.match(token)
54
+ last_chord = $1
55
+ else
56
+ unless last_chord
57
+ output << escape(token)
58
+ else
59
+ token = '&nbsp;' if token =~ /^\s$/
60
+ output << "<span class='chord'><span><span class='brackets'>[</span>#{escape(last_chord)}<span class='brackets'>]</span></span>#{escape(token)}</span>"
61
+ last_chord = nil
62
+ end
63
+ end
64
+ end
65
+ output << "<br />\n"
66
+ end
67
+ output.gsub! %r|<br />\Z|, ''
68
+ output << "\t"*3 << "</p>\n"
69
+ end
70
+ return output << <<-'HERE'
71
+ </section>
72
+ </body>
73
+ </html>
74
+ HERE
75
+ end
76
+
77
+ private
78
+
79
+ def escape(str)
80
+ return CGI.escapeHTML(str)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,26 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6
+
7
+ libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
8
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
9
+
10
+ module Akkordarbeit
11
+ class Parser
12
+ def parse(songstr)
13
+ chordpattern = /(\[.*?\])/
14
+ seperatorpattern = /\n\n+/
15
+ song = []
16
+ songstr.split(seperatorpattern).each do |sectionstr|
17
+ section = []
18
+ sectionstr.each_line do |line|
19
+ section << line.chomp.split(chordpattern).reject { |str| str.empty? }
20
+ end
21
+ song << section
22
+ end
23
+ return song
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,33 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
4
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
5
+
6
+ libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
7
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
8
+
9
+ module Akkordarbeit
10
+ class TextFormatter
11
+ def format(parsetree, title = nil)
12
+ output = ''
13
+ output << '=' * (title.length + 2) << "\n" << ' ' << title << "\n" << '=' * (title.length + 2) << "\n" if title
14
+ parsetree.each do |section|
15
+ section.each do |line|
16
+ chords, lyrics = '', ''
17
+ line.each do |token|
18
+ regex = /(\[.*?\])/
19
+ if regex.match(token)
20
+ chords << token
21
+ else
22
+ lyrics << token
23
+ chords << ' ' * (lyrics.length - chords.length)
24
+ end
25
+ end
26
+ output << chords.rstrip << "\n" << lyrics.rstrip << "\n"
27
+ end
28
+ output << "\n"
29
+ end
30
+ return output.chomp
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6
+
7
+ require File.expand_path File.join(File.dirname(__FILE__), 'spec_helper')
8
+
9
+ require 'akkordarbeit'
10
+
11
+ describe Akkordarbeit do
12
+ it 'should work' do
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6
+
7
+ specdir = File.expand_path(File.dirname __FILE__).gsub(/(.*spec).*?/, '\1')
8
+ $LOAD_PATH.unshift specdir unless $LOAD_PATH.include? specdir
9
+
10
+ require 'spec_helper'
11
+
12
+ Dir[File.join specdir, '**', '*_spec.rb'].each { |spec| require spec }
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --diff unified
3
+ --format nested
@@ -0,0 +1,14 @@
1
+ # vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
2
+
3
+ # Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
4
+ # Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
5
+ # This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
6
+
7
+ require 'spec'
8
+ require 'spec/autorun'
9
+
10
+ libdir = File.expand_path File.join(File.dirname(__FILE__), 'lib').gsub(/(.*)spec.*?/, '\1')
11
+ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
12
+
13
+ specdir = File.expand_path(File.dirname __FILE__).gsub(/(.*spec).*?/, '\1')
14
+ $LOAD_PATH.unshift specdir unless $LOAD_PATH.include? specdir
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: akkordarbeit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3c
5
+ platform: ruby
6
+ authors:
7
+ - "J\xC3\xB6rg W Mittag"
8
+ - Marc Rummel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-11-18 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: cucumber
18
+ type: :development
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: 0.4.4
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: jscruggs-metric_fu
28
+ type: :development
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.1.5
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ type: :development
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 2.4.3
45
+ version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: reek
48
+ type: :development
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.4
55
+ version:
56
+ - !ruby/object:Gem::Dependency
57
+ name: roodi
58
+ type: :development
59
+ version_requirement:
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ version: 2.0.1
65
+ version:
66
+ - !ruby/object:Gem::Dependency
67
+ name: rspec
68
+ type: :development
69
+ version_requirement:
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 1.2.9
75
+ version:
76
+ description: |
77
+ Akkordarbeit is a program for formatting simple leadsheets in a
78
+ simplified ChordPro format to various other formats such as HTML
79
+ or plaintext.
80
+
81
+ email: JoergWMittag+Akkordarbeit@GoogleMail.Com
82
+ executables:
83
+ - akkordarbeit
84
+ extensions: []
85
+
86
+ extra_rdoc_files:
87
+ - LICENSE.rdoc
88
+ - README.rdoc
89
+ - examples/README.rdoc
90
+ files:
91
+ - features/html_formatter.feature
92
+ - features/parser.feature
93
+ - features/text_formatter.feature
94
+ - features/step_definitions/akkordarbeit_steps.rb
95
+ - spec/akkordarbeit_spec.rb
96
+ - spec/akkordarbeit_suite.rb
97
+ - spec/spec_helper.rb
98
+ - spec/spec.opts
99
+ - LICENSE.rdoc
100
+ - README.rdoc
101
+ - examples/README.rdoc
102
+ - bin/akkordarbeit
103
+ - lib/akkordarbeit.rb
104
+ - lib/akkordarbeit/html_formatter.rb
105
+ - lib/akkordarbeit/parser.rb
106
+ - lib/akkordarbeit/text_formatter.rb
107
+ has_rdoc: true
108
+ homepage: http://JoergWMittag.GitHub.Com/akkordarbeit/
109
+ licenses:
110
+ - MIT X11 License (see LICENSE.rdoc)
111
+ post_install_message:
112
+ rdoc_options:
113
+ - --all
114
+ - --charset=UTF-8
115
+ - --line-numbers
116
+ - --webcvs=https://GitHub.Com/JoergWMittag/Akkordarbeit/blob/master/%s
117
+ - --include='C:/Users/JRGWMI~1/Downloads/repos/akkordarbeit'
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 1.8.6
125
+ version:
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ~>
129
+ - !ruby/object:Gem::Version
130
+ version: 1.3.5
131
+ version:
132
+ requirements: []
133
+
134
+ rubyforge_project: Akkordarbeit
135
+ rubygems_version: 1.3.5
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Formats ChordPro leadsheets as HTML or plaintext
139
+ test_files:
140
+ - features/html_formatter.feature
141
+ - features/parser.feature
142
+ - features/text_formatter.feature
143
+ - features/step_definitions/akkordarbeit_steps.rb
144
+ - spec/akkordarbeit_spec.rb
145
+ - spec/akkordarbeit_suite.rb
146
+ - spec/spec_helper.rb
147
+ - spec/spec.opts