deplate 0.7.3 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/AUTHORS.TXT +3 -0
  2. data/CHANGES.TXT +248 -175
  3. data/LICENSE.TXT +0 -0
  4. data/NEWS.TXT +28 -24
  5. data/README.TXT +0 -0
  6. data/TODO.TXT +174 -88
  7. data/VERSION.TXT +1 -1
  8. data/bin/deplate +0 -0
  9. data/bin/deplate.bat +0 -0
  10. data/etc/deplate.ini +91 -3
  11. data/lib/action_view/helpers/deplate.rb +45 -0
  12. data/lib/deplate.rb +6 -1
  13. data/lib/deplate/abstract-class.rb +0 -0
  14. data/lib/deplate/bib.rb +576 -0
  15. data/lib/deplate/builtin.rb +0 -0
  16. data/lib/deplate/cache.rb +55 -5
  17. data/lib/deplate/commands.rb +346 -183
  18. data/lib/deplate/common.rb +209 -48
  19. data/lib/deplate/converter.rb +12 -6
  20. data/lib/deplate/core.rb +777 -378
  21. data/lib/deplate/counters.rb +254 -0
  22. data/lib/deplate/css/article.css +4 -3
  23. data/lib/deplate/css/deplate.css +121 -5
  24. data/lib/deplate/css/heading-navbar.css +0 -0
  25. data/lib/deplate/css/layout-deplate-print.css +0 -0
  26. data/lib/deplate/css/layout-deplate.css +0 -0
  27. data/lib/deplate/css/sans-serif.css +0 -0
  28. data/lib/deplate/css/serif-e.css +0 -0
  29. data/lib/deplate/css/serif-rel.css +0 -0
  30. data/lib/deplate/css/serif.css +9 -3
  31. data/lib/deplate/css/slides.css +0 -0
  32. data/lib/deplate/css/tabbar-left.css +0 -0
  33. data/lib/deplate/css/tabbar-right-ie.css +3 -9
  34. data/lib/deplate/css/tabbar-right.css +51 -18
  35. data/lib/deplate/css/tabbar-top.css +7 -1
  36. data/lib/deplate/css/tabbar.css +0 -0
  37. data/lib/deplate/css/text-sans-serif.css +0 -0
  38. data/lib/deplate/css/text-serif.css +0 -0
  39. data/lib/deplate/define.rb +183 -177
  40. data/lib/deplate/deplate-string.rb +82 -0
  41. data/lib/deplate/docbook.rb +236 -128
  42. data/lib/deplate/elements.rb +584 -417
  43. data/lib/deplate/etc.rb +163 -101
  44. data/lib/deplate/external.rb +42 -11
  45. data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
  46. data/lib/deplate/fmt/dbk-article.rb +0 -0
  47. data/lib/deplate/fmt/dbk-book.rb +0 -0
  48. data/lib/deplate/fmt/dbk-ref.rb +3 -3
  49. data/lib/deplate/fmt/dbk-slides.rb +0 -0
  50. data/lib/deplate/fmt/dbk-snippet.rb +0 -0
  51. data/lib/deplate/fmt/html-snippet.rb +0 -0
  52. data/lib/deplate/fmt/html.rb +783 -550
  53. data/lib/deplate/fmt/htmlsite.rb +192 -199
  54. data/lib/deplate/fmt/htmlslides.rb +0 -0
  55. data/lib/deplate/fmt/htmlwebsite.rb +3 -3
  56. data/lib/deplate/fmt/latex-snippet.rb +0 -0
  57. data/lib/deplate/fmt/latex.rb +242 -83
  58. data/lib/deplate/fmt/null.rb +32 -0
  59. data/lib/deplate/fmt/php.rb +4 -4
  60. data/lib/deplate/fmt/phpsite.rb +6 -5
  61. data/lib/deplate/fmt/plain.rb +160 -106
  62. data/lib/deplate/fmt/template.rb +0 -0
  63. data/lib/deplate/fmt/xhtml10t.rb +0 -0
  64. data/lib/deplate/formatter-snippet.rb +0 -0
  65. data/lib/deplate/formatter.rb +613 -301
  66. data/lib/deplate/input.rb +202 -142
  67. data/lib/deplate/input/deplate-headings.rb +4 -6
  68. data/lib/deplate/input/deplate-restricted.rb +15 -9
  69. data/lib/deplate/input/deplate.rb +2 -4
  70. data/lib/deplate/input/rdoc.rb +39 -38
  71. data/lib/deplate/input/template.rb +0 -0
  72. data/lib/deplate/lib/Makefile.config +29 -0
  73. data/lib/deplate/lib/latex/deplate.sty +54 -0
  74. data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
  75. data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
  76. data/lib/deplate/lib/php/page-comment.inc.php +216 -0
  77. data/lib/deplate/lib/tabmenu.js +0 -0
  78. data/lib/deplate/locale/de.latin1 +155 -17
  79. data/lib/deplate/locale/ru.koi8-r +0 -0
  80. data/lib/deplate/locale/zh_cn.gb2312 +0 -0
  81. data/lib/deplate/macros.rb +133 -82
  82. data/lib/deplate/messages.rb +6 -4
  83. data/lib/deplate/metadata.rb +0 -0
  84. data/lib/deplate/metadata/marshal.rb +0 -0
  85. data/lib/deplate/metadata/xml.rb +0 -0
  86. data/lib/deplate/metadata/yaml.rb +0 -0
  87. data/lib/deplate/mod/anyword.rb +3 -3
  88. data/lib/deplate/mod/babelfish.rb +4 -4
  89. data/lib/deplate/mod/code-gvim.rb +8 -4
  90. data/lib/deplate/mod/code-highlight.rb +3 -3
  91. data/lib/deplate/mod/colored-log.rb +0 -0
  92. data/lib/deplate/mod/de.rb +2 -2
  93. data/lib/deplate/mod/en.rb +0 -0
  94. data/lib/deplate/mod/endnotes.rb +0 -0
  95. data/lib/deplate/mod/fr.rb +0 -0
  96. data/lib/deplate/mod/html-asciimath.rb +0 -0
  97. data/lib/deplate/mod/html-deplate-button.rb +0 -0
  98. data/lib/deplate/mod/html-headings-navbar.rb +5 -13
  99. data/lib/deplate/mod/html-jsmath.rb +39 -0
  100. data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
  101. data/lib/deplate/mod/html-sidebar.rb +0 -0
  102. data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
  103. data/lib/deplate/mod/iconv.rb +0 -0
  104. data/lib/deplate/mod/imgurl.rb +4 -4
  105. data/lib/deplate/mod/inlatex-compound.rb +7 -10
  106. data/lib/deplate/mod/koma.rb +0 -0
  107. data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
  108. data/lib/deplate/mod/latex-styles.rb +7 -4
  109. data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
  110. data/lib/deplate/mod/makefile.rb +23 -7
  111. data/lib/deplate/mod/mark-external-urls.rb +3 -3
  112. data/lib/deplate/mod/markup-1-warn.rb +10 -10
  113. data/lib/deplate/mod/markup-1.rb +0 -0
  114. data/lib/deplate/mod/navbar-png.rb +24 -8
  115. data/lib/deplate/mod/noindent.rb +0 -0
  116. data/lib/deplate/mod/numpara.rb +0 -0
  117. data/lib/deplate/mod/particle-math.rb +4 -4
  118. data/lib/deplate/mod/php-extra.rb +46 -6
  119. data/lib/deplate/mod/pstoedit.rb +0 -0
  120. data/lib/deplate/mod/recode.rb +0 -0
  121. data/lib/deplate/mod/ru_koi8-r.rb +0 -0
  122. data/lib/deplate/mod/smart-dash.rb +26 -0
  123. data/lib/deplate/mod/smiley.rb +69 -7
  124. data/lib/deplate/mod/soffice.rb +0 -0
  125. data/lib/deplate/mod/symbols-latin1.rb +14 -23
  126. data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
  127. data/lib/deplate/mod/symbols-plain.rb +5 -35
  128. data/lib/deplate/mod/symbols-sgml.rb +8 -9
  129. data/lib/deplate/mod/symbols-utf-8.rb +8 -9
  130. data/lib/deplate/mod/symbols-xml.rb +5 -9
  131. data/lib/deplate/mod/syntax-region-alt.rb +5 -5
  132. data/lib/deplate/mod/utf8.rb +0 -0
  133. data/lib/deplate/mod/validate-html.rb +0 -0
  134. data/lib/deplate/mod/xmlrpc.rb +0 -0
  135. data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
  136. data/lib/deplate/mod/zh-cn.rb +4 -6
  137. data/lib/deplate/nukumi2.rb +71 -0
  138. data/lib/deplate/once-method.rb +0 -0
  139. data/lib/deplate/output.rb +19 -21
  140. data/lib/deplate/particles.rb +178 -116
  141. data/lib/deplate/regions.rb +99 -58
  142. data/lib/deplate/skeletons.rb +122 -0
  143. data/lib/deplate/structured.rb +164 -106
  144. data/lib/deplate/template.rb +67 -43
  145. data/lib/deplate/templates/html-doc.html +0 -0
  146. data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
  147. data/lib/deplate/templates/html-left-tabbar.html +0 -0
  148. data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
  149. data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
  150. data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
  151. data/lib/deplate/templates/html-tabbar-right.html +2 -4
  152. data/lib/deplate/templates/html-tabbar-top.html +0 -9
  153. data/lib/deplate/templates/html-tabbar.html +0 -0
  154. data/lib/deplate/variables.rb +127 -0
  155. data/lib/deplate/wiki-markup.rb +99 -33
  156. data/lib/deplate/xml.rb +18 -18
  157. data/lib/deplate/zh-cn.rb +0 -0
  158. data/lib/ps2ppm.rb +0 -0
  159. data/man/man1/deplate.1 +564 -474
  160. metadata +201 -186
