erbook 7.0.0 → 7.1.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.
Files changed (105) hide show
  1. data/CREDITS +3 -0
  2. data/bin/erbook +2 -2
  3. data/doc/HelloWorld.input +1 -1
  4. data/doc/api/classes/ERBook/Document.html +153 -150
  5. data/doc/api/classes/ERBook/Document/Node.html +7 -7
  6. data/doc/api/classes/ERBook/Template.html +24 -24
  7. data/doc/api/classes/ERBook/Template/Sandbox.html +6 -6
  8. data/doc/api/classes/RDoc/AnyMethod.html +32 -28
  9. data/doc/api/classes/RDoc/TopLevel.html +47 -47
  10. data/doc/api/classes/String.html +14 -14
  11. data/doc/api/created.rid +1 -1
  12. data/doc/api/files/CREDITS.html +68 -0
  13. data/doc/api/files/lib/erbook/document_rb.html +1 -3
  14. data/doc/api/files/lib/erbook/rdoc_rb.html +1 -1
  15. data/doc/api/files/lib/erbook/template_rb.html +1 -1
  16. data/doc/api/files/lib/erbook/to_xhtml_rb.html +3 -3
  17. data/doc/api/files/lib/erbook_rb.html +3 -1
  18. data/doc/api/panel/search_index.js +1 -1
  19. data/doc/api/panel/tree.js +1 -1
  20. data/doc/formats.erb +129 -8
  21. data/doc/history.erb +136 -2
  22. data/doc/index.erb +2 -2
  23. data/doc/index.xhtml +1867 -610
  24. data/doc/intro.erb +29 -13
  25. data/doc/setup.erb +9 -2
  26. data/doc/theory.erb +24 -3
  27. data/doc/usage.erb +11 -2
  28. data/fmt/xhtml.yaml +913 -707
  29. data/fmt/{xhtml.icons → xhtml/icons}/index.yaml +2 -2
  30. data/fmt/{xhtml.icons → xhtml/icons}/mediawiki-1.13.2/COPYING +0 -0
  31. data/fmt/{xhtml.icons → xhtml/icons}/mediawiki-1.13.2/README +0 -0
  32. data/fmt/{xhtml.icons → xhtml/icons}/mediawiki-1.13.2/skins/simple/external.png +0 -0
  33. data/fmt/{xhtml.icons → xhtml/icons}/rakefile +4 -6
  34. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/16x16/places/start-here.png +0 -0
  35. data/fmt/xhtml/icons/tango-icon-theme-0.8.90/32x32/actions/go-next.png +0 -0
  36. data/fmt/xhtml/icons/tango-icon-theme-0.8.90/32x32/actions/go-previous.png +0 -0
  37. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/32x32/places/start-here.png +0 -0
  38. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/32x32/status/software-update-available.png +0 -0
  39. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/48x48/apps/accessories-text-editor.png +0 -0
  40. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/48x48/apps/internet-group-chat.png +0 -0
  41. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/48x48/emblems/emblem-important.png +0 -0
  42. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/48x48/status/dialog-error.png +0 -0
  43. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/48x48/status/dialog-information.png +0 -0
  44. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/48x48/status/dialog-warning.png +0 -0
  45. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/COPYING +0 -0
  46. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/README +0 -0
  47. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/actions/bookmark-new.svg +0 -0
  48. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/actions/go-home.svg +0 -0
  49. data/fmt/xhtml/icons/tango-icon-theme-0.8.90/scalable/actions/go-next.svg +191 -0
  50. data/fmt/xhtml/icons/tango-icon-theme-0.8.90/scalable/actions/go-previous.svg +852 -0
  51. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/actions/view-refresh.svg +0 -0
  52. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/apps/accessories-text-editor.svg +0 -0
  53. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/apps/internet-group-chat.svg +0 -0
  54. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/emblems/emblem-favorite.svg +0 -0
  55. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/emblems/emblem-important.svg +0 -0
  56. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/mimetypes/application-certificate.svg +0 -0
  57. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/places/start-here.svg +0 -0
  58. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/status/dialog-error.svg +0 -0
  59. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/status/dialog-information.svg +0 -0
  60. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/status/dialog-warning.svg +0 -0
  61. data/fmt/{xhtml.icons → xhtml/icons}/tango-icon-theme-0.8.90/scalable/status/software-update-available.svg +0 -0
  62. data/fmt/xhtml/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  63. data/fmt/xhtml/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  64. data/fmt/xhtml/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  65. data/fmt/xhtml/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  66. data/fmt/xhtml/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  67. data/fmt/xhtml/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  68. data/fmt/xhtml/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  69. data/fmt/xhtml/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  70. data/fmt/xhtml/jquery/images/ui-icons_222222_256x240.png +0 -0
  71. data/fmt/xhtml/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
  72. data/fmt/xhtml/jquery/images/ui-icons_454545_256x240.png +0 -0
  73. data/fmt/xhtml/jquery/images/ui-icons_888888_256x240.png +0 -0
  74. data/fmt/xhtml/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
  75. data/fmt/{xhtml.scripts → xhtml/jquery}/jquery-1.3.2.min.js +0 -0
  76. data/fmt/xhtml/jquery/jquery-ui-1.7.2.custom.css +406 -0
  77. data/fmt/xhtml/jquery/jquery-ui-1.7.2.custom.min.js +43 -0
  78. data/lang/de.yaml +13 -2
  79. data/lang/el.yaml +13 -2
  80. data/lang/es.yaml +13 -2
  81. data/lang/fr.yaml +13 -2
  82. data/lang/it.yaml +13 -2
  83. data/lang/ja.yaml +13 -2
  84. data/lang/ko.yaml +13 -2
  85. data/lang/nl.yaml +13 -2
  86. data/lang/phrases.yaml +15 -4
  87. data/lang/pt.yaml +13 -2
  88. data/lang/ru.yaml +13 -2
  89. data/lang/zh.yaml +13 -2
  90. data/lang/zt.yaml +13 -2
  91. data/lib/erbook.rb +10 -8
  92. data/lib/erbook/document.rb +144 -139
  93. data/lib/erbook/rdoc.rb +29 -7
  94. data/lib/erbook/template.rb +2 -2
  95. data/lib/erbook/to_xhtml.rb +6 -2
  96. metadata +78 -45
  97. data/doc/api/files/ANN_eml.html +0 -276
  98. data/doc/api/files/ANN_html.html +0 -407
  99. data/doc/api/files/ANN_txt.html +0 -271
  100. data/fmt/xhtml.icons/tango-icon-theme-0.8.90/32x32/actions/go-down.png +0 -0
  101. data/fmt/xhtml.icons/tango-icon-theme-0.8.90/32x32/actions/go-up.png +0 -0
  102. data/fmt/xhtml.icons/tango-icon-theme-0.8.90/scalable/actions/go-down.svg +0 -200
  103. data/fmt/xhtml.icons/tango-icon-theme-0.8.90/scalable/actions/go-up.svg +0 -196
  104. data/fmt/xhtml.scripts/jquery.localscroll-1.2.7-min.js +0 -9
  105. data/fmt/xhtml.scripts/jquery.scrollTo-1.4.1-min.js +0 -11
