glyph 0.5.2 → 0.5.3.1
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.
- checksums.yaml +7 -0
- data/AUTHORS.textile +1 -0
- data/CHANGELOG.textile +104 -59
- data/Gemfile.lock +46 -0
- data/LICENSE.textile +1 -1
- data/README.textile +106 -120
- data/book/lib/layouts/bookindex.glyph +6 -106
- data/book/lib/layouts/bookpage.glyph +8 -108
- data/book/lib/layouts/project.glyph +0 -1
- data/book/text/acknowledgements.glyph +1 -0
- data/book/text/changelog.glyph +7 -1
- data/glyph.gemspec +10 -10
- data/lib/glyph.rb +1 -1
- data/spec/files/test.scss +1 -1
- data/spec/lib/analyzer_spec.rb +60 -61
- data/spec/lib/bookmark_spec.rb +21 -21
- data/spec/lib/commands_spec.rb +53 -54
- data/spec/lib/config_spec.rb +16 -16
- data/spec/lib/document_spec.rb +35 -35
- data/spec/lib/glyph_spec.rb +32 -32
- data/spec/lib/interpreter_spec.rb +8 -8
- data/spec/lib/macro_spec.rb +51 -49
- data/spec/lib/macro_validators_spec.rb +14 -14
- data/spec/lib/node_spec.rb +25 -25
- data/spec/lib/parser_spec.rb +26 -26
- data/spec/lib/reporter_spec.rb +32 -32
- data/spec/lib/syntax_node_spec.rb +33 -33
- data/spec/macros/core_spec.rb +95 -95
- data/spec/macros/filters_spec.rb +9 -8
- data/spec/macros/html5_spec.rb +17 -17
- data/spec/macros/macros_spec.rb +33 -33
- data/spec/macros/textile_spec.rb +15 -15
- data/spec/macros/web5_spec.rb +3 -3
- data/spec/macros/web_spec.rb +19 -19
- data/spec/macros/xml_spec.rb +15 -15
- data/spec/tasks/generate_spec.rb +34 -34
- data/spec/tasks/load_spec.rb +15 -15
- data/spec/tasks/project_spec.rb +15 -15
- data/styles/coderay.css +2 -0
- data/styles/coderay.css.map +7 -0
- data/styles/default.css +9 -7
- data/styles/default.css.map +7 -0
- data/styles/pagination.css +18 -23
- data/styles/pagination.css.map +7 -0
- data/tasks/generate.rake +12 -5
- metadata +47 -68
- data/glyph-0.5.1.gem +0 -0
data/spec/macros/macros_spec.rb
CHANGED
@@ -18,16 +18,16 @@ describe "Macro:" do
|
|
18
18
|
it "anchor" do
|
19
19
|
interpret "this is a #[test|test]."
|
20
20
|
doc = @p.document
|
21
|
-
doc.output.
|
22
|
-
doc.bookmarks[:test].
|
23
|
-
|
21
|
+
expect(doc.output).to eq("this is a <a id=\"test\">test</a>.")
|
22
|
+
expect(doc.bookmarks[:test]).to eq(Glyph::Bookmark.new({:file => nil, :title => 'test', :id => :test}))
|
23
|
+
expect { interpret "this is a #[test|test]. #[test|This won't work!]"; @p.document }.to raise_error
|
24
24
|
end
|
25
25
|
|
26
26
|
it "section, chapter, header" do
|
27
27
|
text = "chapter[@title[Chapter X] ... section[@title[Section Y]@id[sec-y] ... section[@title[Another section] ...]]]"
|
28
28
|
interpret text
|
29
29
|
doc = @p.document
|
30
|
-
doc.output.gsub(/\n|\t/, '').
|
30
|
+
expect(doc.output.gsub(/\n|\t/, '')).to eq(%{<div class="chapter">
|
31
31
|
<h2 id="h_1" class="toc">Chapter X</h2>...
|
32
32
|
<div class="section">
|
33
33
|
<h3 id="sec-y" class="toc">Section Y</h3>...
|
@@ -36,8 +36,8 @@ describe "Macro:" do
|
|
36
36
|
</div>
|
37
37
|
</div>
|
38
38
|
</div>
|
39
|
-
}.gsub(/\n|\t/, '')
|
40
|
-
doc.bookmark?(:"sec-y").
|
39
|
+
}.gsub(/\n|\t/, ''))
|
40
|
+
expect(doc.bookmark?(:"sec-y")).to eq(Glyph::Bookmark.new({:id => :"sec-y", :title => "Section Y", :file => nil}))
|
41
41
|
end
|
42
42
|
|
43
43
|
it "document, head, style" do
|
@@ -52,14 +52,14 @@ describe "Macro:" do
|
|
52
52
|
<meta name="copyright" content="#{Glyph["document.author"]}" />
|
53
53
|
<meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
|
54
54
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
55
|
-
<style type=\"text/css\">#main { background-color:
|
55
|
+
<style type=\"text/css\">#main { background-color: #0000ff; margin: 12px; }</style>
|
56
56
|
</head>
|
57
57
|
</html>
|
58
58
|
}
|
59
59
|
interpret "document[head[style[test.sass]]]"
|
60
|
-
@p.document.output.gsub(/\n|\t/, '').
|
60
|
+
expect(@p.document.output.gsub(/\n|\t/, '')).to eq(doc.gsub(/\n|\t/, ''))
|
61
61
|
interpret "document[head[style[test.scss]]]"
|
62
|
-
@p.document.output.gsub(/\n|\t/, '').
|
62
|
+
expect(@p.document.output.gsub(/\n|\t/, '')).to eq(doc.gsub(/\n|\t/, ''))
|
63
63
|
end
|
64
64
|
|
65
65
|
it "style should link files by absolute or relative path in Lite mode" do
|
@@ -73,21 +73,21 @@ describe "Macro:" do
|
|
73
73
|
<meta name="copyright" content="#{Glyph["document.author"]}" />
|
74
74
|
<meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
|
75
75
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
76
|
-
<style type=\"text/css\">#main { background-color:
|
76
|
+
<style type=\"text/css\">#main { background-color: #0000ff; margin: 12px; }</style>
|
77
77
|
</head>
|
78
78
|
</html>
|
79
79
|
}.gsub(/\n|\t/, '')
|
80
80
|
Glyph.lite_mode = true
|
81
81
|
Dir.chdir Glyph::PROJECT
|
82
82
|
interpret "document[head[style[styles/test.sass]]]"
|
83
|
-
@p.document.output.gsub(/\n|\t/, '').
|
83
|
+
expect(@p.document.output.gsub(/\n|\t/, '')).to eq(result)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "style should import and link stylesheets" do
|
87
87
|
Glyph['document.styles'] = 'import'
|
88
|
-
output_for("head[style[default.css]]").match(/@import url\("styles\/default\.css"\)/).blank
|
88
|
+
expect(output_for("head[style[default.css]]").match(/@import url\("styles\/default\.css"\)/).blank?).to eq(false)
|
89
89
|
Glyph['document.styles'] = 'link'
|
90
|
-
output_for("head[style[default.css]]").match(%{<link href="styles/default.css" rel="stylesheet" type="text/css" />}).blank
|
90
|
+
expect(output_for("head[style[default.css]]").match(%{<link href="styles/default.css" rel="stylesheet" type="text/css" />}).blank?).to eq(false)
|
91
91
|
Glyph['document.styles'] = 'embed'
|
92
92
|
end
|
93
93
|
|
@@ -96,7 +96,7 @@ describe "Macro:" do
|
|
96
96
|
interpret file_load(Glyph::PROJECT/'document.glyph')
|
97
97
|
doc = @p.document
|
98
98
|
doc.output.gsub!(/\n|\t/, '')
|
99
|
-
doc.output.slice(/(.+?<\/div>)/, 1).
|
99
|
+
expect(doc.output.slice(/(.+?<\/div>)/, 1)).to eq(%{
|
100
100
|
<div class="contents">
|
101
101
|
<h2 class="toc-header" id="toc">Table of Contents</h2>
|
102
102
|
<ol class="toc">
|
@@ -104,7 +104,7 @@ describe "Macro:" do
|
|
104
104
|
<li class="section"><a href="#md">Markdown</a></li>
|
105
105
|
</ol>
|
106
106
|
</div>
|
107
|
-
}.gsub(/\n|\t/, '')
|
107
|
+
}.gsub(/\n|\t/, ''))
|
108
108
|
end
|
109
109
|
|
110
110
|
it "link" do
|
@@ -115,26 +115,26 @@ describe "Macro:" do
|
|
115
115
|
#[test_id2|Test #2]
|
116
116
|
}
|
117
117
|
interpret text
|
118
|
-
@p.document.output.gsub(/\n|\t/, '').
|
118
|
+
expect(@p.document.output.gsub(/\n|\t/, '')).to eq(%{
|
119
119
|
<a href="#test_id">Test #1</a>
|
120
120
|
<a href="#test_id2">Test #2</a>
|
121
121
|
<a id="test_id">Test #1</a>
|
122
122
|
<a id="test_id2">Test #2</a>
|
123
|
-
}.gsub(/\n|\t/, '')
|
123
|
+
}.gsub(/\n|\t/, ''))
|
124
124
|
end
|
125
125
|
|
126
126
|
it "fmi" do
|
127
127
|
interpret "fmi[this topic|#test] #[test|Test]"
|
128
|
-
@p.document.output.
|
128
|
+
expect(@p.document.output).to eq(%{<span class="fmi">
|
129
129
|
for more information on this topic,
|
130
|
-
see <a href="#test">Test</a></span> <a id="test">Test</a>}.gsub(/\n|\t/, '')
|
130
|
+
see <a href="#test">Test</a></span> <a id="test">Test</a>}.gsub(/\n|\t/, ''))
|
131
131
|
end
|
132
132
|
|
133
133
|
it "image" do
|
134
134
|
interpret "image[@width[90%]@height[90%]@alt[-]ligature.jpg]"
|
135
|
-
@p.document.output.gsub(/\t|\n/, '').
|
135
|
+
expect(@p.document.output.gsub(/\t|\n/, '')).to eq(%{
|
136
136
|
<img src="images/ligature.jpg" width="90%" height="90%" alt="-" />
|
137
|
-
}.gsub(/\n|\t/, '')
|
137
|
+
}.gsub(/\n|\t/, ''))
|
138
138
|
end
|
139
139
|
|
140
140
|
it "image should link files by absolute or relative path in Lite mode" do
|
@@ -144,18 +144,18 @@ describe "Macro:" do
|
|
144
144
|
Glyph.lite_mode = true
|
145
145
|
Dir.chdir Glyph::PROJECT
|
146
146
|
interpret "image[@width[90%]@height[90%]images/ligature.jpg]"
|
147
|
-
@p.document.output.gsub(/\t|\n/, '').
|
147
|
+
expect(@p.document.output.gsub(/\t|\n/, '')).to eq(result)
|
148
148
|
interpret "image[@width[90%]@height[90%]#{Glyph::PROJECT}/images/ligature.jpg]"
|
149
|
-
@p.document.output.gsub(/\t|\n/, '').gsub(Glyph::PROJECT.to_s+'/', '').
|
149
|
+
expect(@p.document.output.gsub(/\t|\n/, '').gsub(Glyph::PROJECT.to_s+'/', '')).to eq(result)
|
150
150
|
end
|
151
151
|
|
152
152
|
it "figure" do
|
153
153
|
interpret "figure[@alt[ligature]ligature.jpg|Ligature]"
|
154
|
-
@p.document.output.gsub(/\t|\n/, '').
|
154
|
+
expect(@p.document.output.gsub(/\t|\n/, '')).to eq(%{
|
155
155
|
<div class=\"figure\" alt=\"ligature\">
|
156
156
|
<img src=\"images/ligature.jpg\" />
|
157
157
|
<div class=\"caption\">Ligature</div>
|
158
|
-
</div>}.gsub(/\n|\t/, '')
|
158
|
+
</div>}.gsub(/\n|\t/, ''))
|
159
159
|
end
|
160
160
|
|
161
161
|
it "fig should link files by absolute or relative path in Lite mode" do
|
@@ -168,24 +168,24 @@ describe "Macro:" do
|
|
168
168
|
Glyph.lite_mode = true
|
169
169
|
Dir.chdir Glyph::PROJECT
|
170
170
|
interpret "figure[images/ligature.jpg|Ligature]"
|
171
|
-
@p.document.output.gsub(/\t|\n/, '').
|
171
|
+
expect(@p.document.output.gsub(/\t|\n/, '')).to eq(result)
|
172
172
|
interpret "figure[#{Glyph::PROJECT}/images/ligature.jpg|Ligature]"
|
173
|
-
@p.document.output.gsub(/\t|\n/, '').gsub(Glyph::PROJECT.to_s+'/', '').
|
173
|
+
expect(@p.document.output.gsub(/\t|\n/, '').gsub(Glyph::PROJECT.to_s+'/', '')).to eq(result)
|
174
174
|
end
|
175
175
|
|
176
176
|
it "draftcomment, todo" do
|
177
177
|
text1 = "dc[comment!]"
|
178
178
|
text2 = "![todo!]"
|
179
179
|
interpret text1
|
180
|
-
@p.document.output.
|
180
|
+
expect(@p.document.output).to eq("")
|
181
181
|
interpret text2
|
182
|
-
@p.document.output.
|
182
|
+
expect(@p.document.output).to eq("")
|
183
183
|
Glyph['document.draft'] = true
|
184
184
|
interpret text1
|
185
|
-
@p.document.output.
|
185
|
+
expect(@p.document.output).to eq(%{<span class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>comment!</span>})
|
186
186
|
interpret text2
|
187
|
-
@p.document.output.
|
188
|
-
@p.document.todos.length.
|
187
|
+
expect(@p.document.output).to eq(%{<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>todo!</span>})
|
188
|
+
expect(@p.document.todos.length).to eq(1)
|
189
189
|
Glyph['document.draft'] = false
|
190
190
|
end
|
191
191
|
|
@@ -210,7 +210,7 @@ describe "Macro:" do
|
|
210
210
|
]
|
211
211
|
}
|
212
212
|
end
|
213
|
-
output_for(container.call aliased).
|
213
|
+
expect(output_for(container.call aliased)).to eq(output_for(container.call normal))
|
214
214
|
end
|
215
215
|
|
216
216
|
end
|
data/spec/macros/textile_spec.rb
CHANGED
@@ -47,8 +47,8 @@ Testing:
|
|
47
47
|
<h2 id="h_1" class="toc">Test</h2>
|
48
48
|
#@html
|
49
49
|
</div>}
|
50
|
-
filter(text1).
|
51
|
-
filter(text2).gsub(/<\/h2>/, "</h2>").
|
50
|
+
expect(filter(text1)).to eq(result)
|
51
|
+
expect(filter(text2).gsub(/<\/h2>/, "</h2>")).to eq(result)
|
52
52
|
end
|
53
53
|
|
54
54
|
######################################
|
@@ -70,10 +70,10 @@ Testing:
|
|
70
70
|
#@textile
|
71
71
|
]
|
72
72
|
]}
|
73
|
-
filter(box1).
|
74
|
-
filter(box2).
|
75
|
-
filter(box3).
|
76
|
-
filter(box4).
|
73
|
+
expect(filter(box1)).to eq(result)
|
74
|
+
expect(filter(box2)).to eq(result)
|
75
|
+
expect(filter(box3)).to eq(result)
|
76
|
+
expect(filter(box4)).to eq(result)
|
77
77
|
end
|
78
78
|
|
79
79
|
######################################
|
@@ -93,10 +93,10 @@ Testing:
|
|
93
93
|
#@textile
|
94
94
|
]
|
95
95
|
]}
|
96
|
-
filter(note1).
|
97
|
-
filter(note2).
|
98
|
-
filter(note3).
|
99
|
-
filter(note4).
|
96
|
+
expect(filter(note1)).to eq(result)
|
97
|
+
expect(filter(note2)).to eq(result)
|
98
|
+
expect(filter(note3)).to eq(result)
|
99
|
+
expect(filter(note4)).to eq(result)
|
100
100
|
end
|
101
101
|
|
102
102
|
######################################
|
@@ -149,11 +149,11 @@ Testing:
|
|
149
149
|
#{code}
|
150
150
|
]
|
151
151
|
]]}
|
152
|
-
filter(text1).
|
153
|
-
filter(text2).
|
154
|
-
filter(text3).
|
155
|
-
filter(text4).
|
156
|
-
filter(text5).
|
152
|
+
expect(filter(text1)).to eq(result)
|
153
|
+
expect(filter(text2)).to eq(result)
|
154
|
+
expect(filter(text3)).to eq(result)
|
155
|
+
expect(filter(text4)).to eq(result)
|
156
|
+
expect(filter(text5)).to eq(result)
|
157
157
|
end
|
158
158
|
|
159
159
|
end
|
data/spec/macros/web5_spec.rb
CHANGED
@@ -19,14 +19,14 @@ describe "Macro:" do
|
|
19
19
|
it "section (topic)" do
|
20
20
|
interpret("section[section[@src[a/web1.glyph]@title[Test]]]")
|
21
21
|
topic = @p.document.topics[0]
|
22
|
-
topic[:contents].match(/<article>/).blank
|
22
|
+
expect(topic[:contents].match(/<article>/).blank?).to eq(false)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "navigation" do
|
26
26
|
Glyph.run! 'generate:web5'
|
27
27
|
web1 = Glyph.file_load(Glyph::PROJECT/'output/web5/a/web1.html').gsub(/\n|\t| /, '')
|
28
28
|
web2 = Glyph.file_load(Glyph::PROJECT/'output/web5/a/b/web2.html').gsub(/\n|\t| /, '')
|
29
|
-
web1.
|
30
|
-
web2.
|
29
|
+
expect(web1).to match(%{<nav>|<a href="/index.html">Contents</a>|<a href="/a/b/web2.html">→ Topic #2</a></nav>})
|
30
|
+
expect(web2).to match(%{<nav><a href="/a/web1.html">Topic #1</a>|<a href="/index.html">Contents</a>|</nav>})
|
31
31
|
end
|
32
32
|
end
|
data/spec/macros/web_spec.rb
CHANGED
@@ -16,47 +16,47 @@ describe "Macro:" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "section (topic)" do
|
19
|
-
|
19
|
+
expect { output_for("section[@src[test]]") }.to raise_error(Glyph::MacroError, "Macro 'section' requires a 'title' attribute")
|
20
20
|
interpret("section[@src[a/web1.glyph]@title[Test]]")
|
21
21
|
topic = @p.document.topics[0]
|
22
|
-
topic.blank
|
23
|
-
topic[:id].
|
24
|
-
topic[:title].
|
25
|
-
topic[:src].
|
26
|
-
topic[:contents].match(/id="w1_3"/).blank
|
22
|
+
expect(topic.blank?).to eq(false)
|
23
|
+
expect(topic[:id]).to eq(:t_0)
|
24
|
+
expect(topic[:title]).to eq("Test")
|
25
|
+
expect(topic[:src]).to eq("a/web1.glyph")
|
26
|
+
expect(topic[:contents].match(/id="w1_3"/).blank?).to eq(false)
|
27
27
|
Glyph['document.output'] = 'html'
|
28
28
|
Glyph.run! 'load:macros'
|
29
|
-
output_for("contents[section[@src[a/web1.glyph]@title[Test]]]").match(/id="w1_3"/).blank
|
29
|
+
expect(output_for("contents[section[@src[a/web1.glyph]@title[Test]]]").match(/id="w1_3"/).blank?).to eq(false)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "navigation" do
|
33
33
|
Glyph.run! 'generate:web'
|
34
34
|
web1 = compact_html Glyph.file_load(Glyph::PROJECT/'output/web/a/web1.html')
|
35
35
|
web2 = compact_html Glyph.file_load(Glyph::PROJECT/'output/web/a/b/web2.html')
|
36
|
-
web1.match(%{<div class="navigation"> | <a href="/index.html">Contents</a> | <a href="/a/b/web2.html">Topic #2</a></div>}).blank
|
37
|
-
web2.match(%{<div class="navigation"><a href="/a/web1.html">Topic #1</a> | <a href="/index.html">Contents</a> | </div>}).blank
|
36
|
+
expect(web1.match(%{<div class="navigation"> | <a href="/index.html">Contents</a> | <a href="/a/b/web2.html">Topic #2</a></div>}).blank?).to eq(false)
|
37
|
+
expect(web2.match(%{<div class="navigation"><a href="/a/web1.html">Topic #1</a> | <a href="/index.html">Contents</a> | </div>}).blank?).to eq(false)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "toc should only list topics" do
|
41
41
|
Glyph.run! 'generate:web'
|
42
42
|
index = Glyph.file_load(Glyph::PROJECT/'output/web/index.html')
|
43
|
-
index.match(%{<li class="section"><a href="#h_1">Web Document</a></li>}).blank
|
44
|
-
index.match(%{href="/a/web1.html#h_3"}).blank
|
45
|
-
index.match(%{href="/a/b/web2.html#h_7"}).blank
|
43
|
+
expect(index.match(%{<li class="section"><a href="#h_1">Web Document</a></li>}).blank?).to eq(true)
|
44
|
+
expect(index.match(%{href="/a/web1.html#h_3"}).blank?).to eq(false)
|
45
|
+
expect(index.match(%{href="/a/b/web2.html#h_7"}).blank?).to eq(false)
|
46
46
|
web1 = Glyph.file_load(Glyph::PROJECT/'output/web/a/web1.html')
|
47
|
-
web1.
|
47
|
+
expect(web1).to match(/<h2 id="t_0" class="toc">Topic #1<\/h2>/) # Headers are reset in each topic
|
48
48
|
delete_project
|
49
49
|
reset_quiet
|
50
50
|
create_web_project
|
51
51
|
Glyph['document.output'] = 'html'
|
52
52
|
Glyph.run! 'generate:html'
|
53
53
|
index = compact_html Glyph.file_load(Glyph::PROJECT/'output/html/test_project.html')
|
54
|
-
index.
|
55
|
-
index.match(%{href="a/web1.html#h_3"}).blank
|
56
|
-
index.match(%{href="a/b/web2.html#h_7"}).blank
|
57
|
-
index.match(%{<li class="section"><a href="#h_1">Web Document</a></li>}).blank
|
58
|
-
index.match(%{href="#h_2"}).blank
|
59
|
-
index.match(%{href="#h_8"}).blank
|
54
|
+
expect(index).to match(%{<li class="section"><a href="#h_3">Topic #1</a></li><li><ol><li class="section"><a href="#h_4">Test #1a</a></li>})
|
55
|
+
expect(index.match(%{href="a/web1.html#h_3"}).blank?).to eq(true)
|
56
|
+
expect(index.match(%{href="a/b/web2.html#h_7"}).blank?).to eq(true)
|
57
|
+
expect(index.match(%{<li class="section"><a href="#h_1">Web Document</a></li>}).blank?).to eq(false)
|
58
|
+
expect(index.match(%{href="#h_2"}).blank?).to eq(false)
|
59
|
+
expect(index.match(%{href="#h_8"}).blank?).to eq(false) # Header numbers are different...
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
data/spec/macros/xml_spec.rb
CHANGED
@@ -15,40 +15,40 @@ describe "Glyph Language" do
|
|
15
15
|
|
16
16
|
it "should support XML fallback by default" do
|
17
17
|
Glyph.run 'load:all'
|
18
|
-
output_for(%{
|
18
|
+
expect(output_for(%{
|
19
19
|
i[test]
|
20
20
|
code[
|
21
21
|
test
|
22
22
|
]
|
23
|
-
}).gsub(/\s+/, '').
|
23
|
+
}).gsub(/\s+/, '')).to eq(%{
|
24
24
|
<i>test</i>
|
25
25
|
<code>
|
26
26
|
test
|
27
|
-
</code>}.gsub(/\s+/, '')
|
27
|
+
</code>}.gsub(/\s+/, ''))
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should support XML macros" do
|
31
31
|
language('xml')
|
32
|
-
output_for("pre[code[test]]").
|
32
|
+
expect(output_for("pre[code[test]]")).to eq("<pre>\n<code>test</code>\n</pre>")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should support XML attributes" do
|
36
36
|
language('xml')
|
37
|
-
output_for("span[@class[test] @style[color:red;] test...]").
|
37
|
+
expect(output_for("span[@class[test] @style[color:red;] test...]")).to eq(%{
|
38
38
|
<span class="test" style="color:red;"> test...</span>
|
39
|
-
}.strip
|
39
|
+
}.strip)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should detect invalid characters for XML elements and attributes" do
|
43
43
|
language('xml')
|
44
|
-
|
45
|
-
output_for("span[@class[test]@.[test]test]").
|
44
|
+
expect { interpret("!&test[test]").document }.to raise_error
|
45
|
+
expect(output_for("span[@class[test]@.[test]test]")).to eq(%{<span class="test">test</span>})
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should notify the user that a macro is not found for invalid elements if xml_fallback is enabled" do
|
49
49
|
# Assuming options.xml_fallback = true
|
50
50
|
language('glyph')
|
51
|
-
|
51
|
+
expect { interpret("*a[test]").document }.to raise_error(Glyph::MacroError, "Invalid XML element '*a'")
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should not render blacklisted tags" do
|
@@ -71,16 +71,16 @@ describe "Glyph Language" do
|
|
71
71
|
param[test]
|
72
72
|
title[tesy]
|
73
73
|
}
|
74
|
-
output_for(text).gsub(/\s/, '').
|
74
|
+
expect(output_for(text).gsub(/\s/, '')).to eq("<test>test</test>")
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should work with macro composition" do
|
78
78
|
language('glyph')
|
79
|
-
output_for("xml/a[@test[...]xyz]").
|
80
|
-
output_for("xml/a[@test[...]xml/b[test]]").
|
81
|
-
output_for("xml/a[xml/b[test]xml/c[test]]").
|
82
|
-
output_for("xml/a[xml/b[test]xml/c[@test[test_attr]test]]").
|
83
|
-
output_for("xml/a[xml/b[@test[true]]]").
|
79
|
+
expect(output_for("xml/a[@test[...]xyz]")).to eq("<a test=\"...\">xyz</a>")
|
80
|
+
expect(output_for("xml/a[@test[...]xml/b[test]]")).to eq("<a test=\"...\">\n<b>test</b>\n</a>")
|
81
|
+
expect(output_for("xml/a[xml/b[test]xml/c[test]]")).to eq("<a>\n<b>test</b><c>test</c>\n</a>")
|
82
|
+
expect(output_for("xml/a[xml/b[test]xml/c[@test[test_attr]test]]")).to eq("<a>\n<b>test</b><c test=\"test_attr\">test</c>\n</a>")
|
83
|
+
expect(output_for("xml/a[xml/b[@test[true]]]")).to eq("<a>\n<b test=\"true\" />\n</a>")
|
84
84
|
end
|
85
85
|
|
86
86
|
end
|
data/spec/tasks/generate_spec.rb
CHANGED
@@ -13,64 +13,64 @@ describe "generate" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it ":document should generate Glyph.document" do
|
16
|
-
|
17
|
-
Glyph.document.structure.children.length.
|
16
|
+
expect { Glyph.run! 'generate:document'}.not_to raise_error
|
17
|
+
expect(Glyph.document.structure.children.length).to be > 0
|
18
18
|
end
|
19
19
|
|
20
20
|
it ":html should generate a standalone html document" do
|
21
|
-
|
22
|
-
(Glyph::PROJECT/'output/html/test_project.html').exist
|
21
|
+
expect { Glyph.run! 'generate:html'}.not_to raise_error
|
22
|
+
expect((Glyph::PROJECT/'output/html/test_project.html').exist?).to eq(true)
|
23
23
|
end
|
24
24
|
|
25
25
|
it ":html5 should generate a standalone html document" do
|
26
26
|
Glyph['document.output'] = 'html5'
|
27
|
-
|
28
|
-
(Glyph::PROJECT/'output/html5/test_project.html').exist
|
27
|
+
expect { Glyph.run! 'generate:html5'}.not_to raise_error
|
28
|
+
expect((Glyph::PROJECT/'output/html5/test_project.html').exist?).to eq(true)
|
29
29
|
end
|
30
30
|
|
31
31
|
it ":pdf_through_html should generate a pdf document through html" do
|
32
32
|
Glyph['document.output'] = 'pdf'
|
33
|
-
|
34
|
-
(Glyph::PROJECT/'output/tmp/test_project.html').exist
|
35
|
-
(Glyph::PROJECT/'output/pdf/test_project.pdf').exist
|
33
|
+
expect { stdout_for { Glyph.run! 'generate:pdf_through_html'}}.not_to raise_error
|
34
|
+
expect((Glyph::PROJECT/'output/tmp/test_project.html').exist?).to eq(true)
|
35
|
+
expect((Glyph::PROJECT/'output/pdf/test_project.pdf').exist?).to eq(true)
|
36
36
|
end
|
37
37
|
|
38
38
|
it ":pdf_through_html5 should generate a pdf document through html5" do
|
39
39
|
Glyph['document.output'] = 'pdf'
|
40
|
-
|
41
|
-
(Glyph::PROJECT/'output/tmp/test_project.html').exist
|
42
|
-
(Glyph::PROJECT/'output/pdf/test_project.pdf').exist
|
40
|
+
expect { stdout_for { Glyph.run! 'generate:pdf_through_html5'}}.not_to raise_error
|
41
|
+
expect((Glyph::PROJECT/'output/tmp/test_project.html').exist?).to eq(true)
|
42
|
+
expect((Glyph::PROJECT/'output/pdf/test_project.pdf').exist?).to eq(true)
|
43
43
|
end
|
44
44
|
|
45
45
|
it ":mobi should generate a mobi document" do
|
46
46
|
Glyph['document.output'] = 'mobi'
|
47
|
-
|
48
|
-
(Glyph::PROJECT/'output/tmp/test_project.html').exist
|
49
|
-
(Glyph::PROJECT/'output/mobi/test_project.mobi').exist
|
47
|
+
expect { stdout_for { Glyph.run! 'generate:mobi'}}.not_to raise_error
|
48
|
+
expect((Glyph::PROJECT/'output/tmp/test_project.html').exist?).to eq(true)
|
49
|
+
expect((Glyph::PROJECT/'output/mobi/test_project.mobi').exist?).to eq(true)
|
50
50
|
end
|
51
51
|
|
52
52
|
it ":epub should generate an epub document" do
|
53
53
|
Glyph['document.output'] = 'epub'
|
54
54
|
#lambda {
|
55
55
|
stdout_for { Glyph.run! 'generate:epub'}#}.should_not raise_error
|
56
|
-
(Glyph::PROJECT/'output/tmp/test_project.html').exist
|
57
|
-
(Glyph::PROJECT/'output/epub/test_project.epub').exist
|
56
|
+
expect((Glyph::PROJECT/'output/tmp/test_project.html').exist?).to eq(true)
|
57
|
+
expect((Glyph::PROJECT/'output/epub/test_project.epub').exist?).to eq(true)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should copy images" do
|
61
61
|
dir = (Glyph::PROJECT/'images/test').mkpath
|
62
62
|
file_copy Glyph::HOME/'spec/files/ligature.jpg', Glyph::PROJECT/'images/test'
|
63
|
-
|
64
|
-
(Glyph::PROJECT/'output/html/images/test/ligature.jpg').exist
|
63
|
+
expect { Glyph.run! 'generate:html' }.not_to raise_error
|
64
|
+
expect((Glyph::PROJECT/'output/html/images/test/ligature.jpg').exist?).to eq(true)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "should copy styles if necessary" do
|
68
68
|
Glyph['document.styles'] = 'import'
|
69
69
|
require 'sass'
|
70
70
|
file_write Glyph::PROJECT/'document.glyph', "head[style[default.css]\nstyle[test.sass]]"
|
71
|
-
|
72
|
-
(Glyph::PROJECT/'output/html/styles/default.css').exist
|
73
|
-
(Glyph::PROJECT/'output/html/styles/test.css').exist
|
71
|
+
expect { Glyph.run! 'generate:html' }.not_to raise_error
|
72
|
+
expect((Glyph::PROJECT/'output/html/styles/default.css').exist?).to eq(true)
|
73
|
+
expect((Glyph::PROJECT/'output/html/styles/test.css').exist?).to eq(true)
|
74
74
|
end
|
75
75
|
|
76
76
|
it ":web should generate multiple html documents" do
|
@@ -85,10 +85,10 @@ describe "generate" do
|
|
85
85
|
# check that the user didn't create a styles or images directory under /text
|
86
86
|
reset_web.call
|
87
87
|
(Glyph::PROJECT/'text/images').mkdir
|
88
|
-
|
88
|
+
expect { Glyph.run! 'generate:web'}.to raise_error(RuntimeError, "You cannot have an 'images' directory under your 'text' directory.")
|
89
89
|
reset_web.call
|
90
90
|
(Glyph::PROJECT/'text/styles').mkdir
|
91
|
-
|
91
|
+
expect { Glyph.run! 'generate:web'}.to raise_error(RuntimeError, "You cannot have a 'styles' directory under your 'text' directory.")
|
92
92
|
reset_web.call
|
93
93
|
# check that the task can be run without errors
|
94
94
|
reset_web.call
|
@@ -97,23 +97,23 @@ describe "generate" do
|
|
97
97
|
Glyph.run! 'generate:web'
|
98
98
|
#}.should_not raise_error
|
99
99
|
# check that images are copied
|
100
|
-
(Glyph::PROJECT/'output/web/images/ligature.jpg').exist
|
100
|
+
expect((Glyph::PROJECT/'output/web/images/ligature.jpg').exist?).to eq(true)
|
101
101
|
# check that stylesheets are copied
|
102
|
-
(Glyph::PROJECT/'output/web/styles/default.css').exist
|
103
|
-
(Glyph::PROJECT/'output/web/styles/test.css').exist
|
102
|
+
expect((Glyph::PROJECT/'output/web/styles/default.css').exist?).to eq(true)
|
103
|
+
expect((Glyph::PROJECT/'output/web/styles/test.css').exist?).to eq(true)
|
104
104
|
# check that index.html is created
|
105
105
|
index = (Glyph::PROJECT/'output/web/index.html')
|
106
|
-
index.exist
|
107
|
-
compact_html(file_load(index)).
|
106
|
+
expect(index.exist?).to eq(true)
|
107
|
+
expect(compact_html(file_load(index))).to match(/<li class="section"><a href="\/test\/a\/b\/web2.html#h_7">Topic #2<\/a>/)
|
108
108
|
# check that topics are copied in the proper directories
|
109
109
|
web1 = (Glyph::PROJECT/'output/web/a/web1.html')
|
110
|
-
web1.exist
|
110
|
+
expect(web1.exist?).to eq(true)
|
111
111
|
web2 = (Glyph::PROJECT/'output/web/a/b/web2.html')
|
112
|
-
web2.exist
|
112
|
+
expect(web2.exist?).to eq(true)
|
113
113
|
# Check that placeholders are replaced correctly and that links are valid
|
114
|
-
file_load(web2).match(/<a href="\/test\/a\/web1\.html#w1_3">Test #1b<\/a>/).blank
|
115
|
-
file_load(web1).match(/<a href="\/test\/a\/b\/web2\.html#w2_1">Test #2a<\/a>/).blank
|
116
|
-
file_load(web1).match(/<a href="#w1_3">Test #1b<\/a>/).blank
|
114
|
+
expect(file_load(web2).match(/<a href="\/test\/a\/web1\.html#w1_3">Test #1b<\/a>/).blank?).to eq(false)
|
115
|
+
expect(file_load(web1).match(/<a href="\/test\/a\/b\/web2\.html#w2_1">Test #2a<\/a>/).blank?).to eq(false)
|
116
|
+
expect(file_load(web1).match(/<a href="#w1_3">Test #1b<\/a>/).blank?).to eq(false)
|
117
117
|
end
|
118
118
|
|
119
119
|
|