@@ -3,8 +3,8 @@
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 10-Aug-2004.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.445
6
+ # @Last Change: 28-Mai-2006.
7
+ # @Revision: 0.465
8
8
  #
9
9
  # Description:
10
10
  #
@@ -25,6 +25,7 @@ end
25
25
 
26
26
 
27
27
  class Deplate::Command::Matter < Deplate::Command
28
+ set_formatter :fill_in_template
28
29
  def process
29
30
  id = @args["id"] || @accum[0]
30
31
  @elt = template_get_content(id)
@@ -38,28 +39,25 @@ class Deplate::Command::Matter < Deplate::Command
38
39
  end
39
40
 
40
41
  class Deplate::Command::PREMATTER < Deplate::Command::Matter
41
- @formatter = :fill_in_template
42
42
  def template_get_content(arg)
43
43
  @deplate.options.template_manager.template_get_content(:pre, arg)
44
44
  end
45
45
  end
46
46
 
47
47
  class Deplate::Command::POSTMATTER < Deplate::Command::Matter
48
- @formatter = :fill_in_template
49
48
  def template_get_content(arg)
50
49
  @deplate.options.template_manager.template_get_content(:post, arg)
51
50
  end
52
51
  end
53
52
 
54
53
  class Deplate::Command::BODY < Deplate::Command::Matter
