glyph 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.textile +8 -0
- data/CHANGELOG.textile +260 -0
- data/LICENSE.textile +26 -0
- data/README.textile +49 -21
- data/Rakefile +17 -7
- data/VERSION +1 -1
- data/book/config.yml +11 -5
- data/book/document.glyph +24 -13
- data/book/lib/macros/reference.rb +41 -14
- data/book/output/html/glyph.html +2298 -687
- data/book/output/pdf/glyph.pdf +6218 -2698
- data/book/script/authors +1 -0
- data/book/script/changelog +1 -0
- data/book/script/compile.rb +8 -0
- data/book/script/license +1 -0
- data/book/script/prof +1 -0
- data/book/script/prof_results.htm +21079 -0
- data/book/script/readme +1 -0
- data/book/snippets.yml +3 -4
- data/book/text/acknowledgement.glyph +8 -0
- data/book/text/authoring.glyph +548 -0
- data/book/text/changelog.glyph +76 -0
- data/book/text/extending.glyph +224 -0
- data/book/text/{getting_started.textile → getting_started.glyph} +30 -24
- data/book/text/{introduction.textile → introduction.glyph} +22 -12
- data/book/text/license.glyph +21 -0
- data/book/text/{ref_commands.textile → ref_commands.glyph} +30 -8
- data/book/text/ref_config.glyph +108 -0
- data/book/text/ref_macros.glyph +378 -0
- data/book/text/troubleshooting.glyph +179 -0
- data/config.yml +16 -4
- data/glyph.gemspec +83 -22
- data/lib/glyph.rb +164 -31
- data/lib/glyph/commands.rb +98 -23
- data/lib/glyph/document.rb +13 -7
- data/lib/glyph/glyph_language.rb +9 -1
- data/lib/glyph/glyph_language.treetop +1 -1
- data/lib/glyph/interpreter.rb +19 -9
- data/lib/glyph/macro.rb +88 -11
- data/lib/glyph/macro_validators.rb +48 -0
- data/lib/glyph/node.rb +13 -1
- data/lib/glyph/system_extensions.rb +0 -28
- data/macros/common.rb +125 -31
- data/macros/filters.rb +19 -13
- data/macros/html/block.rb +119 -68
- data/macros/html/inline.rb +29 -3
- data/macros/html/structure.rb +40 -40
- data/spec/files/article.glyph +5 -0
- data/spec/lib/commands_spec.rb +98 -3
- data/spec/lib/document_spec.rb +15 -2
- data/spec/lib/glyph_spec.rb +39 -10
- data/spec/lib/interpreter_spec.rb +8 -2
- data/spec/lib/macro_spec.rb +54 -6
- data/spec/lib/macro_validators_spec.rb +33 -0
- data/spec/lib/node_spec.rb +11 -3
- data/spec/macros/filters_spec.rb +5 -5
- data/spec/macros/macros_spec.rb +185 -8
- data/spec/macros/textile_spec.rb +217 -0
- data/spec/spec_helper.rb +25 -15
- data/spec/tasks/generate_spec.rb +3 -3
- data/spec/tasks/load_spec.rb +11 -1
- data/spec/tasks/project_spec.rb +0 -3
- data/styles/coderay.css +121 -0
- data/styles/default.css +54 -20
- data/{book/styles/css3.css → styles/pagination.css} +35 -7
- data/styles/ultraviolet/active4d.css +114 -0
- data/styles/ultraviolet/all_hallows_eve.css +72 -0
- data/styles/ultraviolet/amy.css +147 -0
- data/styles/ultraviolet/blackboard.css +88 -0
- data/styles/ultraviolet/brilliance_black.css +605 -0
- data/styles/ultraviolet/brilliance_dull.css +599 -0
- data/styles/ultraviolet/cobalt.css +149 -0
- data/styles/ultraviolet/dawn.css +121 -0
- data/styles/ultraviolet/eiffel.css +121 -0
- data/styles/ultraviolet/espresso_libre.css +109 -0
- data/styles/ultraviolet/idle.css +62 -0
- data/styles/ultraviolet/iplastic.css +80 -0
- data/styles/ultraviolet/lazy.css +73 -0
- data/styles/ultraviolet/mac_classic.css +123 -0
- data/styles/ultraviolet/magicwb_amiga.css +104 -0
- data/styles/ultraviolet/pastels_on_dark.css +188 -0
- data/styles/ultraviolet/slush_poppies.css +85 -0
- data/styles/ultraviolet/spacecadet.css +51 -0
- data/styles/ultraviolet/sunburst.css +180 -0
- data/styles/ultraviolet/twilight.css +137 -0
- data/styles/ultraviolet/zenburnesque.css +91 -0
- data/tasks/generate.rake +45 -26
- data/tasks/load.rake +21 -18
- data/tasks/project.rake +3 -1
- metadata +210 -41
- data/book/styles/default.css +0 -190
- data/book/text/authoring.textile +0 -351
- data/book/text/extending.textile +0 -148
- data/book/text/ref_config.textile +0 -0
- data/book/text/ref_macros.textile +0 -256
- data/book/text/troubleshooting.textile +0 -118
- data/styles/css3.css +0 -220
data/macros/html/inline.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
macro :anchor do
|
4
|
-
|
4
|
+
min_parameters 1
|
5
|
+
max_parameters 2
|
6
|
+
ident, title = params
|
5
7
|
macro_error "Bookmark '#{ident}' already exists" if bookmark? ident
|
6
8
|
bookmark :id => ident, :title => title
|
7
9
|
%{<a id="#{ident}">#{title}</a>}
|
@@ -12,7 +14,9 @@ macro :codeph do
|
|
12
14
|
end
|
13
15
|
|
14
16
|
macro :link do
|
15
|
-
|
17
|
+
min_parameters 1
|
18
|
+
max_parameters 2
|
19
|
+
href, title = params
|
16
20
|
if href.match /^#/ then
|
17
21
|
anchor = href.gsub(/^#/, '').to_sym
|
18
22
|
bmk = bookmark? anchor
|
@@ -31,13 +35,35 @@ macro :link do
|
|
31
35
|
end
|
32
36
|
|
33
37
|
macro :fmi do
|
34
|
-
|
38
|
+
exact_parameters 2, :level => :warning
|
39
|
+
topic, href = params
|
35
40
|
link = placeholder do |document|
|
36
41
|
interpret "link[#{href}]"
|
37
42
|
end
|
38
43
|
%{<span class="fmi">for more information on #{topic}, see #{link}</span>}
|
39
44
|
end
|
40
45
|
|
46
|
+
macro :draftcomment do
|
47
|
+
if Glyph['document.draft'] then
|
48
|
+
%{<span class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>#{@value}</span>}
|
49
|
+
else
|
50
|
+
""
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
macro :todo do
|
55
|
+
min_parameters 1
|
56
|
+
todo = "[#{@source}] -- #{@value}"
|
57
|
+
@node[:document].todos << todo unless @node[:document].todos.include? todo
|
58
|
+
if Glyph['document.draft'] then
|
59
|
+
%{<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>#{@value}</span>}
|
60
|
+
else
|
61
|
+
""
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
41
65
|
macro_alias :bookmark => :anchor
|
42
66
|
macro_alias '#' => :anchor
|
43
67
|
macro_alias '=>' => :link
|
68
|
+
macro_alias '!' => :todo
|
69
|
+
macro_alias :dc => :draftcomment
|
data/macros/html/structure.rb
CHANGED
@@ -1,61 +1,66 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
macro :div do
|
4
|
-
|
4
|
+
exact_parameters 1, :level => :warning
|
5
|
+
%{<div class="#{@name}">
|
6
|
+
#{@value}
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
</div>}
|
8
|
+
</div>}
|
9
9
|
end
|
10
10
|
|
11
11
|
macro :header do
|
12
|
-
|
12
|
+
min_parameters 1
|
13
|
+
max_parameters 2
|
14
|
+
title = params[0]
|
15
|
+
h_id = params[1]
|
16
|
+
h_id = nil if h_id.blank?
|
13
17
|
level = 1
|
14
18
|
@node.ascend do |n|
|
15
|
-
if
|
19
|
+
if Glyph["structure.headers"].include? n[:macro] then
|
16
20
|
level+=1
|
17
21
|
end
|
18
22
|
end
|
19
|
-
h_id = @params[1]
|
20
23
|
h_id ||= "h_#{@node[:document].headers.length+1}".to_sym
|
21
24
|
header :title => title, :level => level, :id => h_id
|
22
25
|
@node[:header] = h_id
|
23
26
|
macro_error "Bookmark '#{h_id}' already exists" if bookmark? h_id
|
24
27
|
bookmark :id => h_id, :title => title
|
25
|
-
%{
|
26
|
-
<h#{level} id="#{h_id}">#{title}</h#{level}>
|
27
|
-
}
|
28
|
+
%{<h#{level} id="#{h_id}">#{title}</h#{level}>}
|
28
29
|
end
|
29
30
|
|
30
31
|
macro :document do
|
32
|
+
exact_parameters 1, :level => :warning
|
31
33
|
%{<?xml version="1.0" encoding="utf-8"?>
|
32
34
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
33
35
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
34
|
-
|
36
|
+
#{@value}
|
37
|
+
|
35
38
|
</html>}
|
36
39
|
end
|
37
40
|
|
38
41
|
macro :body do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
exact_parameters 1, :level => :warning
|
43
|
+
%{<body>
|
44
|
+
#{@value}
|
45
|
+
|
46
|
+
</body>}
|
44
47
|
end
|
45
48
|
|
46
49
|
macro :head do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
exact_parameters 1, :level => :warning
|
51
|
+
%{<head>
|
52
|
+
<title>#{Glyph["document.title"]}</title>
|
53
|
+
<meta name="author" content="#{Glyph["document.author"]}" />
|
54
|
+
<meta name="copyright" content="#{Glyph["document.author"]}" />
|
55
|
+
<meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
|
56
|
+
#{@value}
|
57
|
+
</head>
|
58
|
+
}
|
55
59
|
end
|
56
60
|
|
57
61
|
macro :style do
|
58
|
-
file = Glyph::PROJECT/"styles/#{@value}"
|
62
|
+
file = Glyph.lite? ? Pathname.new(@value) : Glyph::PROJECT/"styles/#{@value}"
|
63
|
+
file = Pathname.new Glyph::HOME/'styles'/@value unless file.exist?
|
59
64
|
macro_error "Stylesheet '#{@value}' not found" unless file.exist?
|
60
65
|
style = ""
|
61
66
|
case file.extname
|
@@ -73,14 +78,13 @@ macro :style do
|
|
73
78
|
else
|
74
79
|
macro_error "Extension '#{file.extname}' not supported."
|
75
80
|
end
|
76
|
-
%{
|
77
|
-
|
78
|
-
|
79
|
-
</style>
|
80
|
-
}
|
81
|
+
%{<style type="text/css">
|
82
|
+
#{style}
|
83
|
+
</style>}
|
81
84
|
end
|
82
85
|
|
83
86
|
macro :toc do
|
87
|
+
no_parameters
|
84
88
|
link_header = lambda do |header|
|
85
89
|
%{<a href="##{header[:id]}">#{header[:title].gsub(/@(.+?)@/, '\1')}</a>}
|
86
90
|
end
|
@@ -89,16 +93,13 @@ macro :toc do
|
|
89
93
|
list = ""
|
90
94
|
added_headers ||= []
|
91
95
|
n1.descend do |n2, level|
|
92
|
-
if
|
93
|
-
next if n2.find_parent{|node|
|
96
|
+
if Glyph['structure.headers'].include?(n2[:macro])
|
97
|
+
next if n2.find_parent{|node| Glyph['structure.special'].include? node[:macro] }
|
94
98
|
header_id = n2.children.select{|n| n[:header]}[0][:header] rescue nil
|
95
99
|
next if added_headers.include? header_id
|
96
100
|
added_headers << header_id
|
97
101
|
# Check if part of frontmatter, bodymatter or backmatter
|
98
|
-
container = n2.find_parent{|node| node[:macro]
|
99
|
-
container ||= n2.find_parent{|node| node[:macro] == :bodymatter}[:macro] rescue nil
|
100
|
-
container ||= n2.find_parent{|node| node[:macro] == :appendix}[:macro] rescue nil
|
101
|
-
container ||= n2.find_parent{|node| node[:macro] == :backmatter}[:macro] rescue nil
|
102
|
+
container = n2.find_parent{|node| node[:macro].in? [:frontmatter, :bodymatter, :appendix, :backmatter]}[:macro] rescue nil
|
102
103
|
list << "<li class=\"#{container} #{n2[:macro]}\">#{link_header.call(document.header?(header_id))}</li>\n" if header_id
|
103
104
|
child_list = ""
|
104
105
|
n2.children.each do |c|
|
@@ -109,11 +110,10 @@ macro :toc do
|
|
109
110
|
end
|
110
111
|
list
|
111
112
|
end
|
112
|
-
%{
|
113
|
-
<div class="contents">
|
113
|
+
%{<div class="contents">
|
114
114
|
<h2 class="toc-header" id="h_toc">Table of Contents</h2>
|
115
115
|
<ol class="toc">
|
116
|
-
|
116
|
+
#{descend_section.call(document.structure, nil)}
|
117
117
|
</ol>
|
118
118
|
</div>}
|
119
119
|
end
|
@@ -126,7 +126,7 @@ end
|
|
126
126
|
|
127
127
|
macro_alias :section => :div
|
128
128
|
|
129
|
-
(
|
129
|
+
(Glyph['structure.frontmatter'] + Glyph['structure.bodymatter'] + Glyph['structure.backmatter']).
|
130
130
|
each {|s| macro_alias s => :div }
|
131
131
|
|
132
132
|
macro_alias :frontcover => :div
|
data/spec/lib/commands_spec.rb
CHANGED
@@ -9,12 +9,13 @@ describe "glyph" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
after do
|
12
|
+
Glyph.lite_mode = false
|
12
13
|
delete_project
|
13
14
|
end
|
14
15
|
|
15
16
|
it "[init] should create a project in the current directory" do
|
17
|
+
delete_project
|
16
18
|
Glyph.enable "project:create"
|
17
|
-
run_command_successfully(['init']).should == false
|
18
19
|
Dir.chdir Glyph::PROJECT.to_s
|
19
20
|
run_command_successfully(['init']).should == true
|
20
21
|
end
|
@@ -29,13 +30,19 @@ describe "glyph" do
|
|
29
30
|
create_project
|
30
31
|
run_command_successfully(["config", "test_setting", true]).should == true
|
31
32
|
Glyph::CONFIG.get(:test_setting).should == true
|
33
|
+
Glyph::PROJECT_CONFIG.read
|
32
34
|
Glyph::PROJECT_CONFIG.get('test_setting').should == true
|
35
|
+
Glyph::GLOBAL_CONFIG.read
|
33
36
|
Glyph::GLOBAL_CONFIG.get('test_setting').should_not == true
|
34
37
|
run_command_successfully(["config", "-g", "another.test", "something else"]).should == true
|
38
|
+
(Glyph::SPEC_DIR/'.glyphrc').exist?.should == true
|
35
39
|
Glyph::CONFIG.get("another.test").should == "something else"
|
40
|
+
Glyph::PROJECT_CONFIG.read
|
36
41
|
Glyph::PROJECT_CONFIG.get('another.test').should_not == "something else"
|
42
|
+
Glyph::GLOBAL_CONFIG.read
|
37
43
|
Glyph::GLOBAL_CONFIG.get('another.test').should == "something else"
|
38
44
|
run_command_successfully(["config", "-g", "yet.another.test", "something else", "extra argument"]).should == false
|
45
|
+
(Glyph::SPEC_DIR/'.glyphrc').unlink
|
39
46
|
end
|
40
47
|
|
41
48
|
it "[add] should create a new text file" do
|
@@ -57,7 +64,7 @@ describe "glyph" do
|
|
57
64
|
(Glyph::PROJECT/'output/html/test_project.html').exist?.should == true
|
58
65
|
end
|
59
66
|
|
60
|
-
it "[compile] should continue execution in case of macro errors" do
|
67
|
+
it "[compile] should not continue execution in case of macro errors" do
|
61
68
|
create_project
|
62
69
|
text = %{
|
63
70
|
=>[#invalid1]
|
@@ -68,16 +75,104 @@ describe "glyph" do
|
|
68
75
|
#[valid|Valid bookmark]
|
69
76
|
}
|
70
77
|
file_write Glyph::PROJECT/'document.glyph', text
|
71
|
-
res = run_command([
|
78
|
+
res = run_command(["compile"])
|
72
79
|
res.match(/Bookmark 'invalid1' does not exist/).should_not == nil
|
73
80
|
res.match(/Bookmark 'invalid2' does not exist/).should_not == nil
|
74
81
|
res.match(/Bookmark 'valid' does not exist/).should == nil
|
75
82
|
res.match(/Snippet 'invalid3' does not exist/).should_not == nil
|
76
83
|
end
|
77
84
|
|
85
|
+
it "[compile] should regenerate output with auto switch set" do
|
86
|
+
require 'timeout'
|
87
|
+
create_project
|
88
|
+
res = ''
|
89
|
+
|
90
|
+
compile_thread = Thread.new do
|
91
|
+
res = run_command(['-d', 'compile', '--auto'])
|
92
|
+
end
|
93
|
+
|
94
|
+
output_file = (Glyph::PROJECT/'output/html/test_project.html')
|
95
|
+
Timeout.timeout(5, StandardError) do loop do
|
96
|
+
break if output_file.file?
|
97
|
+
sleep 1
|
98
|
+
end end
|
99
|
+
output = file_load output_file
|
100
|
+
output_file.unlink
|
101
|
+
|
102
|
+
text_file = (Glyph::PROJECT/'text/container.textile')
|
103
|
+
text_file.unlink
|
104
|
+
|
105
|
+
file_write text_file, "section[\nheader[Container section]\nThis is another test.\n]\n"
|
106
|
+
|
107
|
+
Timeout.timeout(5, StandardError) do
|
108
|
+
loop do
|
109
|
+
break if output_file.file?
|
110
|
+
sleep 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
compile_thread.raise Interrupt
|
114
|
+
compile_thread.join
|
115
|
+
|
116
|
+
output2 = file_load output_file
|
117
|
+
output.should_not == output2
|
118
|
+
output2.match(/<p>This is another test.<\/p>/).should_not == nil
|
119
|
+
|
120
|
+
res.match(/Auto-regeneration enabled/).should_not == nil
|
121
|
+
res.match(/Regeneration started: 1 files changed/).should_not == nil
|
122
|
+
reset_quiet
|
123
|
+
end
|
124
|
+
|
78
125
|
it "[compile] should not compile the project in case of an unknown output format" do
|
126
|
+
reset_quiet
|
79
127
|
run_command_successfully(["compile", "-f", "wrong"]).should == false
|
80
128
|
end
|
81
129
|
|
130
|
+
it "[compile] should compile a single source file" do
|
131
|
+
reset_quiet
|
132
|
+
Dir.chdir Glyph::PROJECT
|
133
|
+
file_copy "#{Glyph::PROJECT}/../files/article.glyph", "#{Glyph::PROJECT}/article.glyph"
|
134
|
+
file_copy "#{Glyph::PROJECT}/../files/ligature.jpg", "#{Glyph::PROJECT}/ligature.jpg"
|
135
|
+
run_command_successfully(["compile", "article.glyph"]).should == true
|
136
|
+
Pathname.new('article.html').exist?.should == true
|
137
|
+
file_load('article.html').gsub(/\t|\n/, '').should == %{
|
138
|
+
<div class="section">
|
139
|
+
Test -- Test Snippet
|
140
|
+
</div>
|
141
|
+
}.gsub(/\t|\n/, '')
|
142
|
+
Glyph.enable 'generate:html'
|
143
|
+
(Glyph::PROJECT/'article.html').unlink
|
144
|
+
Glyph['document.output'] = 'pdf'
|
145
|
+
run_command_successfully(["compile", "article.glyph"]).should == true
|
146
|
+
(Glyph::PROJECT/'article.html').exist?.should == true
|
147
|
+
(Glyph::PROJECT/'article.pdf').exist?.should == true
|
148
|
+
Glyph.lite_mode = false
|
149
|
+
end
|
150
|
+
|
151
|
+
it "[compile] should compile a single source file to a custom destination" do
|
152
|
+
reset_quiet
|
153
|
+
Dir.chdir Glyph::PROJECT
|
154
|
+
file_copy "#{Glyph::PROJECT}/../files/article.glyph", "#{Glyph::PROJECT}/article.glyph"
|
155
|
+
file_copy "#{Glyph::PROJECT}/../files/ligature.jpg", "#{Glyph::PROJECT}/ligature.jpg"
|
156
|
+
run_command_successfully(["compile", "article.glyph", "out/article.htm"]).should == true
|
157
|
+
Glyph.lite_mode = false
|
158
|
+
Pathname.new('out/article.htm').exist?.should == true
|
159
|
+
end
|
160
|
+
|
161
|
+
it "[compile] should finalize the document in case of errors in included files" do
|
162
|
+
create_project
|
163
|
+
file_write Glyph::PROJECT/'document.glyph', "section[header[Test]\n@[errors.glyph]\n@[syntax_error.glyph]]"
|
164
|
+
file_write Glyph::PROJECT/'text/errors.glyph', "not[a|b]"
|
165
|
+
file_write Glyph::PROJECT/'text/syntax_error.glyph', "$[a"
|
166
|
+
err = "Document cannot be finalized due to previous errors"
|
167
|
+
res = run_command(["compile"])
|
168
|
+
out = file_load Glyph::PROJECT/'output/html/test_project.html'
|
169
|
+
out.should == %{<div class="section">
|
170
|
+
<h2 id="h_1">Test</h2>
|
171
|
+
<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>Correct errors in file 'errors.glyph'</span>
|
172
|
+
<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>Correct errors in file 'syntax_error.glyph'</span>
|
173
|
+
|
174
|
+
</div>}
|
175
|
+
res.match("error: #{err}").should == nil
|
176
|
+
end
|
82
177
|
|
83
178
|
end
|
data/spec/lib/document_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
#!/usr/bin/env ruby
|
2
4
|
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
3
5
|
|
@@ -11,7 +13,6 @@ describe Glyph::Document do
|
|
11
13
|
create_doc = lambda {|tree| }
|
12
14
|
@tree = create_tree "test[test[test[Test\\|\\]...]]]"
|
13
15
|
@doc = create_doc @tree
|
14
|
-
|
15
16
|
end
|
16
17
|
|
17
18
|
it "should expose document data" do
|
@@ -95,6 +96,18 @@ describe Glyph::Document do
|
|
95
96
|
doc.output.gsub(/\n|\t/, '')[0..14].should == "Total: 4 tests."
|
96
97
|
end
|
97
98
|
|
98
|
-
|
99
|
+
it "should substitute escaped pipes only when finalizing the document" do
|
100
|
+
define_em_macro
|
101
|
+
define_ref_macro
|
102
|
+
text = %{em[ref[link with ref[fake \\| parameter]]]}
|
103
|
+
# Nevermind the absurdity. It's just to test that the escaped pipes
|
104
|
+
# are handled properly.
|
105
|
+
result = %{<em><a href="link with <a href="fake | parameter"></a>"></a></em>}
|
106
|
+
tree = create_tree text
|
107
|
+
doc = create_doc tree
|
108
|
+
doc.analyze
|
109
|
+
doc.finalize
|
110
|
+
doc.output.should == result
|
111
|
+
end
|
99
112
|
end
|
100
113
|
|
data/spec/lib/glyph_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Glyph do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should initialize a rake app and tasks" do
|
11
|
-
|
11
|
+
Rake.application.tasks.length.should > 0
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should run rake tasks" do
|
@@ -42,19 +42,28 @@ describe Glyph do
|
|
42
42
|
create_project
|
43
43
|
Glyph.run! 'load:macros'
|
44
44
|
macros = [:anchor, :link, :codeph, :fmi, :note, :box, :code, :title, :subtitle,
|
45
|
-
:img, :fig, :author, :pubdate, :table, :td, :tr, :th, :comment, :todo, :snippet,
|
46
|
-
:include, :config, :ruby, :escape, :textile, :markdown, :div, :header, :document, :body,
|
47
|
-
:head, :style, :toc, :section
|
45
|
+
:img, :fig, :author, :pubdate, :table, :td, :tr, :th, :comment, :todo, :snippet, "snippet:",
|
46
|
+
:include, :config, "config:", :ruby, :escape, :textile, :markdown, :div, :header, :document, :body,
|
47
|
+
:head, :style, :toc, :section, :condition, :eq, :and, :or, :not, :match, :highlight, "macro:",
|
48
|
+
:encode, :decode, :draftcomment]
|
48
49
|
aliases = [
|
49
50
|
[[:bookmark, "#"], :anchor],
|
50
51
|
[["=>"], :link],
|
51
52
|
[[:important, :caution, :tip], :note],
|
52
53
|
[["@"], :include],
|
53
54
|
[["&"], :snippet],
|
55
|
+
[["&:"], "snippet:"],
|
56
|
+
[["%:"], "macro:"],
|
57
|
+
[["?"], "condition"],
|
54
58
|
[["$"], :config],
|
59
|
+
[["$:"], "config:"],
|
55
60
|
[["%"], :ruby],
|
56
61
|
[["."], :escape],
|
57
62
|
[["--"], :comment],
|
63
|
+
[[:dc], :draftcomment],
|
64
|
+
[["!"], :todo],
|
65
|
+
[["*"], :encode],
|
66
|
+
[["**"], :decode],
|
58
67
|
[[:md], :markdown],
|
59
68
|
[[:frontcover, :titlepage, :halftitlepage, :frontmatter, :bodymatter, :backmatter, :backcover], :div]]
|
60
69
|
total = 0
|
@@ -63,14 +72,34 @@ describe Glyph do
|
|
63
72
|
arr.each {|v| total += 1; Glyph::MACROS[v.to_sym].should == Glyph::MACROS[target.to_sym]}
|
64
73
|
end
|
65
74
|
aliases.each { |v| check_aliases.call v[0], v[1] }
|
66
|
-
check_aliases.call
|
67
|
-
check_aliases.call
|
68
|
-
check_aliases.call
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
check_aliases.call Glyph['structure.frontmatter'], :div
|
76
|
+
check_aliases.call Glyph['structure.bodymatter'], :div
|
77
|
+
check_aliases.call Glyph['structure.backmatter'], :div
|
78
|
+
Glyph['structure.frontmatter'].length.should == 8
|
79
|
+
Glyph['structure.bodymatter'].length.should == 4
|
80
|
+
Glyph['structure.backmatter'].length.should == 13
|
72
81
|
#puts Glyph::MACROS.keys.map{|i| i.to_s}.sort.to_yaml
|
73
82
|
total.should == Glyph::MACROS.length
|
74
83
|
end
|
75
84
|
|
85
|
+
it "should provide a filter method to convert raw text into HTML" do
|
86
|
+
Glyph['document.title'] = "Test"
|
87
|
+
Glyph.filter("title[]").gsub(/\n|\t/, '').should == "<h1>Test</h1>"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should provide a compile method to compile files in lite mode" do
|
91
|
+
file_copy Glyph::PROJECT/'../files/article.glyph', Glyph::PROJECT/'article.glyph'
|
92
|
+
lambda { Glyph.compile Glyph::PROJECT/'article.glyph' }.should_not raise_error
|
93
|
+
reset_quiet
|
94
|
+
(Glyph::PROJECT/'article.html').exist?.should == true
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should provide a reset method to remove config overrides, reenable tasks, clear macros and snippets." do
|
98
|
+
Glyph['test_setting'] = true
|
99
|
+
Glyph.reset
|
100
|
+
Glyph::SNIPPETS.length.should == 0
|
101
|
+
Glyph::MACROS.length.should == 0
|
102
|
+
Glyph['test_setting'].should == nil
|
103
|
+
end
|
104
|
+
|
76
105
|
end
|