glyph 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/AUTHORS.textile +1 -1
  2. data/CHANGELOG.textile +119 -222
  3. data/LICENSE.textile +1 -1
  4. data/README.textile +42 -23
  5. data/Rakefile +1 -3
  6. data/VERSION +1 -1
  7. data/benchmark.rb +72 -0
  8. data/book/config.yml +4 -4
  9. data/book/document.glyph +90 -57
  10. data/book/images/document_generation.png +0 -0
  11. data/book/lib/macros/reference.rb +75 -22
  12. data/book/output/html/glyph.html +3183 -2121
  13. data/book/output/html/images/document_generation.png +0 -0
  14. data/book/output/pdf/glyph.pdf +7370 -4913
  15. data/book/resources/document_generation.txt +34 -0
  16. data/book/snippets.yml +6 -0
  17. data/book/text/changelog.glyph +45 -34
  18. data/book/text/compiling/compiling.glyph +23 -0
  19. data/book/text/compiling/lite_mode.glyph +23 -0
  20. data/book/text/compiling/programmatic_usage.glyph +77 -0
  21. data/book/text/extending/bookmarks_headers.glyph +21 -0
  22. data/book/text/extending/further_reading.glyph +13 -0
  23. data/book/text/extending/internals.glyph +79 -0
  24. data/book/text/extending/interpreting.glyph +51 -0
  25. data/book/text/extending/macro_def.glyph +64 -0
  26. data/book/text/extending/params_attrs.glyph +70 -0
  27. data/book/text/extending/placeholders.glyph +34 -0
  28. data/book/text/extending/validators.glyph +16 -0
  29. data/book/text/getting_started/configuration.glyph +49 -0
  30. data/book/text/getting_started/create_project.glyph +41 -0
  31. data/book/text/getting_started/structure.glyph +55 -0
  32. data/book/text/introduction.glyph +49 -26
  33. data/book/text/license.glyph +1 -1
  34. data/book/text/macros/macros_block.glyph +99 -0
  35. data/book/text/macros/macros_core.glyph +208 -0
  36. data/book/text/macros/macros_filters.glyph +40 -0
  37. data/book/text/macros/macros_inline.glyph +50 -0
  38. data/book/text/macros/macros_structure.glyph +100 -0
  39. data/book/text/ref_commands.glyph +94 -73
  40. data/book/text/ref_config.glyph +34 -42
  41. data/book/text/ref_macros.glyph +1 -373
  42. data/book/text/text_editing/code.glyph +51 -0
  43. data/book/text/text_editing/conditionals.glyph +49 -0
  44. data/book/text/text_editing/evaluation.glyph +13 -0
  45. data/book/text/text_editing/glyph_files.glyph +7 -0
  46. data/book/text/text_editing/images.glyph +29 -0
  47. data/book/text/text_editing/inclusions.glyph +44 -0
  48. data/book/text/text_editing/links.glyph +53 -0
  49. data/book/text/text_editing/macro_intro.glyph +111 -0
  50. data/book/text/text_editing/raw_html.glyph +112 -0
  51. data/book/text/text_editing/sections.glyph +63 -0
  52. data/book/text/text_editing/stylesheets.glyph +36 -0
  53. data/book/text/troubleshooting/errors_command.glyph +39 -0
  54. data/book/text/troubleshooting/errors_generic.glyph +29 -0
  55. data/book/text/troubleshooting/errors_intro.glyph +3 -0
  56. data/book/text/troubleshooting/errors_macro.glyph +98 -0
  57. data/book/text/troubleshooting/errors_parser.glyph +29 -0
  58. data/config.yml +77 -58
  59. data/document.glyph +25 -25
  60. data/glyph.gemspec +57 -22
  61. data/lib/glyph.rb +54 -13
  62. data/lib/glyph/commands.rb +84 -17
  63. data/lib/glyph/config.rb +3 -3
  64. data/lib/glyph/document.rb +14 -8
  65. data/lib/glyph/interpreter.rb +18 -58
  66. data/lib/glyph/macro.rb +160 -55
  67. data/lib/glyph/macro_validators.rb +104 -12
  68. data/lib/glyph/node.rb +24 -0
  69. data/lib/glyph/parser.rb +278 -0
  70. data/lib/glyph/syntax_node.rb +225 -0
  71. data/macros/core.rb +212 -0
  72. data/macros/filters.rb +66 -15
  73. data/macros/html/block.rb +43 -105
  74. data/macros/html/inline.rb +11 -12
  75. data/macros/html/structure.rb +123 -58
  76. data/macros/xml.rb +33 -0
  77. data/spec/files/container.textile +2 -2
  78. data/spec/files/document.glyph +2 -2
  79. data/spec/files/document_with_toc.glyph +3 -3
  80. data/spec/files/included.textile +1 -1
  81. data/spec/files/ligature.jpg +0 -0
  82. data/spec/files/markdown.markdown +2 -1
  83. data/spec/lib/commands_spec.rb +46 -3
  84. data/spec/lib/document_spec.rb +4 -4
  85. data/spec/lib/glyph_spec.rb +17 -46
  86. data/spec/lib/interpreter_spec.rb +6 -25
  87. data/spec/lib/macro_spec.rb +141 -43
  88. data/spec/lib/macro_validators_spec.rb +27 -5
  89. data/spec/lib/node_spec.rb +26 -1
  90. data/spec/lib/parser_spec.rb +246 -0
  91. data/spec/lib/syntax_node_spec.rb +111 -0
  92. data/spec/macros/core_spec.rb +195 -0
  93. data/spec/macros/filters_spec.rb +38 -4
  94. data/spec/macros/macros_spec.rb +20 -176
  95. data/spec/macros/textile_spec.rb +13 -71
  96. data/spec/macros/xml_spec.rb +77 -0
  97. data/spec/spec_helper.rb +50 -10
  98. data/spec/tasks/load_spec.rb +13 -2
  99. data/styles/default.css +18 -6
  100. data/styles/pagination.css +1 -19
  101. data/tasks/generate.rake +2 -2
  102. data/tasks/load.rake +27 -17
  103. data/tasks/project.rake +1 -1
  104. metadata +75 -62
  105. data/book/script/compile.rb +0 -8
  106. data/book/script/prof +0 -1
  107. data/book/script/prof_results.htm +0 -21079
  108. data/book/text/authoring.glyph +0 -548
  109. data/book/text/extending.glyph +0 -224
  110. data/book/text/getting_started.glyph +0 -158
  111. data/book/text/troubleshooting.glyph +0 -179
  112. data/lib/glyph/glyph_language.rb +0 -538
  113. data/lib/glyph/glyph_language.treetop +0 -27
  114. data/macros/common.rb +0 -160