55
- @formatter = :fill_in_template
56
54
  def template_get_content(arg)
57
55
  @deplate.options.template_manager.template_get_content(:body, arg)
58
56
  end
59
57
  end
60
58
 
61
59
  class Deplate::Regions::Mingle < Deplate::Region
62
- @line_cont = false
60
+ set_line_cont false
63
61
 
64
62
  def finish
65
63
  finish_accum
@@ -100,7 +98,7 @@ end
100
98
  class Deplate::Template
101
99
  attr_reader :mingled
102
100
 
103
- @@templateKeys = ["pre", "body", "post", "doc", "ARG", "arg", "clip"]
101
+ @@templateKeys = ['pre', 'body', 'post', 'doc', 'ARG', 'arg', 'clip']
104
102
  @@deplate_for_template = nil
105
103
  @@deplate_options = {
106
104
  :formatter => Deplate::Formatter::Template,
@@ -113,28 +111,30 @@ class Deplate::Template
113
111
  Deplate::Element::Command,
114
112
  Deplate::Element::Whitespace,
115
113
  ],
114
+
116
115
  :commands => {
117
- "INC" => Deplate::Command::INC,
118
- "INCLUDE" => Deplate::Command::INC,
119
- "GET" => Deplate::Command::GET,
120
- "ARG" => Deplate::Command::ARG,
121
- "XARG" => Deplate::Command::XARG,
122
- "VAL" => Deplate::Command::ARG,
123
- "XVAL" => Deplate::Command::XARG,
124
- "DOC" => Deplate::Command::DOC,
125
- "VAR" => Deplate::Command::DOC,
126
- "OPT" => Deplate::Command::OPT,
127
- "PREMATTER" => Deplate::Command::PREMATTER,
128
- "POSTMATTER" => Deplate::Command::POSTMATTER,
129
- "BODY" => Deplate::Command::BODY,
116
+ 'INC' => Deplate::Command::INC,
117
+ 'INCLUDE' => Deplate::Command::INC,
118
+ 'GET' => Deplate::Command::GET,
119
+ 'ARG' => Deplate::Command::ARG,
120
+ 'XARG' => Deplate::Command::XARG,
121
+ 'VAL' => Deplate::Command::ARG,
122
+ 'XVAL' => Deplate::Command::XARG,
123
+ 'DOC' => Deplate::Command::VAR,
124
+ 'VAR' => Deplate::Command::VAR,
125
+ 'OPT' => Deplate::Command::OPT,
126
+ 'PREMATTER' => Deplate::Command::PREMATTER,
127
+ 'POSTMATTER' => Deplate::Command::POSTMATTER,
128
+ 'BODY' => Deplate::Command::BODY,
130
129
  },