data/lang/pt.yaml CHANGED
@@ -1,32 +1,43 @@
1
1
  # pt (Portuguese)
2
+ About: Sobre
3
+ Abstract: Sumário
2
4
  Caution: Cuidado
3
5
  Cautions: Cuidados
4
6
  Chapter: Capítulo
5
7
  Contents: Índices
8
+ Document: Original
6
9
  Equation: Equação
7
10
  Equations: Equações
8
11
  Example: Exemplo
9
12
  Examples: Exemplos
13
+ Failed!: Falhado!
10
14
  Figure: Figura
11
15
  Figures: Figuras
12
16
  Focus next segment: Segmento seguinte do foco
13
17
  Focus previous segment: Segmento precedente do foco
14
18
  Focus this segment: Focalize este segmento
15
- Generated by %s on %s.: Gerado por %s em %s.
16
19
  Important: Importante
17
20
  Importants: Importants
21
+ Index: Índice
22
+ License: Licença
23
+ Loading...: Carregamento…
18
24
  Note: Nota
19
25
  Notes: Notas
26
+ Origin: Origem
20
27
  Part: Parte
28
+ Please enable JavaScript in your Web browser.: Permita por favor o Javascript em seu web browser.
29
+ Printer friendly: Impressora amigável
21
30
  Procedure: Procedimento