data/macros/html/block.rb CHANGED
@@ -2,133 +2,90 @@
2
2
 
3
3
  macro :note do
4
4
  %{<div class="#{@name}">
5
- <span class="note-title">#{@name.to_s.capitalize}</span>#{@value}
5
+ <span class="note-title">#{@name.to_s.capitalize}</span>#{value}
6
6
 
7
7
  </div>}
8
8
  end
9
9
 
10
10
  macro :box do
11
- exact_parameters 2, :level => :warning
11
+ exact_parameters 2
12
12
  %{<div class="box">
13
- <div class="box-title">#{params[0]}</div>
14
- #{params[1]}
13
+ <div class="box-title">#{param(0)}</div>
14
+ #{param(1)}
15
15
 
16
16
  </div>}
17
17
  end
18
18
 
19
- macro :code do
20
- min_parameters 1
19
+ macro :codeblock do
20
+ exact_parameters 1
21
21
  %{
22
22
  <div class="code">
23
23
  <pre>
24
24
  <code>
25
- #{@value}
25
+ #{value}
26
26
  </code>
27
27
  </pre>
28
28
  </div>}
29
29
  end
30
30
 
31
- macro :highlight do
32
- min_parameters 2
33
- lang = params[0]
34
- text = raw_params[1..raw_params.length-1].join '\\|'
35
- text.gsub!(/\\(.)/){$1}
36
- highlighter = Glyph["highlighters.current"].to_sym rescue nil
37
- if !highlighter then
38
- begin
39
- require 'coderay'
40
- highlighter = :coderay
41
- rescue LoadError
42
- begin
43
- require 'uv'
44
- highlighter = :ultraviolet
45
- rescue LoadError
46
- macro_error "No highlighter installed. Please run: gem install coderay"
47
- end
48
- end
49
- Glyph["highlighter.current"] = highlighter
50
- end
51
- target = Glyph["highlighters.target"]
52
- result = ""
53
- case highlighter.to_sym
54
- when :coderay
55
- begin
56
- require 'coderay'
57
- result = CodeRay.scan(text, lang).div(Glyph["highlighters.coderay"])
58
- rescue LoadError
59
- macro_error "CodeRay highlighter not installed. Please run: gem install coderay"
60
- rescue Exception => e
61
- macro_error e.message
62
- end
63
- when :ultraviolet
64
- begin
65
- require 'uv'
66
- target = 'xhtml' if target == 'html'
67
- result = Uv.parse(text.to_s, target.to_s, lang.to_s,
68
- Glyph["highlighters.ultraviolet.line_numbers"],
69
- Glyph["highlighters.ultraviolet.theme"].to_s)
70
- rescue LoadError
71
- macro_error "UltraViolet highlighter not installed. Please run: gem install ultraviolet"
72
- rescue Exception => e
73
- puts e.backtrace
74
- macro_error e.message
75
- end
76
- else
77
- macro_error "No highlighter installed. Please run: gem install coderay"
78
- end
79
- result
80
- end
81
-
82
- macro :title do
83
- no_parameters
84
- %{<h1>
85
- #{Glyph["document.title"]}
86
- </h1>}
87
- end
88
-
89
- macro :img do
31
+ macro :image do
90
32
  min_parameters 1