130
+
131
131
  :regions => {
132
- "Foreach" => Deplate::Regions::Foreach,
133
- "Mingle" => Deplate::Regions::Mingle,
134
- "Native" => Deplate::Regions::Native,
135
- "Ruby" => Deplate::Regions::Ruby,
136
- "Doc" => Deplate::Regions::Doc,
137
- "Var" => Deplate::Regions::Doc,
132
+ 'Foreach' => Deplate::Regions::Foreach,
133
+ 'Mingle' => Deplate::Regions::Mingle,
134
+ 'Native' => Deplate::Regions::Native,
135
+ 'Ruby' => Deplate::Regions::Ruby,
136
+ 'Doc' => Deplate::Regions::Doc,
137
+ 'Var' => Deplate::Regions::Doc,
138
138
  },
139
139
 
140
140
  :particles => [
@@ -142,17 +142,19 @@ class Deplate::Template
142
142
  Deplate::Particle::Macro,
143
143
  Deplate::Particle::Whitespace,
144
144
  ],
145
+
145
146
  :macros => {
146
- "get" => Deplate::Macro::Clip,
147
- "clip" => Deplate::Macro::Clip,
148
- "opt" => Deplate::Macro::Opt,
149
- "arg" => Deplate::Macro::Arg,
150
- "xarg" => Deplate::Macro::XArg,
151
- "val" => Deplate::Macro::Arg,
152
- "xval" => Deplate::Macro::XArg,
153
- "doc" => Deplate::Macro::Doc,
154
- "var" => Deplate::Macro::Doc,
155
- "ruby" => Deplate::Macro::Ruby,
147
+ 'get' => Deplate::Macro::Clip,
148
+ 'clip' => Deplate::Macro::Clip,
149
+ 'opt' => Deplate::Macro::Opt,
150
+ 'arg' => Deplate::Macro::Arg,
151
+ 'xarg' => Deplate::Macro::XArg,
152
+ 'val' => Deplate::Macro::Arg,
153
+ 'xval' => Deplate::Macro::XArg,
154
+ 'var' => Deplate::Macro::Var,
155
+ 'doc' => Deplate::Macro::Var,
156
+ 'ruby' => Deplate::Macro::Ruby,
157
+ 'msg' => Deplate::Macro::Msg,
156
158
  },
157
159
  }
158
160
 
@@ -160,6 +162,23 @@ class Deplate::Template
160
162
  def deplate_options
161
163
  @@deplate_options
162
164
  end
165
+
166
+ def copy(deplate, src, dest, invoker=nil)
167
+ tpl = File.open(src) {|io| io.read}
168
+ src = invoker ? invoker.source : nil
169
+ tpl = Deplate::Template.new(:template => tpl,
170
+ :source => src,
171
+ :container => self)
172
+ args = {}
173
+ if block_given?
174
+ yield(args)
175
+ end
176
+ Deplate::Define.let_variables(deplate, args) do
177
+ tpl = tpl.fill_in(deplate, :source => src)
178
+ end
179
+ tpl = tpl.join("\n")
180
+ File.open(dest, 'w') {|io| io.puts(tpl)}
181
+ end
163
182
  end
164
183
 
165
184
  attr_reader :template, :pre, :body, :post
@@ -181,14 +200,19 @@ class Deplate::Template
181
200
  file = args[:file]
182
201
  if file
183
202
  if File.exists?(file)
184
- File.open(file) do |io|
185
- @template = io.read
203
+ begin
204
+ File.open(file) do |io|
205
+ @template = io.read
206
+ end
207
+ rescue Exception => e
208
+ Deplate::DeplateForTemplates.log([e.message], :error, @source)
209
+ @template = ''
186
210
  end