22
31
  Procedures: Procedimentos
32
+ Ready!: Pronto!
23
33
  Reference: Referência
24
34
  References: Referências
35
+ Resource: Recurso
25
36
  Return to listing: Retorne à lista
26
37
  Section: Seção
27
38
  Table: Tabela
28
39
  Tables: Tabelas
29
- The icons shown above are part of %s, which is copyright %s and is distributed under %s.: Os ícones mostrados acima são parte de %s, que é os direitos reservados %s e é distribuído sob %s.
40
+ This document was generated by %s on %s using the following resources.: Este original foi gerado por %s em %s usando os seguintes recursos.
30
41
  Tip: Ponta
31
42
  Tips: Pontas
32
43
  Warning: Aviso
data/lang/ru.yaml CHANGED
@@ -1,32 +1,43 @@
1
1
  # ru (Russian)
2
+ About: О
3
+ Abstract: Конспект
2
4
  Caution: Предосторежение
3
5
  Cautions: Предосторежения
4
6
  Chapter: Глава
5
7
  Contents: Содержание
8
+ Document: Документ
6
9
  Equation: Уровнение
7
10
  Equations: Уровнения
8
11
  Example: Пример
9
12
  Examples: Примеры
13
+ Failed!: Неудачно!
10
14
  Figure: Диаграмма
11
15
  Figures: Диаграммы
12
16
  Focus next segment: Этап фокуса следующий
13
17
  Focus previous segment: Этап фокуса предыдущий
14
18
  Focus this segment: Сфокусируйте этот этап
15
- Generated by %s on %s.: Произведено %s на %s.
16
19
  Important: Важно
17
20
  Importants: Importants
21
+ Index: Индекс
22
+ License: Лицензия
23
+ Loading...: Нагрузка…
18
24
  Note: Примечание
19
25
  Notes: Примечания
26
+ Origin: Начало
20
27
  Part: Часть
28
+ Please enable JavaScript in your Web browser.: Пожалуйста включите яваскрипт в вашем браузере паутины.
29
+ Printer friendly: Принтер содружественный
21
30
  Procedure: Процедура
22
31
  Procedures: Процедуры
32
+ Ready!: Готово!
23
33
  Reference: Справка
24
34
  References: Справки
35
+ Resource: Ресурс
25
36
  Return to listing: Возвратите к перечислению
26
37
  Section: Раздел
27
38
  Table: Таблица
28
39
  Tables: Таблицы
29
- The icons shown above are part of %s, which is copyright %s and is distributed under %s.: Иконы показанные выше часть %s, которое авторское право %s и распределено под %s.
40
+ This document was generated by %s on %s using the following resources.: Этот документ был произведен %s на %s используя следующие ресурсы.
30
41
  Tip: Подсказка
31
42
  Tips: Подсказки
32
43
  Warning: Предупреждение
data/lang/zh.yaml CHANGED
@@ -1,32 +1,43 @@
1
1
  # zh (Chinese-simp)
2
+ About: 关于
3
+ Abstract: 摘要
2
4
  Caution: 小心
3
5
  Cautions: 小心
4
6
  Chapter: 章节
5
7
  Contents: 内容
8
+ Document: 文件
6
9
  Equation: 等式
7
10
  Equations: 等式
8
11
  Example: 例子
9
12
  Examples: 例子
13
+ Failed!: 不合格!
10
14
  Figure: 图
11
15
  Figures: 图
12
16
  Focus next segment: 焦点下段
13
17
  Focus previous segment: 焦点早先段
14
18
  Focus this segment: 聚焦这段
15
- Generated by %s on %s.: 引起由%s在%s。
16
19
  Important: 重要
17
20
  Importants: Importants
