glyph 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +19 -40
- data/benchmark.rb +1 -2
- data/book/config.yml +8 -8
- data/book/document.glyph +18 -19
- data/book/images/glyph/commands_tasks.png +0 -0
- data/book/lib/layouts/bookindex.glyph +113 -111
- data/book/lib/layouts/bookpage.glyph +112 -108
- data/book/lib/macros/reference.rb +2 -2
- data/book/lib/tasks/tasks.rake +1 -1
- data/book/text/acknowledgements.glyph +1 -0
- data/book/text/changelog.glyph +140 -112
- data/book/text/compiling/compiling.glyph +36 -24
- data/book/text/compiling/lite_mode.glyph +11 -11
- data/book/text/compiling/programmatic_usage.glyph +57 -57
- data/book/text/config/document.glyph +7 -1
- data/book/text/config/options.glyph +5 -3
- data/book/text/config/output.glyph +41 -8
- data/book/text/extending/bookmarks_headers.glyph +13 -11
- data/book/text/extending/command.glyph +1 -1
- data/book/text/extending/commands_tasks.glyph +2 -2
- data/book/text/extending/internals.glyph +29 -29
- data/book/text/extending/interpreting.glyph +48 -9
- data/book/text/extending/macro_def.glyph +80 -32
- data/book/text/extending/output_format.glyph +2 -2
- data/book/text/extending/placeholders.glyph +27 -15
- data/book/text/extending/validators.glyph +1 -1
- data/book/text/getting_started/configuration.glyph +1 -1
- data/book/text/getting_started/create_project.glyph +4 -5
- data/book/text/getting_started/structure.glyph +2 -2
- data/book/text/macros/macros_core.glyph +341 -199
- data/book/text/macros/macros_filters.glyph +1 -1
- data/book/text/macros/macros_inline.glyph +3 -3
- data/book/text/macros/macros_structure.glyph +1 -1
- data/book/text/ref_commands.glyph +98 -93
- data/book/text/snippets.glyph +18 -0
- data/book/text/stats/bookmarks.glyph +16 -16
- data/book/text/stats/links.glyph +23 -23
- data/book/text/stats/macros.glyph +14 -14
- data/book/text/stats/snippets.glyph +26 -26
- data/book/text/stats/stats.glyph +14 -15
- data/book/text/text_editing/attribute_intro.glyph +8 -8
- data/book/text/text_editing/code.glyph +16 -16
- data/book/text/text_editing/conditionals.glyph +12 -13
- data/book/text/text_editing/esc_quot.glyph +3 -3
- data/book/text/text_editing/evaluation.glyph +57 -3
- data/book/text/text_editing/inclusions.glyph +34 -25
- data/book/text/text_editing/macro_composition.glyph +28 -0
- data/book/text/text_editing/macro_intro.glyph +4 -4
- data/book/text/text_editing/section_aliases.glyph +23 -23
- data/book/text/text_editing/sections.glyph +22 -22
- data/book/text/text_editing/stylesheets.glyph +33 -33
- data/book/text/text_editing/topics.glyph +6 -6
- data/book/text/text_editing/xml_fallback.glyph +1 -1
- data/book/text/troubleshooting/errors_command.glyph +4 -4
- data/book/text/troubleshooting/errors_generic.glyph +16 -10
- data/book/text/troubleshooting/errors_macro.glyph +18 -21
- data/book/text/troubleshooting/errors_parser.glyph +7 -7
- data/config.yml +51 -29
- data/document.glyph +18 -18
- data/glyph.gemspec +39 -287
- data/layouts/web5/topic.glyph +1 -1
- data/lib/glyph.rb +42 -10
- data/lib/glyph/analyzer.rb +5 -2
- data/lib/glyph/bookmark.rb +3 -1
- data/lib/glyph/commands.rb +11 -9
- data/lib/glyph/commands/add.rb +3 -1
- data/lib/glyph/commands/compile.rb +10 -7
- data/lib/glyph/commands/config.rb +7 -5
- data/lib/glyph/commands/init.rb +2 -0
- data/lib/glyph/commands/outline.rb +2 -0
- data/lib/glyph/commands/stats.rb +3 -0
- data/lib/glyph/commands/todo.rb +2 -0
- data/lib/glyph/config.rb +2 -0
- data/lib/glyph/document.rb +34 -9
- data/lib/glyph/interpreter.rb +2 -0
- data/lib/glyph/macro.rb +97 -25
- data/lib/glyph/macro_validators.rb +9 -6
- data/lib/glyph/node.rb +3 -1
- data/lib/glyph/parser.rb +68 -33
- data/lib/glyph/reporter.rb +3 -1
- data/lib/glyph/syntax_node.rb +23 -28
- data/lib/glyph/system_extensions.rb +21 -0
- data/lib/glyph/utils.rb +24 -4
- data/macros/block.rb +111 -0
- data/macros/core.rb +163 -33
- data/macros/filters.rb +3 -2
- data/macros/inline.rb +97 -0
- data/macros/reps/html.rb +180 -0
- data/macros/reps/html5.rb +100 -0
- data/macros/reps/web.rb +4 -0
- data/macros/reps/web5.rb +4 -0
- data/macros/structure.rb +229 -0
- data/macros/xml.rb +29 -24
- data/spec/config.yml +7 -0
- data/spec/files/article.glyph +2 -2
- data/spec/files/web_doc.glyph +9 -5
- data/spec/lib/commands_spec.rb +13 -9
- data/spec/lib/config_spec.rb +2 -2
- data/spec/lib/document_spec.rb +10 -0
- data/spec/lib/glyph_spec.rb +30 -8
- data/spec/lib/macro_spec.rb +39 -4
- data/spec/lib/macro_validators_spec.rb +3 -4
- data/spec/lib/parser_spec.rb +7 -0
- data/spec/lib/reporter_spec.rb +1 -0
- data/spec/lib/syntax_node_spec.rb +40 -6
- data/spec/macros/core_spec.rb +154 -21
- data/spec/macros/filters_spec.rb +1 -1
- data/spec/macros/html5_spec.rb +4 -5
- data/spec/macros/macros_spec.rb +6 -7
- data/spec/macros/web5_spec.rb +3 -3
- data/spec/macros/web_spec.rb +10 -7
- data/spec/macros/xml_spec.rb +11 -2
- data/spec/spec_helper.rb +11 -5
- data/spec/tasks/generate_spec.rb +40 -5
- data/spec/tasks/load_spec.rb +1 -13
- data/styles/coderay.css +147 -38
- data/styles/default.css +19 -22
- data/styles/pagination.css +30 -30
- data/tasks/generate.rake +54 -18
- data/tasks/load.rake +9 -24
- data/tasks/project.rake +0 -2
- metadata +208 -207
- data/.gitignore +0 -7
- data/VERSION +0 -1
- data/book/snippets.yml +0 -18
- data/lib/glyph/macro_helpers.rb +0 -282
- data/macros/html/block.rb +0 -124
- data/macros/html/inline.rb +0 -42
- data/macros/html/structure.rb +0 -191
- data/macros/html5/block.rb +0 -69
- data/macros/html5/inline.rb +0 -24
- data/macros/html5/structure.rb +0 -140
data/macros/html/structure.rb
DELETED
@@ -1,191 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
macro :section do
|
4
|
-
max_parameters 1
|
5
|
-
if raw_attribute(:src) && Glyph.multiple_output_files? then
|
6
|
-
required_attribute :title
|
7
|
-
end
|
8
|
-
procs = {}
|
9
|
-
procs[:title] = lambda do |level, ident, title|
|
10
|
-
%{<h#{level} id="#{ident}">#{title}</h#{level}>\n}
|
11
|
-
end
|
12
|
-
procs[:body] = lambda do |title, value|
|
13
|
-
%{<div class="#{@name}">
|
14
|
-
#{title}#{value}
|
15
|
-
|
16
|
-
</div>}
|
17
|
-
end
|
18
|
-
section_element_for procs
|
19
|
-
end
|
20
|
-
|
21
|
-
macro :article do
|
22
|
-
exact_parameters 1
|
23
|
-
head = raw_attr(:head)
|
24
|
-
head ||= %{style[default.css]}
|
25
|
-
pre_title = raw_attr(:"pre-title")
|
26
|
-
post_title = raw_attr(:"post-title")
|
27
|
-
pubdate = @node.attr(:pubdate) ? "div[@class[pubdate]#{@node.attr(:pubdate).contents}]" : "pubdate[]"
|
28
|
-
halftitlepage = raw_attr(:halftitlepage)
|
29
|
-
halftitlepage ||= %{
|
30
|
-
#{pre_title}
|
31
|
-
title[]
|
32
|
-
subtitle[]
|
33
|
-
author[]
|
34
|
-
#{pubdate}
|
35
|
-
#{post_title}
|
36
|
-
}
|
37
|
-
interpret %{document[
|
38
|
-
head[#{head}]
|
39
|
-
body[
|
40
|
-
halftitlepage[
|
41
|
-
#{halftitlepage}
|
42
|
-
]
|
43
|
-
#{@node.value}
|
44
|
-
]
|
45
|
-
]}
|
46
|
-
end
|
47
|
-
|
48
|
-
macro :book do
|
49
|
-
no_parameters
|
50
|
-
head = raw_attr(:head)
|
51
|
-
head ||= %{style[default.css]}
|
52
|
-
pre_title = raw_attr(:"pre-title")
|
53
|
-
post_title = raw_attr(:"post-title")
|
54
|
-
titlepage = raw_attr(:titlepage)
|
55
|
-
pubdate = @node.attr(:pubdate) ? "div[@class[pubdate]#{@node.attr(:pubdate).contents}]" : "pubdate[]"
|
56
|
-
titlepage ||= %{
|
57
|
-
#{pre_title}
|
58
|
-
title[]
|
59
|
-
subtitle[]
|
60
|
-
revision[]
|
61
|
-
author[]
|
62
|
-
#{pubdate}
|
63
|
-
#{post_title}
|
64
|
-
}
|
65
|
-
frontmatter = raw_attr(:frontmatter)
|
66
|
-
bodymatter = raw_attr(:bodymatter)
|
67
|
-
backmatter = raw_attr(:backmatter)
|
68
|
-
frontmatter = "frontmatter[\n#{frontmatter}\n]" if frontmatter
|
69
|
-
bodymatter = "bodymatter[\n#{bodymatter}\n]" if bodymatter
|
70
|
-
backmatter = "backmatter[\n#{backmatter}\n]" if backmatter
|
71
|
-
interpret %{document[
|
72
|
-
head[#{head}]
|
73
|
-
body[
|
74
|
-
titlepage[
|
75
|
-
#{titlepage}
|
76
|
-
]
|
77
|
-
#{frontmatter}
|
78
|
-
#{bodymatter}
|
79
|
-
#{backmatter}
|
80
|
-
]
|
81
|
-
]}
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
macro :document do
|
86
|
-
exact_parameters 1
|
87
|
-
%{<?xml version="1.0" encoding="utf-8"?>
|
88
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
89
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
90
|
-
#{value}
|
91
|
-
|
92
|
-
</html>}
|
93
|
-
end
|
94
|
-
|
95
|
-
macro :head do
|
96
|
-
exact_parameters 1
|
97
|
-
author = Glyph['document.author'].blank? ? "" : %{<meta name="author" content="#{Glyph["document.author"]}" />
|
98
|
-
}
|
99
|
-
copy = Glyph['document.author'].blank? ? "" : %{<meta name="copyright" content="#{Glyph["document.author"]}" />}
|
100
|
-
%{<head>
|
101
|
-
<title>#{Glyph["document.title"]}</title>
|
102
|
-
#{author}
|
103
|
-
#{copy}
|
104
|
-
<meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
|
105
|
-
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
106
|
-
#{value}
|
107
|
-
</head>
|
108
|
-
}
|
109
|
-
end
|
110
|
-
|
111
|
-
macro :style do
|
112
|
-
within :head
|
113
|
-
exact_parameters 1
|
114
|
-
file = Glyph.lite? ? Pathname.new(value) : Glyph::PROJECT/"styles/#{value}"
|
115
|
-
file = Pathname.new Glyph::HOME/'styles'/value unless file.exist?
|
116
|
-
macro_error "Stylesheet '#{value}' not found" unless file.exist?
|
117
|
-
|
118
|
-
@node[:document].style file
|
119
|
-
case Glyph['document.styles'].to_s
|
120
|
-
when 'embed' then
|
121
|
-
style = ""
|
122
|
-
case file.extname
|
123
|
-
when ".css" then
|
124
|
-
style = file_load file
|
125
|
-
when ".sass", ".scss" then
|
126
|
-
begin
|
127
|
-
require 'sass'
|
128
|
-
style = Sass::Engine.new(file_load(file), :syntax => file.extname.gsub(/^\./, '').to_sym).render
|
129
|
-
rescue LoadError
|
130
|
-
macro_error "Haml is not installed. Please run: gem install haml"
|
131
|
-
rescue Exception
|
132
|
-
raise
|
133
|
-
end
|
134
|
-
else
|
135
|
-
macro_error "Extension '#{file.extname}' not supported."
|
136
|
-
end
|
137
|
-
%{<style type="text/css">
|
138
|
-
#{style}
|
139
|
-
</style>}
|
140
|
-
when 'import' then
|
141
|
-
%{<style type="text/css">
|
142
|
-
@import url("#{Glyph["output.#{Glyph['document.output']}.base"]}styles/#{value.gsub(/\..+$/, '.css')}");
|
143
|
-
</style>}
|
144
|
-
when 'link' then
|
145
|
-
%{<link href="#{Glyph["output.#{Glyph['document.output']}.base"]}styles/#{value.gsub(/\..+$/, '.css')}" rel="stylesheet" type="text/css" />}
|
146
|
-
else
|
147
|
-
macro_error "Value '#{Glyph['document.styles']}' not allowed for 'document.styles' setting"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
macro :toc do
|
152
|
-
max_parameters 1
|
153
|
-
link_proc = lambda do |head|
|
154
|
-
(!Glyph.multiple_output_files? || (head.definition != head.file)) ? %{<a href="#{head.link(@source_file)}">#{head.title}</a>} : head.title
|
155
|
-
end
|
156
|
-
toc_list_proc = lambda do |descend_proc, bmk, document|
|
157
|
-
%{<div class="contents">
|
158
|
-
<h2 class="toc-header" id="#{bmk}">#{bmk.title}</h2>
|
159
|
-
<ol class="toc">
|
160
|
-
#{descend_proc.call(document.structure, nil)}
|
161
|
-
</ol>
|
162
|
-
</div>}
|
163
|
-
end
|
164
|
-
toc_item_proc = lambda do |classes, header|
|
165
|
-
"<li class=\"#{classes.join(" ").strip}\">#{header}</li>"
|
166
|
-
end
|
167
|
-
toc_sublist_proc = lambda do |contents|
|
168
|
-
"<li><ol>#{contents}</ol></li>\n"
|
169
|
-
end
|
170
|
-
toc_element_for param(0), attr(:title),
|
171
|
-
:link => link_proc,
|
172
|
-
:toc_list => toc_list_proc,
|
173
|
-
:toc_item => toc_item_proc,
|
174
|
-
:toc_sublist => toc_sublist_proc
|
175
|
-
end
|
176
|
-
|
177
|
-
# See:
|
178
|
-
# http://microformats.org/wiki/book-brainstorming
|
179
|
-
# http://en.wikipedia.org/wiki/Book_design
|
180
|
-
|
181
|
-
(Glyph['system.structure.frontmatter'] + Glyph['system.structure.bodymatter'] + Glyph['system.structure.backmatter']).
|
182
|
-
each {|s| macro_alias s => :section }
|
183
|
-
|
184
|
-
macro_alias "§" => :section
|
185
|
-
macro_alias :frontcover => :section
|
186
|
-
macro_alias :titlepage => :section
|
187
|
-
macro_alias :halftitlepage => :section
|
188
|
-
macro_alias :frontmatter => :section
|
189
|
-
macro_alias :bodymatter => :section
|
190
|
-
macro_alias :backmatter => :section
|
191
|
-
macro_alias :backcover => :section
|
data/macros/html5/block.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
macro :note do
|
4
|
-
%{<aside class="#{@name}">
|
5
|
-
<span class="note-title">#{@name.to_s.capitalize}</span>#{value}
|
6
|
-
|
7
|
-
</aside>}
|
8
|
-
end
|
9
|
-
|
10
|
-
macro :box do
|
11
|
-
exact_parameters 2
|
12
|
-
%{<aside class="box">
|
13
|
-
<div class="box-title">#{param(0)}</div>
|
14
|
-
#{param(1)}
|
15
|
-
|
16
|
-
</aside>}
|
17
|
-
end
|
18
|
-
|
19
|
-
macro :figure do
|
20
|
-
min_parameters 1
|
21
|
-
max_parameters 2
|
22
|
-
image = param(0)
|
23
|
-
alt = "@alt[-]" unless attr(:alt)
|
24
|
-
caption = "figcaption[#{param(1)}]" rescue nil
|
25
|
-
figure_element_for image, alt, caption do |alt, dest_file, caption|
|
26
|
-
interpret %{=figure[
|
27
|
-
img[#{alt}@src[#{Glyph["output.#{Glyph['document.output']}.base"]}#{dest_file}]#{@node.attrs.join}]
|
28
|
-
#{caption}
|
29
|
-
]}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
macro :pubdate do
|
34
|
-
no_parameters
|
35
|
-
t = Time.now
|
36
|
-
%{<time class="pubdate" datetime="#{t.strftime("%Y-%m-%d")}">
|
37
|
-
#{Time.now.strftime("%B %Y")}
|
38
|
-
</time>}
|
39
|
-
end
|
40
|
-
|
41
|
-
macro :navigation do
|
42
|
-
exact_parameters 1
|
43
|
-
procs = {}
|
44
|
-
procs[:contents] = lambda do
|
45
|
-
%{<a href="#{Glyph["output.#{Glyph['document.output']}.base"]}index.html">Contents</a>}
|
46
|
-
end
|
47
|
-
procs[:previous] = lambda do |topic|
|
48
|
-
if topic then
|
49
|
-
%{<a href="#{Glyph["output.#{Glyph['document.output']}.base"]}#{topic[:src].gsub(/\..+$/, '.html')}">#{topic[:title]} ←</a>}
|
50
|
-
else
|
51
|
-
""
|
52
|
-
end
|
53
|
-
end
|
54
|
-
procs[:next] = lambda do |topic|
|
55
|
-
if topic then
|
56
|
-
%{<a href="#{Glyph["output.#{Glyph['document.output']}.base"]}#{topic[:src].gsub(/\..+$/, '.html')}">→ #{topic[:title]}</a>}
|
57
|
-
else
|
58
|
-
""
|
59
|
-
end
|
60
|
-
end
|
61
|
-
procs[:navigation] = lambda do |contents, prev_link, next_link|
|
62
|
-
%{<nav>#{prev_link}#{contents}#{next_link}</nav>}
|
63
|
-
end
|
64
|
-
navigation_element_for param(0).to_sym, procs
|
65
|
-
end
|
66
|
-
|
67
|
-
macro_alias :important => :note
|
68
|
-
macro_alias :tip => :note
|
69
|
-
macro_alias :caution => :note
|
data/macros/html5/inline.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
macro :fmi do
|
4
|
-
exact_parameters 2, :level => :warning
|
5
|
-
fmi_element_for param(0), param(1) do |topic, link|
|
6
|
-
%{<span class="fmi">for more information on <mark>#{topic}</mark>, see #{link}</span>}
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
macro :draftcomment do
|
11
|
-
draftcomment_element do |value|
|
12
|
-
%{<aside class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>#{value}</aside>}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
macro :todo do
|
17
|
-
exact_parameters 1
|
18
|
-
todo_element do |value|
|
19
|
-
%{<aside class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>#{value}</aside>}
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
macro_alias '!' => :todo
|
24
|
-
macro_alias :dc => :draftcomment
|
data/macros/html5/structure.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
macro :section do
|
4
|
-
max_parameters 1
|
5
|
-
if raw_attribute(:src) && Glyph.multiple_output_files? then
|
6
|
-
required_attribute :title
|
7
|
-
end
|
8
|
-
procs = {}
|
9
|
-
procs[:title] = lambda do |level, ident, title|
|
10
|
-
%{<header><h1 id="#{ident}">#{title}</h1></header>\n}
|
11
|
-
end
|
12
|
-
procs[:body] = lambda do |title, value|
|
13
|
-
%{<section class="#{@name}">
|
14
|
-
#{title}#{value}
|
15
|
-
|
16
|
-
</section>}
|
17
|
-
end
|
18
|
-
section_element_for procs
|
19
|
-
end
|
20
|
-
|
21
|
-
macro :article do
|
22
|
-
exact_parameters 1
|
23
|
-
head = raw_attr(:head)
|
24
|
-
head ||= %{style[default.css]}
|
25
|
-
pre_title = raw_attr(:"pre-title")
|
26
|
-
post_title = raw_attr(:"post-title")
|
27
|
-
pubdate = @node.attr(:pubdate) ? "time[@class[pubdate]#{@node.attr(:pubdate).contents}]" : "pubdate[]"
|
28
|
-
halftitlepage = raw_attr(:halftitlepage)
|
29
|
-
halftitlepage ||= %{
|
30
|
-
#{pre_title}
|
31
|
-
hgroup[
|
32
|
-
title[]
|
33
|
-
subtitle[]
|
34
|
-
]
|
35
|
-
author[]
|
36
|
-
#{pubdate}
|
37
|
-
#{post_title}
|
38
|
-
}
|
39
|
-
interpret %{document[
|
40
|
-
head[#{head}]
|
41
|
-
body[
|
42
|
-
=article[
|
43
|
-
halftitlepage[
|
44
|
-
#{halftitlepage}
|
45
|
-
]
|
46
|
-
#{@node.value}
|
47
|
-
]
|
48
|
-
]
|
49
|
-
]}
|
50
|
-
end
|
51
|
-
|
52
|
-
macro :book do
|
53
|
-
no_parameters
|
54
|
-
head = raw_attr(:head)
|
55
|
-
head ||= %{style[default.css]}
|
56
|
-
pre_title = raw_attr(:"pre-title")
|
57
|
-
post_title = raw_attr(:"post-title")
|
58
|
-
titlepage = raw_attr(:titlepage)
|
59
|
-
pubdate = @node.attr(:pubdate) ? "time[@class[pubdate]#{@node.attr(:pubdate).contents}]" : "pubdate[]"
|
60
|
-
titlepage ||= %{
|
61
|
-
#{pre_title}
|
62
|
-
hgroup[
|
63
|
-
title[]
|
64
|
-
subtitle[]
|
65
|
-
]
|
66
|
-
revision[]
|
67
|
-
author[]
|
68
|
-
#{pubdate}
|
69
|
-
#{post_title}
|
70
|
-
}
|
71
|
-
frontmatter = raw_attr(:frontmatter)
|
72
|
-
bodymatter = raw_attr(:bodymatter)
|
73
|
-
backmatter = raw_attr(:backmatter)
|
74
|
-
frontmatter = "frontmatter[\n#{frontmatter}\n]" if frontmatter
|
75
|
-
bodymatter = "bodymatter[\n#{bodymatter}\n]" if bodymatter
|
76
|
-
backmatter = "backmatter[\n#{backmatter}\n]" if backmatter
|
77
|
-
interpret %{document[
|
78
|
-
head[#{head}]
|
79
|
-
body[
|
80
|
-
titlepage[
|
81
|
-
#{titlepage}
|
82
|
-
]
|
83
|
-
#{frontmatter}
|
84
|
-
#{bodymatter}
|
85
|
-
#{backmatter}
|
86
|
-
]
|
87
|
-
]}
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
macro :document do
|
92
|
-
exact_parameters 1
|
93
|
-
%{<!DOCTYPE html>
|
94
|
-
<html lang="en">
|
95
|
-
#{value}
|
96
|
-
|
97
|
-
</html>}
|
98
|
-
end
|
99
|
-
|
100
|
-
macro :toc do
|
101
|
-
max_parameters 1
|
102
|
-
link_proc = lambda do |head|
|
103
|
-
(!Glyph.multiple_output_files? || (head.definition != head.file)) ? %{<a href="#{head.link(@source_file)}">#{head.title}</a>} : head.title
|
104
|
-
end
|
105
|
-
toc_list_proc = lambda do |descend_proc, bmk, document|
|
106
|
-
%{<nav class="contents">
|
107
|
-
<h1 class="toc-header" id="#{bmk}">#{bmk.title}</h1>
|
108
|
-
<ol class="toc">
|
109
|
-
#{descend_proc.call(document.structure, nil)}
|
110
|
-
</ol>
|
111
|
-
</nav>}
|
112
|
-
end
|
113
|
-
toc_item_proc = lambda do |classes, header|
|
114
|
-
"<li class=\"#{classes.join(" ").strip}\">#{header}</li>"
|
115
|
-
end
|
116
|
-
toc_sublist_proc = lambda do |contents|
|
117
|
-
"<li><ol>#{contents}</ol></li>\n"
|
118
|
-
end
|
119
|
-
toc_element_for param(0), attr(:title),
|
120
|
-
:link => link_proc,
|
121
|
-
:toc_list => toc_list_proc,
|
122
|
-
:toc_item => toc_item_proc,
|
123
|
-
:toc_sublist => toc_sublist_proc
|
124
|
-
end
|
125
|
-
|
126
|
-
# See:
|
127
|
-
# http://microformats.org/wiki/book-brainstorming
|
128
|
-
# http://en.wikipedia.org/wiki/Book_design
|
129
|
-
|
130
|
-
(Glyph['system.structure.frontmatter'] + Glyph['system.structure.bodymatter'] + Glyph['system.structure.backmatter']).
|
131
|
-
each {|s| macro_alias s => :section }
|
132
|
-
|
133
|
-
macro_alias "§" => :section
|
134
|
-
macro_alias :frontcover => :section
|
135
|
-
macro_alias :titlepage => :section
|
136
|
-
macro_alias :halftitlepage => :section
|
137
|
-
macro_alias :frontmatter => :section
|
138
|
-
macro_alias :bodymatter => :section
|
139
|
-
macro_alias :backmatter => :section
|
140
|
-
macro_alias :backcover => :section
|