187
211
  else
188
- Deplate::DeplateForTemplates.log(["Template not found", file], :error, @source)
212
+ Deplate::DeplateForTemplates.log(['Template not found', file], :error, @source)
189
213
  end
190
214
  else
191
- Deplate::DeplateForTemplates.log("No template defined", :error, @source)
215
+ Deplate::DeplateForTemplates.log('No template defined', :error, @source)
192
216
  end
193
217
  end
194
218
 
@@ -205,7 +229,7 @@ class Deplate::Template
205
229
  :post => [],
206
230
  }
207
231
  @keep_whitespace = args.has_key?(:keep_whitespace) ? args[:keep_whitespace] : true
208
- if deplate.variables["template_version"] == "1"
232
+ if deplate.variables['template_version'] == '1'
209
233
  fill_in_1
210
234
  else
211
235
  fill_in_2
@@ -216,7 +240,7 @@ class Deplate::Template
216
240
  if @@deplate_for_template
217
241
  d = @@deplate_for_template
218
242
  else
219
- d = @@deplate_for_template = Deplate::DeplateForTemplates.new("", @@deplate_options)
243
+ d = @@deplate_for_template = Deplate::DeplateForTemplates.new('', @@deplate_options)
220
244
  end
221
245
  keep_whitespace = d.options.keep_whitespace
222
246
  master = d.options.master
@@ -224,7 +248,7 @@ class Deplate::Template
224
248
  begin
225
249
  d.reset
226
250
  d.variables = @deplate.variables.dup
227
- d.doc_services = @deplate.doc_services
251
+ # d.doc_services = @deplate.doc_services
228
252
  d.set_all_clips(@deplate.get_unprocessed_clips)
229
253
  d.options.template_manager = self
230
254
  d.options.keep_whitespace = @keep_whitespace
File without changes
@@ -0,0 +1,22 @@
1
+ #Mingle type=pre slot=css:
2
+ <!--[if IE]>
3
+ <link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
4
+ <![endif]-->
5
+ #End
6
+ #PREMATTER
7
+
8
+ <div id="tabFrame">
9
+ <div id="tabBodyFrame">
10
+ <div id="tabBody">
11
+ <img width="600px" height="1px" src="spacer.png" alt="" />
12
+ #BODY: -navbar_top -navbar_bottom
13
+ </div>
14
+ #ARG: pageComment()
15
+ #POSTMATTER: html_pageicons_beg..html_pageicons_end
16
+ </div>
17
+ <div id="tabBar">
18
+ #ARG: tabBarRight(spacer=spacer.png depth=2 depthInactive=1)
19
+ </div>
20
+ </div>
21
+
22
+ #POSTMATTER
@@ -0,0 +1,24 @@
1
+ #Mingle type=pre slot=css:
2
+ <!--[if IE]>
3
+ <link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
4
+ <![endif]-->
5
+ #End
6
+ #PREMATTER
7
+
8
+ <div id="tabFrame">
9
+ <div id="tabBodyFrame">
10
+ <div id="tabBody">
11
+ <img width="600px" height="1px" src="spacer.png" alt="" />
12
+ #BODY: -navbar_top -navbar_bottom
13
+ </div>
14
+ #POSTMATTER: html_pageicons_beg..html_pageicons_end
15
+ </div>
16
+ <div id="tabBar">
17
+ #ARG: tabBarRight(spacer=spacer.png depth=2 depthInactive=1)
18
+ </div>
19
+ #ARG: navigationKeys()
20
+ #ARG: stepwiseDisplay()
21
+ #ARG: navigationHandleKeys()
22
+ </div>
23
+
24
+ #POSTMATTER
@@ -1,8 +1,6 @@
1
1
  #Mingle type=pre slot=css:
2
2
  <!--[if IE]>
3
- <style type="text/css">
4
- <link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
5
- </style>
3
+ <link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
6
4
  <![endif]-->
7
5
  #End
8
6
  #PREMATTER
@@ -16,7 +14,7 @@
16
14
  #POSTMATTER: html_pageicons_beg..html_pageicons_end
17
15
  </div>
18
16
  <div id="tabBar">
19
- #ARG: tabBarRight(progressBar! nextKey! spacer=spacer.png depth=2 depthInactive=1)
17
+ #ARG: tabBarRight(spacer=spacer.png depth=2 depthInactive=1)
20
18
  </div>