21
+ Index: 索引
22
+ License: 执照
23
+ Loading...: 装货…
18
24
  Note: 笔记
19
25
  Notes: 笔记
26
+ Origin: 起源
20
27
  Part: 部分
28
+ Please enable JavaScript in your Web browser.: 请使能在您的浏览器的Java语言。
29
+ Printer friendly: 友好的打印机
21
30
  Procedure: 做法
22
31
  Procedures: 做法
32
+ Ready!: 准备好!
23
33
  Reference: 参考
24
34
  References: 参考
35
+ Resource: 资源
25
36
  Return to listing: 回到目录
26
37
  Section: 部分
27
38
  Table: 表
28
39
  Tables: 表
29
- The icons shown above are part of %s, which is copyright %s and is distributed under %s.: 显示的象以上是%s的一部分,是版权%s和被分布在%s.之下。
40
+ This document was generated by %s on %s using the following resources.: 使用以下资源,本文是由%s引起的在%s
30
41
  Tip: 技巧
31
42
  Tips: 技巧
32
43
  Warning: 警告
data/lang/zt.yaml CHANGED
@@ -1,32 +1,43 @@
1
1
  # zt (Chinese-trad)
2
+ About: 關於
3
+ Abstract: 摘要
2
4
  Caution: 小心
3
5
  Cautions: 小心
4
6
  Chapter: 章節
5
7
  Contents: 内容
8
+ Document: 文件
6
9
  Equation: 等式
7
10
  Equations: 等式
8
11
  Example: 例子
9
12
  Examples: 例子
13
+ Failed!: 不合格!
10
14
  Figure: 图
11
15
  Figures: 图
12
16
  Focus next segment: 焦點下段
13
17
  Focus previous segment: 焦點早先段
14
18
  Focus this segment: 聚焦這段
15
- Generated by %s on %s.: 引起由%s在%s。
16
19
  Important: 重要
17
20
  Importants: Importants
21
+ Index: 索引
22
+ License: 執照
23
+ Loading...: 裝貨…
18
24
  Note: 筆記
19
25
  Notes: 筆記
26
+ Origin: 起源
20
27
  Part: 部分
28
+ Please enable JavaScript in your Web browser.: 請使能在您的瀏覽器的Java語言。
29
+ Printer friendly: 友好的打印機
21
30
  Procedure: 做法
22
31
  Procedures: 做法
32
+ Ready!: 準備好!
23
33
  Reference: 參考
24
34
  References: 參考
35
+ Resource: 資源
25
36
  Return to listing: 回到目錄
26
37
  Section: 部分
27
38
  Table: 表
28
39
  Tables: 表
29
- The icons shown above are part of %s, which is copyright %s and is distributed under %s.: 顯示的像以上是%s的一部分,是版權%s和被分佈在%s.之下。
40
+ This document was generated by %s on %s using the following resources.: 使用以下资源,本文是由%s引起的在%s
30
41
  Tip: 技巧
31
42
  Tips: 技巧
32
43
  Warning: 警告
data/lib/erbook.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #--
2
- # Copyright 2007 Suraj N. Kurapati
3
- # See the LICENSE file for details.
2
+ # Copyright protects this work.
3
+ # See LICENSE file for details.
4
4
  #++
5
5
 
6
6
  require 'rubygems'
@@ -9,15 +9,17 @@ require 'inochi'
9
9
 
10
10
  Inochi.init :ERBook,
11
11
  :program => 'erbook',
12
- :version => '7.0.0',
13
- :release => '2009-05-03',
12
+ :version => '7.1.0',
13
+ :release => '2009-08-30',
14
14
  :website => 'http://snk.tuxfamily.org/lib/erbook/',
15
15
  :tagline => 'Extensible document processor based on eRuby',