91
33
  max_parameters 3
92
- image = params[0]
93
- width = params[1]
34
+ image = param(0)
35
+ alt = "@alt[-]" unless attr(:alt)
94
36
  source_file = Glyph.lite? ? image : Glyph::PROJECT/"images/#{image}"
95
37
  dest_file = Glyph.lite? ? image : "images/#{image}"
96
- w = (width) ? "width=\"#{width}\"" : ''
97
- height = params[2]
98
- h = (height) ? "height=\"#{height}\"" : ''
99
38
  Glyph.warning "Image '#{image}' not found" unless Pathname.new(dest_file).exist?
100
- %{<img src="#{dest_file}" #{w} #{h} alt="-"/>}
39
+ interpret "img[#{alt}@src[#{dest_file}]#{@node.attrs.join}]"
101
40
  end
102
41
 
103
- macro :fig do
42
+ macro :figure do
104
43
  min_parameters 1
105
44
  max_parameters 2
106
- image = params[0]
107
- caption = params[1]
108
- caption ||= nil
109
- caption = %{<div class="caption">#{caption}</div>} if caption
45
+ image = param(0)
46
+ alt = "@alt[-]" unless attr(:alt)
47
+ caption = param(1) rescue nil
48
+ caption = "div[@class[caption]#{caption}]" if caption
110
49
  source_file = Glyph.lite? ? image : Glyph::PROJECT/"images/#{image}"
111
50
  dest_file = Glyph.lite? ? image : "images/#{image}"
112
51
  Glyph.warning "Figure '#{image}' not found" unless Pathname.new(dest_file).exist?
113
- %{<div class="figure">
114
- <img src="#{dest_file}" alt="-"/>
52
+ interpret %{div[@class[figure]
53
+ img[#{alt}@src[#{dest_file}]#{@node.attrs.join}]
115
54
  #{caption}
116
- </div>}
55
+ ]}
117
56
  end
118
57
 
58
+ macro :title do
59
+ no_parameters
60
+ unless Glyph["document.title"].blank? then
61
+ %{<h1>
62
+ #{Glyph["document.title"]}
63
+ </h1>}
64
+ else
65
+ ""
66
+ end
67
+ end
119
68
 
120
69
  macro :subtitle do
121
70
  no_parameters
71
+ unless Glyph["document.subtitle"].blank? then
122
72
  %{<h2>
123
73
  #{Glyph["document.subtitle"]}
124
74
  </h2>}
75
+ else
76
+ ""
77
+ end
125
78
  end
126
79
 
127
80
  macro :author do
128
81
  no_parameters
82
+ unless Glyph['document.author'].blank? then
129
83
  %{<div class="author">
130
84
  by <em>#{Glyph["document.author"]}</em>
131
85
  </div>}
86
+ else
87
+ ""
88
+ end
132
89
  end
133
90
 
134
91
  macro :pubdate do
@@ -138,31 +95,12 @@ macro :pubdate do
138
95
  </div>}
139
96
  end
140
97
 
141
- macro :table do
142
- exact_parameters 1
143
- %{<table>
144
- #{@value}
145
- </table>}
146
- end
147
-
148
- macro :tr do
149
- exact_parameters 1, :level => :warning
150
- %{<tr>
151
- #{@value}
152
- </tr>}
153
- end
154
-
155
- macro :td do
156
- exact_parameters 1, :level => :warning
157
- %{<td>
158
- #{@value}
159
-
160
- </td>}
161
- end
162
-
163
- macro :th do
164
- exact_parameters 1, :level => :warning
165
- %{<th>#{@value}</th>}
98
+ macro :revision do
99
+ unless Glyph["document.revision"].blank? then
100
+ %{<div class="revision">#{Glyph['document.revision']}</div>}
101
+ else
102
+ ""
103
+ end
166
104
  end
167
105
 
168
106
  macro_alias :important => :note
@@ -3,20 +3,18 @@
3
3
  macro :anchor do
4
4
  min_parameters 1
5
5
  max_parameters 2
6
- ident, title = params
6
+ ident = param(0)
7
+ title = param(1) rescue nil
7
8
  macro_error "Bookmark '#{ident}' already exists" if bookmark? ident
8
9
  bookmark :id => ident, :title => title
9
10
  %{<a id="#{ident}">#{title}</a>}
10
11
  end
11
12
 
12
- macro :codeph do
13
- %{<code>#@value</code>}
14
- end
15
-
16
13
  macro :link do
17
14
  min_parameters 1
18
15
  max_parameters 2
19
- href, title = params
16
+ href = param(0)
17
+ title = param(1) rescue nil
20
18
  if href.match /^#/ then
21
19
  anchor = href.gsub(/^#/, '').to_sym
22
20
  bmk = bookmark? anchor
@@ -31,12 +29,13 @@ macro :link do
31
29
  end
32
30
  end
33
31
  title ||= href
34
- %{<a href="#{href}">#{title}</a>}
32
+ %{<a href="#{href}">#{title.to_s}</a>}
35
33
  end
36
34
 
37
35
  macro :fmi do
38
36
  exact_parameters 2, :level => :warning
39
- topic, href = params
37
+ topic = param(0)
38
+ href = param(1)
40
39
  link = placeholder do |document|
41
40
  interpret "link[#{href}]"
42
41
  end
@@ -45,18 +44,18 @@ end
45
44
 
46
45
  macro :draftcomment do
47
46
  if Glyph['document.draft'] then
48
- %{<span class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>#{@value}</span>}
47
+ %{<span class="comment"><span class="comment-pre"><strong>Comment:</strong> </span>#{value}</span>}
49
48
  else
50
49
  ""
51
50
  end
52
51
  end
53
52
 
54
53
  macro :todo do
55
- min_parameters 1
56
- todo = "[#{@source}] -- #{@value}"
54
+ exact_parameters 1
55
+ todo = {:source => @source, :text => value}
57
56
  @node[:document].todos << todo unless @node[:document].todos.include? todo
58
57
  if Glyph['document.draft'] then
59
- %{<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>#{@value}</span>}
58
+ %{<span class="todo"><span class="todo-pre"><strong>TODO:</strong> </span>#{value}</span>}
60
59
  else
61
60
  ""
62
61
  end
@@ -1,67 +1,127 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- macro :div do
4
- exact_parameters 1, :level => :warning
5
- %{<div class="#{@name}">
6
- #{@value}
3
+ macro :section do
4
+ exact_parameters 1
5
+ h = ""
6
+ h_title = attr :title
7
+ h_id = attr :id
8
+ h_notoc = attr :notoc
9
+ macro_warning "Please specify a title for section ##{h_id}" if h_id && !h_title
10
+ if h_title then
11
+ level = 1
12
+ @node.ascend do |n|
13
+ if n.is_a?(Glyph::MacroNode) && Glyph["system.structure.headers"].include?(n[:name]) then
14
+ level+=1
15
+ end
16
+ end
17
+ h_id ||= "h_#{@node[:document].headers.length+1}"
18
+ h_id = h_id.to_sym
19
+ header :title => h_title, :level => level, :id => h_id, :notoc => h_notoc
20
+ @node[:header] = h_id
21
+ macro_error "Bookmark '#{h_id}' already exists" if bookmark? h_id
22
+ bookmark :id => h_id, :title => h_title
23
+ h = %{<h#{level} id="#{h_id}">#{h_title}</h#{level}>\n}
24
+ end
25
+ %{<div class="#{@name}">
26
+ #{h}#{value}
7
27
 
8
28
  </div>}
9
29
  end
10
30
 
11
- macro :header do
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?
17
- level = 1
18
- @node.ascend do |n|
19
- if Glyph["structure.headers"].include? n[:macro] then
20
- level+=1
21
- end
22
- end
23
- h_id ||= "h_#{@node[:document].headers.length+1}".to_sym
24
- header :title => title, :level => level, :id => h_id
25
- @node[:header] = h_id
26
- macro_error "Bookmark '#{h_id}' already exists" if bookmark? h_id
27
- bookmark :id => h_id, :title => title
28
- %{<h#{level} id="#{h_id}">#{title}</h#{level}>}
31
+ macro :article do
32
+ exact_parameters 1
33
+ head = raw_attr(:head)
34
+ head ||= %{style[default.css]}
35
+ pre_title = raw_attr(:"pre-title")
36
+ post_title = raw_attr(:"post-title")
37
+ pubdate = @node.attr(:pubdate) ? "div[@class[pubdate]#{@node.attr(:pubdate).contents}]" : "pubdate[]"
38
+ halftitlepage = raw_attr(:halftitlepage)
39
+ halftitlepage ||= %{
40
+ #{pre_title}
41
+ title[]
42
+ subtitle[]
43
+ author[]
44
+ #{pubdate}
45
+ #{post_title}
46
+ }
47
+ interpret %{document[
48
+ head[#{head}]
49
+ body[
50
+ halftitlepage[
51
+ #{halftitlepage}
52
+ ]
53
+ #{@node.value}
54
+ ]
55
+ ]}
56
+ end
57
+
58
+ macro :book do
59
+ no_parameters
60
+ head = raw_attr(:head)
61
+ head ||= %{style[default.css]}
62
+ pre_title = raw_attr(:"pre-title")
63
+ post_title = raw_attr(:"post-title")
64
+ titlepage = raw_attr(:titlepage)
65
+ pubdate = @node.attr(:pubdate) ? "div[@class[pubdate]#{@node.attr(:pubdate).contents}]" : "pubdate[]"
66
+ titlepage ||= %{
67
+ #{pre_title}
68
+ title[]
69
+ subtitle[]
70
+ revision[]
71
+ author[]
72
+ #{pubdate}
73
+ #{post_title}
74
+ }
75
+ frontmatter = raw_attr(:frontmatter)
76
+ bodymatter = raw_attr(:bodymatter)
77
+ backmatter = raw_attr(:backmatter)
78
+ frontmatter = "frontmatter[\n#{frontmatter}\n]" if frontmatter
79
+ bodymatter = "bodymatter[\n#{bodymatter}\n]" if bodymatter
80
+ backmatter = "backmatter[\n#{backmatter}\n]" if backmatter
81
+ interpret %{document[
82
+ head[#{head}]
83
+ body[
84
+ titlepage[
85
+ #{titlepage}
86
+ ]
87
+ #{frontmatter}
88
+ #{bodymatter}
89
+ #{backmatter}
90
+ ]
91
+ ]}
29
92
  end
30
93
 
94
+
31
95
  macro :document do
32
- exact_parameters 1, :level => :warning
96
+ exact_parameters 1
33
97
  %{<?xml version="1.0" encoding="utf-8"?>
34
98
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
35
99
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
36
- #{@value}
100
+ #{value}
37
101
 
38
102
  </html>}
39
103
  end
40
104
 
41
- macro :body do
42
- exact_parameters 1, :level => :warning
43
- %{<body>
44
- #{@value}
45
-
46
- </body>}
47
- end
48
-
49
105
  macro :head do
50
- exact_parameters 1, :level => :warning
106
+ exact_parameters 1
107
+ author = Glyph['document.author'].blank? ? "" : %{<meta name="author" content="#{Glyph["document.author"]}" />
108
+ }
109
+ copy = Glyph['document.author'].blank? ? "" : %{<meta name="copyright" content="#{Glyph["document.author"]}" />}
51
110
  %{<head>
52
111
  <title>#{Glyph["document.title"]}</title>
53
- <meta name="author" content="#{Glyph["document.author"]}" />
54
- <meta name="copyright" content="#{Glyph["document.author"]}" />
112
+ #{author}
113
+ #{copy}
55
114
  <meta name="generator" content="Glyph v#{Glyph::VERSION} (http://www.h3rald.com/glyph)" />
56
- #{@value}
115
+ #{value}
57
116
  </head>
58
117
  }
59
118
  end
60
119
 
61
120
  macro :style do
62
- file = Glyph.lite? ? Pathname.new(@value) : Glyph::PROJECT/"styles/#{@value}"
63
- file = Pathname.new Glyph::HOME/'styles'/@value unless file.exist?
64
- macro_error "Stylesheet '#{@value}' not found" unless file.exist?
121
+ exact_parameters 1
122
+ file = Glyph.lite? ? Pathname.new(value) : Glyph::PROJECT/"styles/#{value}"
123
+ file = Pathname.new Glyph::HOME/'styles'/value unless file.exist?
124
+ macro_error "Stylesheet '#{value}' not found" unless file.exist?
65
125
  style = ""
66
126
  case file.extname
67
127
  when ".css"
@@ -84,23 +144,29 @@ macro :style do
84
144
  end
85
145
 
86
146
  macro :toc do
87
- no_parameters
147
+ max_parameters 1
148
+ depth = param 0
88
149
  link_header = lambda do |header|
89
- %{<a href="##{header[:id]}">#{header[:title].gsub(/@(.+?)@/, '\1')}</a>}
150
+ %{<a href="##{header[:id]}">#{header[:title]}</a>}
90
151
  end
91
152
  toc = placeholder do |document|
92
153
  descend_section = lambda do |n1, added_headers|
93
154
  list = ""
94
155
  added_headers ||= []
95
156
  n1.descend do |n2, level|
96
- if Glyph['structure.headers'].include?(n2[:macro])
97
- next if n2.find_parent{|node| Glyph['structure.special'].include? node[:macro] }
98
- header_id = n2.children.select{|n| n[:header]}[0][:header] rescue nil
157
+ if n2.is_a?(Glyph::MacroNode) && Glyph['system.structure.headers'].include?(n2[:name]) then
158
+ next if n2.find_parent{|node| Glyph['system.structure.special'].include? node[:name] }
159
+ header_id = n2[:header]
160
+ header_hash = document.header?(header_id)
161
+ next if depth && header_hash && (header_hash[:level]-1 > depth.to_i) || header_hash && header_hash[:notoc]
99
162
  next if added_headers.include? header_id
100
163
  added_headers << header_id
101
164
  # Check if part of frontmatter, bodymatter or backmatter
102
- container = n2.find_parent{|node| node[:macro].in? [:frontmatter, :bodymatter, :appendix, :backmatter]}[:macro] rescue nil
103
- list << "<li class=\"#{container} #{n2[:macro]}\">#{link_header.call(document.header?(header_id))}</li>\n" if header_id
165
+ container = n2.find_parent do |node|
166
+ node.is_a?(Glyph::MacroNode) &&
167
+ node[:name].in?([:frontmatter, :bodymatter, :appendix, :backmatter])
168
+ end[:name] rescue nil
169
+ list << "<li class=\"#{container} #{n2[:name]}\">#{link_header.call(header_hash)}</li>\n" if header_id
104
170
  child_list = ""
105
171
  n2.children.each do |c|
106
172
  child_list << descend_section.call(c, added_headers)
@@ -110,8 +176,9 @@ macro :toc do
110
176
  end
111
177
  list
112
178
  end
179
+ toc_title = attr(:title) || "Table of Contents"
113
180
  %{<div class="contents">
114
- <h2 class="toc-header" id="h_toc">Table of Contents</h2>
181
+ <h2 class="toc-header" id="h_toc">#{toc_title}</h2>
115
182
  <ol class="toc">
116
183
  #{descend_section.call(document.structure, nil)}
117
184
  </ol>
@@ -124,15 +191,13 @@ end
124
191
  # http://microformats.org/wiki/book-brainstorming
125
192
  # http://en.wikipedia.org/wiki/Book_design
126
193
 
127
- macro_alias :section => :div
128
-
129
- (Glyph['structure.frontmatter'] + Glyph['structure.bodymatter'] + Glyph['structure.backmatter']).
130
- each {|s| macro_alias s => :div }
194
+ (Glyph['system.structure.frontmatter'] + Glyph['system.structure.bodymatter'] + Glyph['system.structure.backmatter']).
195
+ each {|s| macro_alias s => :section }
131
196
 
132
- macro_alias :frontcover => :div
133
- macro_alias :titlepage => :div
134
- macro_alias :halftitlepage => :div
135
- macro_alias :frontmatter => :div
136
- macro_alias :bodymatter => :div
137
- macro_alias :backmatter => :div
138
- macro_alias :backcover => :div
197
+ macro_alias :frontcover => :section
198
+ macro_alias :titlepage => :section
199
+ macro_alias :halftitlepage => :section
200
+ macro_alias :frontmatter => :section
201
+ macro_alias :bodymatter => :section
202
+ macro_alias :backmatter => :section
203
+ macro_alias :backcover => :section