21
19
  </div>
22
20
 
@@ -1,13 +1,4 @@
1
1
  #Mingle type=pre slot=css:
2
- <style type="text/css">
3
- <!--
4
- @media screen {
5
- body {
6
- background-color: #e9e9ff;
7
- }
8
- }
9
- -->
10
- </style>
11
2
  <!--[if IE]>
12
3
  <style type="text/css">
13
4
  @media screen {
File without changes
@@ -0,0 +1,127 @@
1
+ # variables.rb
2
+ # @Author: Thomas Link (samul AT web de)
3
+ # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
4
+ # @Created: 31-Dez-2005.
5
+ # @Last Change: 18-Apr-2006.
6
+ # @Revision: 0.37
7
+
8
+ class Deplate::Variables < Hash
9
+ attr_accessor :deplate
10
+
11
+ def initialize(deplate=nil)
12
+ super()
13
+ @deplate = deplate
14
+ end
15
+
16
+ def log(*args)
17
+ Deplate::Core.log(*args)
18
+ end
19
+
20
+ def update(hash)
21
+ for key, val in hash
22
+ self[key] = val
23
+ end
24
+ end
25
+
26
+ def []=(name, value)
27
+ if name.kind_of?(String) and (m = /^(\S+)\[(\S+)?\]$/.match(name))
28
+ key = m[1]
29
+ field = m[2]
30
+ var = self[key]
31
+ if !var
32
+ if !field
33
+ self[key] = [value]
34
+ elsif field =~ /^[0-9]$/
35
+ self[key] = []
36
+ self[key][field.to_i] = value
37
+ else
38
+ self[key] = {field => value}
39
+ end
40
+ elsif var.kind_of?(Struct) || var.kind_of?(OpenStruct)
41
+ var.send("#{field}=", value)
42
+ elsif var.kind_of?(Hash)
43
+ var[field] = value
44
+ elsif var.kind_of?(Array)
45
+ if !field
46
+ var << value
47
+ elsif field =~ /^[0-9]+$/
48
+ field = field.to_i
49
+ var[field] = value
50
+ else
51
+ Deplate::Core.log(["Wrong index", field, name, var.class], :error)
52
+ end
53
+ elsif var
54
+ Deplate::Core.log(["Doc variable has wrong type", key, var.class], :error)
55
+ end
56
+ else
57
+ super
58
+ end
59
+ end
60
+
61
+ def [](name)
62
+ begin
63
+ if !name.kind_of?(String) or keys.include?(name)
64
+ return super
65
+ # elsif name =~ /^no(\S+)$/ and (keys.include?($1) or keys.include?(name))
66
+ # return !super($1)
67
+ elsif name =~ /^\S+\(.*?\)$/
68
+ m = /^(\S+)\((.*?)?\)$/.match(name)
69
+ if m
70
+ method = m[1]
71
+ args = m[2]
72
+ args, text = @deplate.input.parse_args(args, nil, false)
73
+ rv = @deplate.formatter.invoke_service(method, args, text)
74
+ return rv
75
+ else
76
+ Deplate::Core.log(['Malformed variable name', name], :error)
77
+ end
78
+ elsif name =~ /^:(\S+)$/
79
+ n = $1
80
+ if @deplate.is_allowed?(':', :logger => self)
81
+ return @deplate.options.send(n)
82
+ end
83
+ elsif (m = /^(\S+)\[(\S+)\]$/.match(name))
84
+ key = m[1]
85
+ field = m[2]
86
+ val = self[key]
87
+ return extract(val, key, field)
88
+ elsif (m = /^(\S+)\.(\S+)$/.match(name))
89
+ if @deplate.is_allowed?('.', :logger => self)
90
+ key = m[1]
91
+ meth = m[2]
92
+ val = self[key]
93
+ begin
94
+ return val.send(meth)
95
+ rescue Exception => e
96
+ log(['Invoking method failed', meth, val.class], :error)
97
+ end
98
+ else
99
+ log(['No permission', name], :anyway)
100
+ end
101
+ end
102
+ rescue Exception => e
103
+ Deplate::Core.log(['Retrieving doc variable failed', name, e], :error)
104
+ end
105
+ return nil
106
+ end
107
+
108
+ def extract(val, key, field)
109
+ if val.nil?
110
+ Deplate::Core.log(['Unknown variable', key], :error)
111
+ elsif val.kind_of?(Struct) || val.kind_of?(OpenStruct)
112
+ return val.send(field)
113
+ elsif val.kind_of?(Hash)
114
+ return val[field]
115
+ elsif val.kind_of?(Array)
116
+ if field =~ /^[0-9]+$/
117
+ field = field.to_i
118
+ return val[field]
119
+ else
120
+ Deplate::Core.log(['Wrong index', field, name, val.class], :error)
121
+ end
122
+ else
123
+ Deplate::Core.log(['Variable has wrong type', key, val.class], :warning)
124
+ end
125
+ end
126
+ end
127
+
@@ -3,8 +3,8 @@
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 10-M�r-2005.
6
- # @Last Change: 23-Okt-2005.
7
- # @Revision: 0.221
6
+ # @Last Change: 30-Mrz-2006.
7
+ # @Revision: 0.260
8
8
  #
9
9
  # = Description
10
10
  # Various elements for defining input filters
@@ -12,48 +12,116 @@
12
12
  # = TODO
13
13
  # = CHANGES
14
14
 
15
+ require "deplate/abstract-class"
16
+
15
17
  module Deplate::Input::Wiki; end
16
18
 
19
+ # Textstyles
20
+ # Italic
17
21
  class Deplate::Input::Wiki::ItalicWordSingleUnderscore < Deplate::Particle::Emphasize
18
- @rx = /^\b_(\S+?)_\b/
22
+ set_rx(/^\b_(\S+?)_\b/)
19
23
  end
20
24
 
21
- class Deplate::Input::Wiki::BoldWordSingleAsterisk < Deplate::Particle::Emphasize
22
- @rx = /^\B\*(\S+?)\*\B/
25
+ class Deplate::Input::Wiki::ItalicDoubleSlash < Deplate::Particle::Emphasize
26
+ set_rx(/^\b\/\/(\S+?)\/\/\b/)
23
27
  end
24
28
 
25
- class Deplate::Input::Wiki::TypewriterWordSinglePlus < Deplate::Particle::Code
26
- @rx = /^\B\+(\S+?)\+\B/
29
+
30
+ # Bold
31
+ class Deplate::Input::Wiki::Bold < Deplate::Particle::Emphasize
32
+ def setup
33
+ @args['style'] = 'bold'
34
+ update_styles
35
+ super
36
+ end
27
37
  end
28
38
 
29
- # Treat a reference to an image as included images. Requires subclassing and a
30
- # definition of @rx.
31
- class Deplate::Input::Wiki::AbstractImgUrl < Deplate::HyperLink::Url
32
- def get_destination
33
- @match[1]
39
+ class Deplate::Input::Wiki::BoldWordSingleAsterisk < Deplate::Input::Wiki::Bold
40
+ set_rx(/^\B\*(\S+?)\*\B/)
41
+ end
42
+
43
+ class Deplate::Input::Wiki::BoldDoubleAsterisk < Deplate::Input::Wiki::Bold
44
+ set_rx(/^\*\*(\S+?)\*\*/)
45
+ end
46
+
47
+
48
+ # Superscript
49
+ class Deplate::Input::Wiki::Superscript < Deplate::SimpleParticle
50
+ set_formatter :format_superscript
51
+ end
52
+
53
+ class Deplate::Input::Wiki::SuperscriptTagSup < Deplate::Input::Wiki::Superscript
54
+ set_rx(/^<sup>(.*?)<\/sup>/)
55
+ end
56
+
57
+
58
+ # Subscript
59
+ class Deplate::Input::Wiki::Subscript < Deplate::SimpleParticle
60
+ set_formatter :format_subscript
61
+ end
62
+
63
+ class Deplate::Input::Wiki::SubscriptTagSub < Deplate::Input::Wiki::Subscript
64
+ set_rx(/^<sub>(.*?)<\/sub>/)
65
+ end
66
+
67
+
68
+ # Strikethrough
69
+ class Deplate::Input::Wiki::StrikeThrough < Deplate::Particle::Emphasize
70
+ def setup
71
+ @args['style'] = 'strikethrough'
72
+ update_styles
73
+ super
34
74
  end
75
+ end
76
+
77
+ class Deplate::Input::Wiki::StrikethroughTagDeleted < Deplate::Input::Wiki::StrikeThrough
78
+ set_rx(/^<deleted>(.*?)<\/deleted>/)
79
+ end
80
+
81
+
82
+ # Typewriter
83
+ class Deplate::Input::Wiki::TypewriterWordSinglePlus < Deplate::Particle::Code
84
+ set_rx(/^\B\+(\S+?)\+\B/)
85
+ end
35
86
 
36
- def get_anchor
37
- nil
87
+ module Deplate::Input::Wiki::AbstractImg
88
+ def image_args
89
+ {}
38
90
  end
39
91
 
40
- def process
41
- @elt = @deplate.formatter.include_image(@dest, @args, true)
92
+ def image_process
93
+ args = @args.dup
94
+ args.update(image_args)
95
+ @elt = @deplate.formatter.include_image(self, @dest, args, true)
42
96
  end
43
97
  end
44
98
 
99
+ # Treat a reference to an image as included images. Requires subclassing and a
100
+ # definition of @rx.
101
+ class Deplate::Input::Wiki::ImgUrl < Deplate::HyperLink::Url
102
+ set_rx(/^((file|https?|mailto|ftps?|www):(\S+?)\.(png|jpg|jpeg|gif|bmp))\b/)
103
+ include Deplate::Input::Wiki::AbstractImg
104
+ alias :process :image_process
105
+ end
106
+
45
107
  # Treat non-indented text as paragraph, indented as verbatim.
46
108
  class Deplate::Input::Wiki::ParagraphIndentedVerbatim < Deplate::Element::Paragraph
47
- @rx = /^([ \t]*)(.+)[ \t]*$/
109
+ set_rx(/^([ \t]*)(.+)[ \t]*$/)
110
+ set_formatter nil
111
+
48
112
  def get_text
49
113
  @leading_whitespace = @match[1]
50
114
  @keep_whitespace = !@leading_whitespace.empty?
51
115
  @match[2]
52
116
  end
53
117
 
54
- def to_be_continued?(line)
55
- indent = get_indent(line).size
56
- return @level > 0 || indent == 0
118
+ def to_be_continued?(line, klass, match)
119
+ if super
120
+ indent = get_indent(line).size
121
+ return @level > 0 || indent == 0
122
+ else
123
+ return false
124
+ end
57
125
  end
58
126
 
59
127
  def format_special
@@ -84,34 +152,32 @@ module Deplate::Input::Wiki::ListExtra
84
152
  end
85
153
  end
86
154
 
87
- class Deplate::Input::Wiki::NumberedNotIndented < Deplate::List::Numbered
155
+ class Deplate::Input::Wiki::OrderedNotIndented < Deplate::List::Ordered
88
156
  include Deplate::Input::Wiki::ListExtra
89
- @formatter = :format_list
90
- @name = "Numbered"
91
- @rx = /^(()([0-9]+\.|[a-zA-Z]\.)[ \t]+)(.+)$/
157
+ set_rx(/^(()([0-9]+\.|[a-zA-Z]\.)[ \t]+)(.+)$/)
92
158
  end
93
159
 
94
160
  class Deplate::Input::Wiki::ItemizeNotIndented < Deplate::List::Itemize
95
161
  include Deplate::Input::Wiki::ListExtra
96
- @formatter = :format_list
97
- @name = "Itemize"
98
- @rx = /^(()([-*])[ \t]+)(.+)$/
162
+ set_rx(/^(()([-*])[ \t]+)(.+)$/)
99
163
  end
100
164
 
101
165
  # Requires subclassing & definition of @rx.
102
166
  class Deplate::Input::Wiki::AbstractDescription < Deplate::List::Description
103
167
  include Deplate::Input::Wiki::ListExtra
104
- @formatter = :format_list
105
- @name = "Description"
106
168
  end
107
169
 
170
+ # Heading
108
171
  class Deplate::Input::Wiki::HeadingPrefixEqual < Deplate::Element::Heading
109
- @formatter = :format_heading
110
- @rx = /^(=+)[ \t]+(.*?)$/
172
+ set_rx(/^(=+)[ \t]+(.*?)$/)
173
+ end
174
+
175
+ class Deplate::Input::Wiki::HeadingEqual < Deplate::Element::Heading
176
+ set_rx(/^(=+)[[:blank:]]*(.*?)[[:blank:]]*\1$/)
111
177
  end
112
178
 
179
+ # Page Break
113
180
  class Deplate::Input::Wiki::Break3Hyphens < Deplate::Element::Break
114
- @formatter = :format_break
115
- @rx = /^\s*-{3,}\s*$/
181
+ set_rx(/^\s*-{3,}\s*$/)
116
182
  end
117
183