16
16
  :require => {
17
- 'ember' => '~> 0', # for eRuby template processing
18
- 'maruku' => '~> 0.5', # for Markdown to XHTML conversion
19
- 'coderay' => '>= 0.8', # for syntax coloring of source code
20
- 'rainpress' => '~> 1', # for minifying CSS
17
+ 'ember' => '~> 0', # for eRuby template processing
18
+ 'maruku' => '~> 0.5', # for Markdown to XHTML conversion
19
+ 'coderay' => '>= 0.8', # for syntax coloring of source code
20
+ 'rainpress' => '~> 1', # for minifying CSS
21
+ 'haml' => '>= 2.2.2', # for generating HTML and CSS
22
+ 'mime-types' => '>= 1.16', # for detecting MIME types
21
23
  }
22
24
 
23
25
  module ERBook
@@ -1,6 +1,6 @@
1
1
  #--
2
- # Copyright 2008 Suraj N. Kurapati
3
- # See the LICENSE file for details.
2
+ # Copyright protects this work.
3
+ # See LICENSE file for details.
4
4
  #++
5
5
 
6
6
  require 'yaml'
@@ -41,7 +41,7 @@ module ERBook
41
41
  #
42
42
  def initialize format_name, input_text, input_file, options = {}
43
43
  # process format specification
44
- @format_file = format_name.to_s
44
+ @format_file = format_name.to_s
45
45
 
46
46
  File.file? @format_file or
47
47
  @format_file = File.join(ERBook::FORMATS_DIR, @format_file + '.yaml')
@@ -62,160 +62,163 @@ module ERBook
62
62
  @node_defs = @format['nodes']
63
63
 
64
64
  # process input document
65
- begin
66
- # create sandbox for input evaluation
67
- template = Template.new(input_file, input_text, options[:unindent])
68
- sandbox = template.sandbox
69
-
70
- @template_vars = {
71
- :@format => @format,
72
- :@roots => @roots = [], # root nodes of all trees
73
- :@nodes => @nodes = [], # all nodes in the forest
74
- :@nodes_by_type => @nodes_by_type = Hash.new {|h,k| h[k] = [] },
75
- :@stack => [], # stack for all nodes
76
- }.each_pair {|k,v| sandbox.instance_variable_set(k, v) }
77
-
78
- # Handles the method call from a node
79
- # placeholder in the input document.
80
- def sandbox.__node_impl__ node_type, *node_args, &node_content
81
- node = Node.new(
82
- :type => node_type,
83
- :defn => @format['nodes'][node_type],
84
- :args => node_args,
85
- :children => [],
86
-
87
- # omit erbook internals from the stack trace
88
- :trace => caller.reject {|t|
89
- [$0, ERBook::INSTALL].any? {|f| t.index(f) == 0 }
90
- }
91
- )
92
- @nodes << node
93
- @nodes_by_type[node.type] << node
94
-
95
- # calculate occurrence number for this node
96
- if node.defn['number']
97
- @count ||= Hash.new {|h,k| h[k] = []}
98
- node.number = (@count[node.type] << node).length
99
- end
65
+ begin
66
+ # create sandbox for input evaluation
67
+ template = Template.new(input_file, input_text, options[:unindent])
68
+ sandbox = template.sandbox
69
+
70
+ @template_vars = {
71
+ :@format => @format,
72
+ :@roots => @roots = [], # root nodes of all trees
73
+ :@nodes => @nodes = [], # all nodes in the forest
74
+ :@nodes_by_type => @nodes_by_type = Hash.new {|h,k| h[k] = [] },
75
+ :@stack => [], # stack for all nodes
76
+ }.each_pair {|k,v| sandbox.instance_variable_set(k, v) }
77
+
78
+ ##
79
+ # Handles the method call from a node
80
+ # placeholder in the input document.
81
+ #
82
+ def sandbox.__node_impl__ node_type, *node_args, &node_content
83
+ node = Node.new(
84
+ :type => node_type,
85
+ :defn => @format['nodes'][node_type],
86
+ :args => node_args,
87
+ :children => [],
88
+
89
+ # omit erbook internals from the stack trace
90
+ :trace => caller.reject {|t|
91
+ [$0, ERBook::INSTALL].any? {|f| t.index(f) == 0 }
92
+ }
93
+ )
94
+ @nodes << node
95
+ @nodes_by_type[node.type] << node
96
+
97
+ # calculate occurrence number for this node
98
+ if node.defn['number']
99
+ @count ||= Hash.new {|h,k| h[k] = []}
100
+ node.number = (@count[node.type] << node).length
101
+ end
100
102
 
