deplate 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/AUTHORS.TXT +26 -0
  2. data/CHANGES.TXT +177 -0
  3. data/LICENSE.TXT +340 -0
  4. data/NEWS.TXT +29 -0
  5. data/README.TXT +86 -0
  6. data/TODO.TXT +202 -0
  7. data/VERSION.TXT +1 -0
  8. data/bin/deplate +3 -0
  9. data/bin/deplate.bat +2 -0
  10. data/etc/deplate.ini +361 -0
  11. data/lib/deplate.rb +31 -0
  12. data/lib/deplate/abstract-class.rb +30 -0
  13. data/lib/deplate/builtin.rb +11 -0
  14. data/lib/deplate/cache.rb +59 -0
  15. data/lib/deplate/commands.rb +693 -0
  16. data/lib/deplate/common.rb +335 -0
  17. data/lib/deplate/converter.rb +99 -0
  18. data/lib/deplate/core.rb +2705 -0
  19. data/lib/deplate/css/article.css +545 -0
  20. data/lib/deplate/css/deplate.css +699 -0
  21. data/lib/deplate/css/heading-navbar.css +29 -0
  22. data/lib/deplate/css/layout-deplate-print.css +540 -0
  23. data/lib/deplate/css/layout-deplate.css +764 -0
  24. data/lib/deplate/css/sans-serif.css +160 -0
  25. data/lib/deplate/css/serif-e.css +170 -0
  26. data/lib/deplate/css/serif-rel.css +121 -0
  27. data/lib/deplate/css/serif.css +190 -0
  28. data/lib/deplate/css/slides.css +11 -0
  29. data/lib/deplate/css/tabbar-left.css +91 -0
  30. data/lib/deplate/css/tabbar-right-ie.css +14 -0
  31. data/lib/deplate/css/tabbar-right.css +118 -0
  32. data/lib/deplate/css/tabbar-top.css +64 -0
  33. data/lib/deplate/css/tabbar.css +81 -0
  34. data/lib/deplate/css/text-sans-serif.css +154 -0
  35. data/lib/deplate/css/text-serif.css +175 -0
  36. data/lib/deplate/define.rb +439 -0
  37. data/lib/deplate/docbook.rb +738 -0
  38. data/lib/deplate/elements.rb +1355 -0
  39. data/lib/deplate/etc.rb +199 -0
  40. data/lib/deplate/external.rb +135 -0
  41. data/lib/deplate/fmt/dbk-article-4.1.2.rb +21 -0
  42. data/lib/deplate/fmt/dbk-article.rb +46 -0
  43. data/lib/deplate/fmt/dbk-book.rb +46 -0
  44. data/lib/deplate/fmt/dbk-ref.rb +105 -0
  45. data/lib/deplate/fmt/dbk-slides.rb +47 -0
  46. data/lib/deplate/fmt/dbk-snippet.rb +21 -0
  47. data/lib/deplate/fmt/html-snippet.rb +21 -0
  48. data/lib/deplate/fmt/html.rb +1696 -0
  49. data/lib/deplate/fmt/htmlsite.rb +419 -0
  50. data/lib/deplate/fmt/htmlslides.rb +21 -0
  51. data/lib/deplate/fmt/htmlwebsite.rb +70 -0
  52. data/lib/deplate/fmt/latex-snippet.rb +22 -0
  53. data/lib/deplate/fmt/latex.rb +1242 -0
  54. data/lib/deplate/fmt/php.rb +19 -0
  55. data/lib/deplate/fmt/phpsite.rb +19 -0
  56. data/lib/deplate/fmt/plain.rb +598 -0
  57. data/lib/deplate/fmt/template.rb +34 -0
  58. data/lib/deplate/fmt/xhtml10t.rb +41 -0
  59. data/lib/deplate/formatter-snippet.rb +17 -0
  60. data/lib/deplate/formatter.rb +1210 -0
  61. data/lib/deplate/input.rb +492 -0
  62. data/lib/deplate/input/deplate-headings.rb +48 -0
  63. data/lib/deplate/input/deplate-restricted.rb +70 -0
  64. data/lib/deplate/input/deplate.rb +28 -0
  65. data/lib/deplate/input/rdoc.rb +277 -0
  66. data/lib/deplate/input/template.rb +29 -0
  67. data/lib/deplate/lib/latex/highlight-extra.sty +15 -0
  68. data/lib/deplate/lib/latex/highlight-typical.sty +15 -0
  69. data/lib/deplate/lib/tabmenu.js +146 -0
  70. data/lib/deplate/locale/de.latin1 +708 -0
  71. data/lib/deplate/locale/ru.koi8-r +48 -0
  72. data/lib/deplate/locale/zh_cn.gb2312 +35 -0
  73. data/lib/deplate/macros.rb +639 -0
  74. data/lib/deplate/messages.rb +120 -0
  75. data/lib/deplate/metadata.rb +77 -0
  76. data/lib/deplate/metadata/marshal.rb +24 -0
  77. data/lib/deplate/metadata/xml.rb +42 -0
  78. data/lib/deplate/metadata/yaml.rb +26 -0
  79. data/lib/deplate/mod/anyword.rb +56 -0
  80. data/lib/deplate/mod/babelfish.rb +27 -0
  81. data/lib/deplate/mod/code-gvim.rb +52 -0
  82. data/lib/deplate/mod/code-highlight.rb +91 -0
  83. data/lib/deplate/mod/colored-log.rb +17 -0
  84. data/lib/deplate/mod/de.rb +19 -0
  85. data/lib/deplate/mod/en.rb +17 -0
  86. data/lib/deplate/mod/endnotes.rb +60 -0
  87. data/lib/deplate/mod/fr.rb +46 -0
  88. data/lib/deplate/mod/html-asciimath.rb +40 -0
  89. data/lib/deplate/mod/html-deplate-button.rb +15 -0
  90. data/lib/deplate/mod/html-headings-navbar.rb +39 -0
  91. data/lib/deplate/mod/html-obfuscate-email.rb +47 -0
  92. data/lib/deplate/mod/html-sidebar.rb +232 -0
  93. data/lib/deplate/mod/htmlslides-navbar-fh.rb +32 -0
  94. data/lib/deplate/mod/iconv.rb +35 -0
  95. data/lib/deplate/mod/imgurl.rb +30 -0
  96. data/lib/deplate/mod/inlatex-compound.rb +69 -0
  97. data/lib/deplate/mod/koma.rb +109 -0
  98. data/lib/deplate/mod/latex-emph-table-head.rb +38 -0
  99. data/lib/deplate/mod/latex-styles.rb +461 -0
  100. data/lib/deplate/mod/latex-verbatim-small.rb +29 -0
  101. data/lib/deplate/mod/makefile.rb +194 -0
  102. data/lib/deplate/mod/mark-external-urls.rb +38 -0
  103. data/lib/deplate/mod/markup-1-warn.rb +37 -0
  104. data/lib/deplate/mod/markup-1.rb +41 -0
  105. data/lib/deplate/mod/navbar-png.rb +33 -0
  106. data/lib/deplate/mod/noindent.rb +32 -0
  107. data/lib/deplate/mod/numpara.rb +40 -0
  108. data/lib/deplate/mod/particle-math.rb +34 -0
  109. data/lib/deplate/mod/php-extra.rb +44 -0
  110. data/lib/deplate/mod/pstoedit.rb +71 -0
  111. data/lib/deplate/mod/recode.rb +57 -0
  112. data/lib/deplate/mod/ru_koi8-r.rb +20 -0
  113. data/lib/deplate/mod/smiley.rb +50 -0
  114. data/lib/deplate/mod/soffice.rb +23 -0
  115. data/lib/deplate/mod/symbols-latin1.rb +58 -0
  116. data/lib/deplate/mod/symbols-od-utf-8.rb +16 -0
  117. data/lib/deplate/mod/symbols-plain.rb +58 -0
  118. data/lib/deplate/mod/symbols-sgml.rb +97 -0
  119. data/lib/deplate/mod/symbols-utf-8.rb +81 -0
  120. data/lib/deplate/mod/symbols-xml.rb +34 -0
  121. data/lib/deplate/mod/syntax-region-alt.rb +37 -0
  122. data/lib/deplate/mod/utf8.rb +49 -0
  123. data/lib/deplate/mod/validate-html.rb +35 -0
  124. data/lib/deplate/mod/xmlrpc.rb +233 -0
  125. data/lib/deplate/mod/zh-cn-autospace.rb +108 -0
  126. data/lib/deplate/mod/zh-cn.rb +59 -0
  127. data/lib/deplate/once-method.rb +44 -0
  128. data/lib/deplate/output.rb +249 -0
  129. data/lib/deplate/particles.rb +815 -0
  130. data/lib/deplate/regions.rb +1076 -0
  131. data/lib/deplate/structured.rb +763 -0
  132. data/lib/deplate/template.rb +430 -0
  133. data/lib/deplate/templates/html-doc.html +28 -0
  134. data/lib/deplate/templates/html-left-tabbar-js.html +37 -0
  135. data/lib/deplate/templates/html-left-tabbar.html +31 -0
  136. data/lib/deplate/templates/html-tabbar-right-table.html +43 -0
  137. data/lib/deplate/templates/html-tabbar-right.html +23 -0
  138. data/lib/deplate/templates/html-tabbar-top.html +43 -0
  139. data/lib/deplate/templates/html-tabbar.html +31 -0
  140. data/lib/deplate/wiki-markup.rb +117 -0
  141. data/lib/deplate/xml.rb +109 -0
  142. data/lib/deplate/zh-cn.rb +59 -0
  143. data/lib/ps2ppm.rb +239 -0
  144. data/man/man1/deplate.1 +692 -0
  145. metadata +210 -0
