erbook 7.3.0 → 8.0.0

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.
data/lib/erbook.rb CHANGED
@@ -9,8 +9,8 @@ require 'inochi'
9
9
 
10
10
  Inochi.init :ERBook,
11
11
  :program => 'erbook',
12
- :version => '7.3.0',
13
- :release => '2009-10-09',
12
+ :version => '8.0.0',
13
+ :release => '2009-10-10',
14
14
  :website => 'http://snk.tuxfamily.org/lib/erbook/',
15
15
  :tagline => 'Write books, manuals, and documents in eRuby',
16
16
  :require => {
@@ -83,44 +83,54 @@ module ERBook
83
83
  #
84
84
  def sandbox.__node_impl__ node_type, *node_args, &node_content
85
85
  node = Node.new(
86
- :type => node_type,
87
- :defn => @format['nodes'][node_type],
88
- :args => node_args,
89
- :trace => caller,
90
- :children => []
86
+ :type => node_type,
87
+ :definition => @format['nodes'][node_type],
88
+ :arguments => node_args,
89
+ :backtrace => caller,
90
+ :parent => @stack.last,
91
+ :children => []
91
92
  )
93
+
94
+ Array(node.definition['params']).each do |param|
95
+ break if node_args.empty?
96
+ node.__send__ "#{param}=", node_args.shift
97
+ end
98
+
92
99
  @nodes << node
93
100
  @nodes_by_type[node.type] << node
94
101
 
95
- # calculate occurrence number for this node
96
- if node.defn['number']
102
+ # calculate ordinal number for this node
103
+ if node.ordinal_number?
97
104
  @count_by_type ||= Hash.new {|h,k| h[k] = 0 }
98
- node.number = (@count_by_type[node.type] += 1)
105
+ node.ordinal_number = (@count_by_type[node.type] += 1)
99
106
  end
100
107
 
101
108
  # assign node family
102
- if parent = @stack.last
109
+ if parent = node.parent
103
110
  parent.children << node
104
111
  node.parent = parent
105
112
  node.depth = parent.depth
106
- node.depth += 1 if node.defn['depth']
113
+ node.depth += 1 if node.anchor?
107
114
 
108
- # calculate latex-style index number for this node
109
- if node.defn['index']
110
- ancestry = @stack.reverse.find {|n| n.defn['index'] }.index
111
- branches = node.parent.children.select {|n| n.index }
115
+ # calculate section number for this node
116
+ if node.section_number?
117
+ ancestor = @stack.reverse.find {|n| n.section_number }
118
+ branches = parent.children.select {|n| n.section_number }
112
119
 
113
- node.index = [ancestry, branches.length + 1].join('.')
120
+ node.section_number = [
121
+ ancestor.section_number,
122
+ branches.length + 1
123
+ ].join('.')
114
124
  end
115
125
  else
116
126
  @roots << node
117
127
  node.parent = nil
118
128
  node.depth = 0
119
129
 
120
- # calculate latex-style index number for this node
121
- if node.defn['index']
122
- branches = @roots.select {|n| n.index }
123
- node.index = (branches.length + 1).to_s
130
+ # calculate section number for this node
131
+ if node.section_number?
132
+ branches = @roots.select {|n| n.section_number }
133
+ node.section_number = (branches.length + 1).to_s
124
134
  end
125
135
  end
126
136
 
@@ -153,9 +163,7 @@ module ERBook
153
163
  @processed_document = template.buffer
154
164
 
155
165
  # chain block-level nodes together for local navigation
156
- block_nodes = @nodes.reject do |n|
157
- n.defn['bypass'] || n.defn['inline']
158
- end
166
+ block_nodes = @nodes.select {|n| n.anchor? }
159
167
 
160
168
  require 'enumerator'
161
169
  block_nodes.each_cons(2) do |a, b|
@@ -179,16 +187,20 @@ module ERBook
179
187
  # calculate the output for this node
180
188
  actual_output = Template.new(
181
189
  "#{@format_file}:nodes:#{n.type}:output",
182
- n.defn['output'].to_s.chomp
190
+ n.definition['output'].to_s.chomp
183
191
  ).render_with(@template_vars.merge(:@node => n))
184
192
 
185
193
  # reveal child nodes' actual output in this node's actual output
186
194
  n.children.each do |c|
187
- if c.defn['inline'] && !c.defn['bypass']
195
+ if c.silent?
196
+ # this child's output is not meant to be revealed at this time
197
+ next
198
+
199
+ elsif c.inline?
188
200
  actual_output[c.output] = actual_output_by_node[c]
189
201
 
190
202
  else
191
- # pull block-level node out of paragraph tag added by Maruku
203
+ # pull block-level child out of paragraph tag added by Maruku
192
204
  actual_output.sub! %r/(<p>\s*)?#{Regexp.quote c.output}/ do
193
205
  actual_output_by_node[c] + $1.to_s
194
206
  end
@@ -239,7 +251,31 @@ module ERBook
239
251
  # Returns the output of this node.
240
252
  #
241
253
  def to_s
242
- defn['silent'] ? '' : output
254
+ if silent?
255
+ ''
256
+ else
257
+ output
258
+ end
259
+ end
260
+
261
+ def section_number?
262
+ Array(definition['number']).include? 'section'
263
+ end
264
+
265
+ def ordinal_number?
266
+ Array(definition['number']).include? 'ordinal'
267
+ end
268
+
269
+ def anchor?
270
+ not inline? and not silent?
271
+ end
272
+
273
+ def inline?
274
+ definition['inline']
275
+ end
276
+
277
+ def silent?
278
+ definition['silent']
243
279
  end
244
280
  end
245
281
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Suraj N. Kurapati
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-09 00:00:00 -07:00
12
+ date: 2009-10-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -82,9 +82,9 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: "1"
84
84
  version:
85
- description: " ERBook 7.3.0\n\n Write books, manuals, and documents in eRuby\n\n http://snk.tuxfamily.org/lib/erbook/\n\n ERBook is an extensible document processor that emits [1]any\n document you can imagine from [2]eRuby templates, which allow\n scripting and dynamic content generation.\n\n\
86
- Version 7.3.0 (2009-10-09)\n\n This release improves the printer friendliness of the XHTML\n format.\n\n * [3]New features\n\n * [4]Bug fixes\n\n * [5]Housekeeping\n\n New features\n\n * Do not omit ERBook internals from node stack traces.\n\n * Hide \"printer friendly\" toggle checkbox when printing\n (but not when viewing the \"printer friendly\" mode on the\n computer screen).\n\n * Hide the \"About\" section in \"printer friendly\" mode.\n\n Bug fixes\n\n * Page scrolled to wrong location when links in the table\n of contents in the \"printer friendly\" mode were clicked.\n\n * Print style was not used when printing from \"printer\n friendly\" mode.\n\n * Sans-serif font was not used in headings in print style.\n\n Housekeeping\n\n * Use Ember syntax in [6]Input document for HelloWorld\n format example.\n\n\
87
- References\n\n 1. http://snk.tuxfamily.org/lib/erbook/#HelloWorld\n 2. http://en.wikipedia.org/wiki/ERuby\n 3. http://snk.tuxfamily.org/lib/erbook/#New-features\n 4. http://snk.tuxfamily.org/lib/erbook/#Bug-fixes\n 5. http://snk.tuxfamily.org/lib/erbook/#Housekeeping\n 6. http://snk.tuxfamily.org/lib/erbook/#HelloWorld-input\n"
85
+ description: " ERBook 8.0.0\n\n Write books, manuals, and documents in eRuby\n\n http://snk.tuxfamily.org/lib/erbook/\n\n ERBook is an extensible document processor that emits [1]any\n document you can imagine from [2]eRuby templates, which allow\n scripting and dynamic content generation.\n\n\
86
+ Version 8.0.0 (2009-10-10)\n\n This release simplifies [3]node definitions, adds [4]Table\n nodes for building tables the HTML way, and introduces\n [5]Arbitrary floats to combat the [6]explosion of\n special-purpose document nodes.\n\n * [7]Incompatible changes\n\n * [8]New features\n\n * [9]Housekeeping\n\n Incompatible changes\n\n * Reduce and rename [10]node definitions attributes:\n + toc: true -> index: tree\n + lof: true -> index: list\n + index: true -> number: section\n + number: true -> number: ordinal\n + depth: true -> (removed)\n + bypass: true -> (removed)\n\n * Rename [11]The ERBook::Document::Node class properties to\n be more self-documenting:\n + args -> arguments\n + defn -> definition\n + trace -> backtrace\n + index -> section_number\n + number -> ordinal_number\n\n * Replace formal blocks (figure, table, example, equation,\n procedure) with [12]Arbitrary floats.\n\n * Append an exclamation mark (!) to the names of\n [13]Admonition nodes, thereby making them a special case\n of [14]Arbitrary floats.\n\n New features\n\n * Add \"params\" attribute to [15]node definitions.\n\n * Add [16]Table nodes for building tables the HTML way.\n\n Housekeeping\n\n * Use YAML hash merging to DRY node definitions in XHTML\n format.\n\n * Use [17]Table nodes instead of PHP Markdown Extra table\n syntax in the user manual.\n\n * Remove the \"digest\" [18]Node definition attribute from\n the user manual. Its use was discontinued a few major\n versions ago.\n\n\
87
+ References\n\n 1. http://snk.tuxfamily.org/lib/erbook/#HelloWorld\n 2. http://en.wikipedia.org/wiki/ERuby\n 3. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n 4. http://snk.tuxfamily.org/lib/erbook/#Table-nodes\n 5. http://snk.tuxfamily.org/lib/erbook/#Arbitrary-floats\n 6. http://www.docbook.org/tdg/en/html/part2.html\n 7. http://snk.tuxfamily.org/lib/erbook/#Incompatible-changes\n 8. http://snk.tuxfamily.org/lib/erbook/#New-features\n 9. http://snk.tuxfamily.org/lib/erbook/#Housekeeping\n 10. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n 11. http://snk.tuxfamily.org/lib/erbook/#Node-class\n 12. http://snk.tuxfamily.org/lib/erbook/#Arbitrary-floats\n 13. http://snk.tuxfamily.org/lib/erbook/#Admonition-nodes\n 14. http://snk.tuxfamily.org/lib/erbook/#Arbitrary-floats\n 15. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n 16. http://snk.tuxfamily.org/lib/erbook/#Table-nodes\n 17. http://snk.tuxfamily.org/lib/erbook/#Table-nodes\n 18. http://snk.tuxfamily.org/lib/erbook/#SpecFile-nodes\n"
88
88
  email: sunaku@gmail.com
89
89
  executables:
90
90
  - erbook