101
- # assign node family
102
- if parent = @stack.last
103
- parent.children << node
104
- node.parent = parent
105
- node.depth = parent.depth
106
- node.depth += 1 if node.defn['depth']
103
+ # assign node family
104
+ if parent = @stack.last
105
+ parent.children << node
106
+ node.parent = parent
107
+ node.depth = parent.depth
108
+ node.depth += 1 if node.defn['depth']
107
109
 
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 }
110
+ # calculate latex-style index number for this node
111
+ if node.defn['index']
112
+ ancestry = @stack.reverse.find {|n| n.defn['index'] }.index
113
+ branches = node.parent.children.select {|n| n.index }
112
114
 
113
- node.index = [ancestry, branches.length + 1].join('.')
114
- end
115
- else
116
- @roots << node
117
- node.parent = nil
118
- node.depth = 0
119
-
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
124
- end
115
+ node.index = [ancestry, branches.length + 1].join('.')
125
116
  end
126
-
127
- # assign node content
128
- if block_given?
129
- @stack.push node
130
- node.content = __block_content__(node, &node_content)
131
- @stack.pop
117
+ else
118
+ @roots << node
119
+ node.parent = nil
120
+ node.depth = 0
121
+
122
+ # calculate latex-style index number for this node
123
+ if node.defn['index']
124
+ branches = @roots.select {|n| n.index }
125
+ node.index = (branches.length + 1).to_s
132
126
  end
133
-
134
- @buffer << node
135
-
136
- nil
137
127
  end
138
128
 
139
- @node_defs.each_key do |type|
140
- # XXX: using a string because define_method()
141
- # does not accept a block until Ruby 1.9
142
- file, line = __FILE__, __LINE__; eval %{
143
- def sandbox.#{type} *node_args, &node_content
144
- __node_impl__ #{type.inspect}, *node_args, &node_content
145
- end
146
- }, binding, file, line
129
+ # assign node content
130
+ if block_given?
131
+ @stack.push node
132
+ node.content = __block_content__(node, &node_content)
133
+ @stack.pop
147
134
  end
148
135
 
149
- # evaluate the input & build the document tree
150
- template.render
151
- @processed_document = template.buffer
136
+ @buffer << node
152
137
 
153
- # chain block-level nodes together for local navigation
154
- block_nodes = @nodes.reject {|n| n.defn['bypass'] ||
155
- n.defn['inline'] }
138
+ nil
139
+ end
156
140
 
157
- require 'enumerator'
158
- block_nodes.each_cons(2) do |a, b|
159
- a.next_node = b
160
- b.prev_node = a
161
- end
141
+ @node_defs.each_key do |type|
142
+ # XXX: using a string because define_method()
143
+ # does not accept a block until Ruby 1.9
144
+ file, line = __FILE__, __LINE__; eval %{
145
+ def sandbox.#{type} *node_args, &node_content
146
+ __node_impl__ #{type.inspect}, *node_args, &node_content
147
+ end
148
+ }, binding, file, line
149
+ end
162
150
 