@@ -0,0 +1,81 @@
1
+ /* TabBar */
2
+ div.tabBarLeft {
3
+ max-width: 250px;
4
+ }
5
+ div.bodyRight {
6
+ position: relative;
7
+ left: 250px;
8
+ }
9
+ a.tabBarEntry {
10
+ }
11
+ .tabBar, .tabBody {
12
+ background-color: #ffffff;
13
+ vertical-align: top;
14
+ }
15
+
16
+ div#pin {
17
+ }
18
+ div.tabBar {
19
+ /* position: absolute; */
20
+ /* float: right; */
21
+ /* top: 10px; */
22
+ /* z-index: 2; */
23
+ border: 1px dashed #cae0ea;
24
+ /* background-color: #dfdfff; */
25
+ background-color: #f0f0f0;
26
+ padding: 15px;
27
+ z-index: 2;
28
+ }
29
+ #tabBodyFrame {
30
+ /* position: absolute; */
31
+ /* top: 0px; */
32
+ /* left: 140px; */
33
+ /* z-index: 1; */
34
+ min-width: 600px;
35
+ max-width: 800px;
36
+ text-align: left;
37
+ }
38
+ div.tabBodyFrame {
39
+ width: 700px;
40
+ z-index: 5;
41
+ }
42
+ div.tabBody {
43
+ border: 1px dashed #cae0ea;
44
+ /* border: 1px solid #cae0ea; */
45
+ padding: 10px;
46
+ margin: 10px;
47
+ /* width: 700px; */
48
+ text-align: left;
49
+ }
50
+
51
+ table.tabBar {
52
+ table-layout:fixed;
53
+ max-width: 200px;
54
+ min-width: 200px;
55
+ padding: 0;
56
+ border: 0;
57
+ border-spacing: 10px;
58
+ }
59
+ tr.tabBar {
60
+ }
61
+ td.tabBar {
62
+ padding: 4px;
63
+ border-right: 20px solid #faf0fa;
64
+ }
65
+ td.tabBody {
66
+ }
67
+
68
+ .buttonRow {
69
+ background-color: #f0f0f0;
70
+ text-align: center;
71
+ padding: 0;
72
+ border: 0;
73
+ padding: 0;
74
+ }
75
+ table.buttonRow {
76
+ }
77
+ tr.buttonRow {
78
+ }
79
+ td.buttonRow {
80
+ }
81
+
@@ -0,0 +1,154 @@
1
+ /* Text style: sans-serif */
2
+ /* @Author: Thomas Link (samul AT web.de) */
3
+ /* @Created: 13-Apr-2004. */
4
+ /* @Last Change: 20-Feb-2005. */
5
+ /* @Revision: 0.587 */
6
+
7
+ body, table, div {
8
+ /* font-family: Verdana, Geneva, Sans-Serif; */
9
+ /* font-family : Georgia, Serif; */
10
+ font-family : Verdana, Monaco, Sans-Serif;
11
+ font-size: 12px;
12
+ }
13
+
14
+ big {
15
+ font-weight: bolder;
16
+ }
17
+
18
+ h1, h2, h3, h4, h5, h6 {
19
+ font-weight: bold;
20
+ font-family : Verdana, Monaco, Sans-Serif;
21
+ }
22
+ h1 {
23
+ font-size: 34px;
24
+ }
25
+ h2 {
26
+ font-size: 28px;
27
+ }
28
+ h3 {
29
+ font-size: 24px;
30
+ }
31
+ h4 {
32
+ font-size: 20px;
33
+ }
34
+ h5 {
35
+ font-size: 18px;
36
+ }
37
+ h6 {
38
+ font-size: 16px;
39
+ }
40
+
41
+ tr.head, tr.foot, tr.high, th, td.foot, td.high {
42
+ font-weight: bold;
43
+ }
44
+ div.tableNote {
45
+ font-size: 10px;
46
+ font-style: italic;
47
+ }
48
+
49
+ blockquote {
50
+ font-family : Serif;
51
+ }
52
+ blockquote.abstract {
53
+ font-style: italic;
54
+ }
55
+
56
+ dt {
57
+ font-weight: bold;
58
+ }
59
+
60
+ code, pre {
61
+ font-family : Courier New, Courier, Monospace;
62
+ }
63
+ pre {
64
+ font-size: 12px;
65
+ }
66
+
67
+ /* htmlslides: Usage note */
68
+
69
+ /* Navigation bar */
70
+ a:link.navbar, a:visited.navbar {
71
+ text-decoration: none;
72
+ font-size: 10px;
73
+ }
74
+ select.navmenu {
75
+ font-size:10px;
76
+ }
77
+ p.navgo {
78
+ font-size:10px;
79
+ }
80
+
81
+ /* Figure */
82
+
83
+ /* Caption */
84
+ caption, p.caption {
85
+ font-weight: bold;
86
+ }
87
+
88
+ /* Title */
89
+ p.title, p.author, p.authornote, p.date {
90
+ font-weight: bold;
91
+ }
92
+ p.title {
93
+ font-size: 34px;
94
+ }
95
+ p.author {
96
+ font-size: 28px;
97
+ }
98
+ p.authornote {
99
+ font-size: 24px;
100
+ }
101
+ p.date {
102
+ font-size: 24px;
103
+ }
104
+
105
+ /* Table of Contents etc. */
106
+
107
+ /* Mini Table of Contents */
108
+
109
+ /* Footnotes */
110
+ a:link.footnote, a:visited.footnote {
111
+ font-size: 8px;
112
+ text-decoration: none;
113
+ }
114
+ p.footnotes, ol.footnotes, li.footnotes {
115
+ font-size: 10px;
116
+ }
117
+ p.footnotes {
118
+ font-weight: bold;
119
+ }
120
+
121
+ /* OpenOffice compatible footnotes */
122
+ .sdfootnoteanc {
123
+ font-size: 8px;
124
+ }
125
+ .sdfootnotesym {
126
+ font-size: 10px;
127
+ }
128
+ p.sdfootnote {
129
+ font-size: 10px;
130
+ }
131
+
132
+ /* Bibliography */
133
+
134
+ /* Index */
135
+
136
+ /* Marker */
137
+
138
+ /* Header, Footer */
139
+
140
+ /* Validate HTML */
141
+
142
+ /* TabBar */
143
+ .tabBarLeft {
144
+ font-size: 10px;
145
+ }
146
+ a.tabBarEntry {
147
+ text-decoration: none;
148
+ }
149
+
150
+ /* ProgressBar */
151
+ span.progress {
152
+ font-size: 10px;
153
+ }
154
+
@@ -0,0 +1,175 @@
1
+ /* Text style: sans-serif */
2
+ /* @Author: Thomas Link (samul AT web.de) */
3
+ /* @Created: 13-Apr-2004. */
4
+ /* @Last Change: 21-Mai-2005. */
5
+ /* @Revision: 0.585 */
6
+
7
+ body, table, div {
8
+ font-family : Serif;
9
+ font-size: 14px;
10
+ }
11
+
12
+ big {
13
+ font-weight: bolder;
14
+ }
15
+
16
+ h1, h2, h3, h4, h5, h6 {
17
+ font-weight: bold;
18
+ }
19
+ h1 {
20
+ font-size: 28px;
21
+ }
22
+ h2 {
23
+ font-size: 24px;
24
+ }
25
+ h3 {
26
+ font-size: 20px;
27
+ }
28
+ h4 {
29
+ font-size: 18px;
30
+ }
31
+ h5 {
32
+ font-size: 16px;
33
+ }
34
+ h6 {
35
+ font-size: 16px;
36
+ }
37
+
38
+ tr.head {
39
+ font-weight: bold;
40
+ }
41
+ th {
42
+ font-weight: bold;
43
+ }
44
+ div.tableNote {
45
+ font-size: 12px;
46
+ font-style: italic;
47
+ }
48
+ .small {
49
+ font-size: 11px;
50
+ }
51
+ .scriptsize {
52
+ font-size: 10px;
53
+ }
54
+ .footnotesize {
55
+ font-size: 9px;
56
+ }
57
+
58
+ blockquote {
59
+ font-family : Sans-Serif;
60
+ }
61
+ blockquote.quote {
62
+ }
63
+ blockquote.longquote {
64
+ }
65
+ blockquote.abstract {
66
+ font-style: italic;
67
+ }
68
+
69
+ dt {
70
+ font-weight: bold;
71
+ }
72
+
73
+ code, pre {
74
+ font-family: Courier New, Courier, Monospace;
75
+ }
76
+ pre {
77
+ font-size: 12px;
78
+ }
79
+
80
+
81
+ /* htmlslides: Usage note */
82
+
83
+
84
+ /* Navigation bar */
85
+ a:link.navbar, a:visited.navbar {
86
+ text-decoration: none;
87
+ font-size: 12px;
88
+ }
89
+ select.navmenu {
90
+ font-size:9px;
91
+ }
92
+ p.navgo {
93
+ font-size:9px;
94
+ }
95
+
96
+
97
+ /* Figure */
98
+
99
+
100
+ /* Caption */
101
+ caption, p.caption {
102
+ font-weight: bold;
103
+ }
104
+
105
+ /* Title */
106
+ p.title, p.author, p.authornote, p.date {
107
+ font-weight: bold;
108
+ }
109
+ p.title {
110
+ font-size: 28px;
111
+ }
112
+ p.author {
113
+ font-size: 24px;
114
+ }
115
+ p.authornote {
116
+ font-size: 18px;
117
+ }
118
+ p.date {
119
+ font-size: 18px;
120
+ }
121
+
122
+
123
+ /* Table of Contents etc. */
124
+
125
+
126
+ /* Mini Table of Contents */
127
+
128
+
129
+ /* Footnotes */
130
+ a:link.footnote, a:visited.footnote {
131
+ font-size: 9px;
132
+ text-decoration: none;
133
+ }
134
+ p.footnotes, ol.footnotes, li.footnotes {
135
+ font-size: 12px;
136
+ }
137
+ p.footnotes {
138
+ font-weight: bold;
139
+ }
140
+
141
+
142
+ /* OpenOffice compatible footnotes */
143
+ .sdfootnoteanc {
144
+ font-size: 9px;
145
+ }
146
+ .sdfootnotesym, .sdfootnote {
147
+ font-size: 12px;
148
+ }
149
+
150
+
151
+ /* Bibliography */
152
+
153
+
154
+ /* Index */
155
+
156
+
157
+ /* Marker */
158
+
159
+
160
+ /* Header, Footer */
161
+
162
+
163
+ /* Validate HTML */
164
+
165
+
166
+ /* TabBar */
167
+ .tabBarLeft {
168
+ font-size: 12px;
169
+ }
170
+
171
+ /* ProgressBar */
172
+ span.progress {
173
+ font-size: 12px;
174
+ }
175
+
@@ -0,0 +1,439 @@
1
+ # define.rb
2
+ # @Author: Thomas Link (samul AT web.de)
3
+ # @Website: http://deplate.sf.net/
4
+ # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
+ # @Created: 19-Okt-2004.
6
+ # @Last Change: 23-Okt-2005.
7
+ # @Revision: 0.402
8
+
9
+ require "deplate/commands"
10
+ require "deplate/macros"
11
+
12
+ module Deplate::DefRegions; end
13
+ module Deplate::DefElements; end
14
+ module Deplate::DefParticles; end
15
+ module Deplate::DefCommand; end
16
+ module Deplate::DefMacro; end
17
+
18
+ # Description:
19
+ #
20
+ # Usage:
21
+ #
22
+ # TODO:
23
+ #
24
+ # CHANGES:
25
+ #
26
+ class Deplate::Define < Deplate::Region
27
+ @line_cont = true
28
+
29
+ class << self
30
+ def let_variables(deplate, args, &block)
31
+ unset = []
32
+ saved = {}
33
+ begin
34
+ for key, val in args
35
+ if key.kind_of?(String)
36
+ opt = deplate.variables[key]
37
+ if opt
38
+ saved[key] = opt
39
+ else
40
+ unset << key
41
+ end
42
+ deplate.variables[key] = val
43
+ end
44
+ end
45
+ block.call
46
+ ensure
47
+ for key in unset
48
+ deplate.variables.delete(key)
49
+ end
50
+ for key, val in saved
51
+ deplate.variables[key] = val
52
+ end
53
+ end
54
+ end
55
+
56
+ def check_arguments(mandatory, args, source)
57
+ if mandatory
58
+ diff = mandatory.split(/\s+/) - args.keys
59
+ unless diff.empty?
60
+ Deplate::Core.log(["Missing arguments", diff], :error, source)
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ def finish
67
+ finish_accum
68
+ define
69
+ return nil
70
+ end
71
+
72
+ def valid_id?(id)
73
+ if id =~ /\W/
74
+ log(["Invalid id", id], :error)
75
+ return false
76
+ else
77
+ return true
78
+ end
79
+ end
80
+
81
+ def valid_switch(arg, default)
82
+ case arg
83
+ when 'false', '0', 'F'
84
+ 'false'
85
+ when 'true', '1', 'T'
86
+ 'true'
87
+ else
88
+ default
89
+ end
90
+ end
91
+ end
92
+
93
+
94
+ # class Deplate::Define::Region < Deplate::Region::SecondOrder
95
+ class Deplate::Define::Region < Deplate::Region
96
+ @line_cont = true
97
+ def finish
98
+ finish_accum
99
+ setup_template
100
+ @args["@body"] = @accum.join("\n")
101
+ @args["@note"] = @regNote
102
+ Deplate::Define.check_arguments(@mandatory, @args, @source)
103
+ @expected = Deplate::Element
104
+ @elt = []
105
+ Deplate::Define.let_variables(@deplate, @args) do
106
+ @elt = @deplate.parsed_array_from_strings(@template, @source.begin, @source.file)
107
+ end
108
+ unless @elt.empty?
109
+ @elt.first.put_label(@label)
110
+ end
111
+ return @elt
112
+ end
113
+ end
114
+
115
+ class Deplate::Regions::DefRegion < Deplate::Define
116
+ @@regions["DefRegion"] = self
117
+ @@regions["DefineRegion"] = self
118
+ @@regions["Defr"] = self
119
+
120
+ def define
121
+ id = @args["id"] || @regNote
122
+ if valid_id?(id)
123
+ region = %{
124
+ class Deplate::DefRegions::#{id} < Deplate::Define::Region
125
+ @@regions["#{id}"] = self
126
+ def setup_template
127
+ @template = #{@accum.inspect}
128
+ @mandatory = #{@args["args"].inspect}
129
+ end
130
+ end
131
+ }
132
+ eval region
133
+ end
134
+ end
135
+ end
136
+
137
+
138
+ class Deplate::Regions::DefElement < Deplate::Define
139
+ @@regions["DefElement"] = self
140
+ @@regions["DefineElement"] = self
141
+ @@regions["Defe"] = self
142
+ @@def_element_counter = 0
143
+
144
+ @line_cont = false
145
+
146
+ def define
147
+ rx = @args['rx'] || @regNote
148
+ if rx
149
+ @@def_element_counter += 1
150
+ template = @accum.join("\n").gsub(/\'/, "\\\\\'")
151
+ rx = Regexp.new(rx).source.gsub(/\//, '\\\\/')
152
+ multiline = valid_switch(@args['multiline'], 'true')
153
+ collapse = valid_switch(@args['collapse'], 'false')
154
+ eval %{
155
+ class Deplate::DefElements::Elt#{@@def_element_counter} < Deplate::Element
156
+ @@elements << self
157
+ @rx = /^#{rx}/
158
+ TPL = '#{template}'
159
+
160
+ def setup
161
+ @multiliner = #{multiline}
162
+ @collapse = #{collapse}
163
+ @accum = [@match[0]]
164
+ end
165
+
166
+ def finish
167
+ m = self.class.match(@accum.join(' '))
168
+ if m
169
+ m.captures.each_with_index do |e, i|
170
+ @args[(i + 1).to_s] = e
171
+ end
172
+ @expected = Deplate::Element
173
+ tmpl = Deplate::Template.new(:template => TPL,
174
+ :source => @source,
175
+ :container => self)
176
+ Deplate::Define.let_variables(@deplate, @args) do
177
+ @accum = tmpl.fill_in(@deplate, :source => @source)
178
+ end
179
+ @accum.flatten!
180
+ @accum.collect! {|l| l.split("\n")}
181
+ @accum.flatten!
182
+ else
183
+ raise 'Internal error!'
184
+ end
185
+ @elt = @deplate.parsed_array_from_strings(@accum, @source.begin, @source.file)
186
+ return @elt
187
+ end
188
+ end
189
+ }
190
+ end
191
+ end
192
+ end
193
+
194
+
195
+ class Deplate::Regions::DefParticle < Deplate::Define
196
+ @@regions["DefParticle"] = self
197
+ @@regions["DefineParticle"] = self
198
+ @@regions["Defp"] = self
199
+ @@def_particle_counter = 0
200
+
201
+ def define
202
+ rx = @args['rx'] || @regNote
203
+ if rx
204
+ template = @accum.join("\n").gsub(/\'/, "\\\\\'")
205
+ rx = Regexp.new(rx).source
206
+ multiline = valid_switch(@args['multiline'], 'true')
207
+ collapse = valid_switch(@args['collapse'], 'false')
208
+ cls = @deplate.formatter.retrieve_particle(rx, template)
209
+ body = <<-EOR
210
+ @rx = /^#{rx}/
211
+ TPL = '#{template}'
212
+
213
+ def setup
214
+ @match.captures.each_with_index do |e, i|
215
+ @args[(i + 1).to_s] = e
216
+ end
217
+ @expected = Deplate::Particle
218
+ tmpl = Deplate::Template.new(:template => TPL,
219
+ :source => @source,
220
+ :container => self)
221
+ Deplate::Define.let_variables(@deplate, @args) do
222
+ @elt = tmpl.fill_in(@deplate, :source => @source)
223
+ end
224
+ @elt = @deplate.parse(@container, @elt.join(' '))
225
+ end
226
+
227
+ def process
228
+ @elt = @deplate.format_particles(@elt)
229
+ end
230
+ EOR
231
+ cls = Deplate::Cache.particle(deplate, body, :register => true)
232
+ end
233
+ end
234
+ end
235
+
236
+
237
+ class Deplate::Define::Command < Deplate::Command
238
+ class << self
239
+ def accumulate(source, array, deplate, text, match, args, cmd)
240
+ Deplate::Core.log("%s: %s" % [cmd, text], :debug)
241
+ template, mandatory = setup_template(text, deplate)
242
+ args["@body"] = text
243
+ Deplate::Define.check_arguments(mandatory, args, source)
244
+ Deplate::Define.let_variables(deplate, args) do
245
+ deplate.include_stringarray(template, array, source.begin, source.file)
246
+ end
247
+ end
248
+ end
249
+ end
250
+
251
+
252
+ class Deplate::Regions::DefCommand < Deplate::Define
253
+ @@regions["DefCommand"] = self
254
+ @@regions["DefCmd"] = self
255
+ @@regions["DefineCommand"] = self
256
+ @@regions["Defc"] = self
257
+
258
+ def define
259
+ id = @args["id"] || @regNote
260
+ if valid_id?(id)
261
+ eval %{
262
+ class Deplate::DefCommand::#{id} < Deplate::Define::Command
263
+ @@commands["#{id}"] = self
264
+ class << self
265
+ def setup_template(text, deplate)
266
+ [#{@accum.inspect}, #{@args["args"].inspect}]
267
+ end
268
+ end
269
+ end
270
+ }
271
+ end
272
+ end
273
+ end
274
+
275
+
276
+ class Deplate::Define::Macro < Deplate::Macro
277
+ @line_cont = true
278
+ def setup(text)
279
+ setup_template(text)
280
+ @args["@body"] = text
281
+ Deplate::Define.check_arguments(@mandatory, @args, @container.source)
282
+ tmpl = Deplate::Template.new(:master => @deplate,
283
+ :template => @template,
284
+ :source => @source,
285
+ :container => self)
286
+ rv = nil
287
+ Deplate::Define.let_variables(@deplate, @args) do
288
+ rv = tmpl.fill_in(@deplate)
289
+ end
290
+ @elt = @deplate.parse(self, rv.join(' '))
291
+ end
292
+ end
293
+
294
+
295
+ class Deplate::Regions::DefMacro < Deplate::Define
296
+ @@regions["DefMacro"] = self
297
+ @@regions["DefineMacro"] = self
298
+ @@regions["Defm"] = self
299
+ def define
300
+ id = @args["id"] || @regNote
301
+ if valid_id?(id)
302
+ eval %{
303
+ class Deplate::DefMacro::Define_#{id} < Deplate::Define::Macro
304
+ @@macros[#{id.inspect}] = self
305
+ def setup_template(text)
306
+ @template = #{@accum.join("\n").inspect}
307
+ @mandatory = #{@args["args"].inspect}
308
+ @macro_id = #{id.inspect}
309
+ end
310
+ end
311
+ }
312
+ # @deplate.initialize_particles(true)
313
+ end
314
+ end
315
+ end
316
+
317
+
318
+
319
+ class Deplate::Regions::Native
320
+ def expand_template
321
+ @args["@note"] = @regNote
322
+ @args["@body"] = @accum.join("\n")
323
+ tmpl = Deplate::Template.new(:master => @deplate,
324
+ :template => @template,
325
+ :source => @source,
326
+ :container => self)
327
+ rv = nil
328
+ Deplate::Define.let_variables(@deplate, @args) do
329
+ rv = tmpl.fill_in(@deplate, :body => @args["@body"], :source => @source)
330
+ end
331
+ return rv
332
+ end
333
+ end
334
+
335
+
336
+ class Deplate::Regions::DefRegionN < Deplate::Define
337
+ @@regions["DefRegionN"] = self
338
+ @@regions["DefineRegionN"] = self
339
+ @@regions["Defrn"] = self
340
+ def define
341
+ id = @args["id"] || @regNote
342
+ if valid_id?(id)
343
+ eval %{
344
+ class Deplate::DefRegions::#{id} < Deplate::Regions::Native
345
+ @@regions["#{id}"] = self
346
+ def finish
347
+ finish_accum
348
+ @template = #{@accum.join("\n").inspect}
349
+ @mandatory = #{@args["args"].inspect}
350
+ @elt = [ expand_template ]
351
+ return self
352
+ end
353
+ end
354
+ }
355
+ end
356
+ end
357
+ end
358
+
359
+
360
+ class Deplate::Define::CommandNative < Deplate::Command
361
+ def expand_template
362
+ @args["@body"] = @accum.join(" ")
363
+ tmpl = Deplate::Template.new(:master => @deplate,
364
+ :template => @template,
365
+ :source => @source,
366
+ :container => self)
367
+ rv = nil
368
+ Deplate::Define.let_variables(@deplate, @args) do
369
+ rv = tmpl.fill_in(@deplate, :source => @source)
370
+ end
371
+ return rv
372
+ end
373
+
374
+ def format_special
375
+ @elt
376
+ end
377
+ end
378
+
379
+
380
+ class Deplate::Regions::DefCommandN < Deplate::Define
381
+ @@regions["DefCommandN"] = self
382
+ @@regions["DefCmdN"] = self
383
+ @@regions["DefineCommandN"] = self
384
+ @@regions["Defcn"] = self
385
+ def define
386
+ id = @args["id"] || @regNote
387
+ if valid_id?(id)
388
+ eval %{
389
+ class Deplate::DefCommand::#{id} < Deplate::Define::CommandNative
390
+ @@commands["#{id}"] = self
391
+ def finish
392
+ @template = #{@accum.join("\n").inspect}
393
+ @mandatory = #{@args["args"].inspect}
394
+ @elt = [ expand_template ]
395
+ return self
396
+ end
397
+ end
398
+ }
399
+ end
400
+ end
401
+ end
402
+
403
+
404
+ class Deplate::Define::MacroNative < Deplate::Macro
405
+ def setup(text)
406
+ setup_template
407
+ @args["@body"] = text
408
+ tmpl = Deplate::Template.new(:master => @deplate,
409
+ :template => @template,
410
+ :source => @source,
411
+ :container => self)
412
+ Deplate::Define.let_variables(@deplate, @args) do
413
+ @text = tmpl.fill_in(@deplate, :source => @source)
414
+ end
415
+ end
416
+ end
417
+
418
+
419
+ class Deplate::Regions::DefMacroN < Deplate::Define
420
+ @@regions["DefMacroN"] = self
421
+ @@regions["DefineMacroN"] = self
422
+ @@regions["Defmn"] = self
423
+ def define
424
+ id = @args["id"] || @regNote
425
+ if valid_id?(id)
426
+ eval %{
427
+ class Deplate::DefMacro::Define_#{id} < Deplate::Define::MacroNative
428
+ @@macros[#{id.inspect}] = self
429
+ def setup_template
430
+ @template = #{@accum.join(" ").inspect}
431
+ @mandatory = #{@args["args"].inspect}
432
+ end
433
+ end
434
+ }
435
+ # @deplate.initialize_particles(true)
436
+ end
437
+ end
438
+ end
439
+