163
- # calculate output for all nodes
164
- actual_output_by_node = {}
165
-
166
- visitor = lambda do |n|
167
- #
168
- # allow child nodes to calculate their actual
169
- # output and to set their identifier as Node#output
170
- #
171
- # we do this nodes first because this node's
172
- # content contains the child nodes' output
173
- #
174
- n.children.each {|c| visitor.call c }
175
-
176
- # calculate the output for this node
177
- actual_output = Template.new(
178
- "#{@format_file}:nodes:#{n.type}:output",
179
- n.defn['output'].to_s.chomp
180
- ).render_with(@template_vars.merge(:@node => n))
181
-
182
- # reveal child nodes' actual output in this node's actual output
183
- n.children.each do |c|
184
- if c.defn['inline'] && !c.defn['bypass']
185
- actual_output[c.output] = actual_output_by_node[c]
186
-
187
- else
188
- # pull block-level node out of paragraph tag added by Maruku
189
- actual_output.sub! %r/(<p>\s*)?#{Regexp.quote c.output}/ do
190
- actual_output_by_node[c] + $1.to_s
191
- end
151
+ # evaluate the input & build the document tree
152
+ template.render
153
+ @processed_document = template.buffer
154
+
155
+ # chain block-level nodes together for local navigation
156
+ block_nodes = @nodes.reject do |n|
157
+ n.defn['bypass'] || n.defn['inline']
158
+ end
159
+
160
+ require 'enumerator'
161
+ block_nodes.each_cons(2) do |a, b|
162
+ a.next_node = b
163
+ b.prev_node = a
164
+ end
165
+
166
+ # calculate output for all nodes
167
+ actual_output_by_node = {}
168
+
169
+ visitor = lambda do |n|
170
+ #
171
+ # allow child nodes to calculate their actual
172
+ # output and to set their identifier as Node#output
173
+ #
174
+ # we do this nodes first because this node's
175
+ # content contains the child nodes' output
176
+ #
177
+ n.children.each {|c| visitor.call c }
178
+
179
+ # calculate the output for this node
180
+ actual_output = Template.new(
181
+ "#{@format_file}:nodes:#{n.type}:output",
182
+ n.defn['output'].to_s.chomp
183
+ ).render_with(@template_vars.merge(:@node => n))
184
+
185
+ # reveal child nodes' actual output in this node's actual output
186
+ n.children.each do |c|
187
+ if c.defn['inline'] && !c.defn['bypass']
188
+ actual_output[c.output] = actual_output_by_node[c]
189
+
190
+ else
191
+ # pull block-level node out of paragraph tag added by Maruku
192
+ actual_output.sub! %r/(<p>\s*)?#{Regexp.quote c.output}/ do
193
+ actual_output_by_node[c] + $1.to_s
192
194
  end
193
195
  end
194
-
195
- actual_output_by_node[n] = actual_output
196
-
197
- #
198
- # allow the parent node to calculate its actual
199
- # output without interference from the output of
200
- # this node (Node#to_s is aliased to Node#output)
201
- #
202
- # this assumes that having this node's string
203
- # representation be a consecutive sequence of digits
204
- # will not interfere with the text-to-whatever
205
- # transformation defined by the format specification
206
- #
207
- n.output = Digest::SHA1.digest(n.object_id.to_s).unpack('I*').join
208
196
  end
209
197
 
210
- @roots.each {|n| visitor.call n }
198
+ actual_output_by_node[n] = actual_output
199
+
200
+ #
201
+ # allow the parent node to calculate its actual
202
+ # output without interference from the output of
203
+ # this node (Node#to_s is aliased to Node#output)
204
+ #
205
+ # this assumes that having this node's string
206
+ # representation be a consecutive sequence of digits
207
+ # will not interfere with the text-to-whatever
208
+ # transformation defined by the format specification
209
+ #
210
+ n.output = Digest::SHA1.digest(n.object_id.to_s).unpack('I*').join
211
+ end
211
212
 
212
- # replace the temporary identifier with each node's actual output
213
- @nodes.each {|n| n.output = actual_output_by_node[n] }
213
+ @roots.each {|n| visitor.call n }
214
214
 
215
- rescue Exception
216
- puts input_text # so the user can debug line numbers in stack trace
217
- error "Could not process input document #{input_file.inspect}"
218
- end
215
+ # replace the temporary identifier with each node's actual output
216
+ @nodes.each {|n| n.output = actual_output_by_node[n] }
217
+
218
+ rescue Exception
219
+ puts input_text # so the user can debug line numbers in stack trace
220
+ error "Could not process input document #{input_file.inspect}"
221
+ end
219
222
  end
220
223
 
221
224
  ##
@@ -232,7 +235,9 @@ module ERBook
232
235
  undef id if respond_to? :id
233
236
  undef type if respond_to? :type
234
237
 
238
+ ##
235
239
  # Returns the output of this node.
240
+ #
236
241
  def to_s
237
242
  defn['silent'] ? '' : output
238
243
  end