wikicloth 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,410 @@
1
+ '''Tables''' may be authored in wiki pages using either XHTML table elements directly, or using wikicode formatting to define the table. XHTML table elements and their use are well described on various web pages and will not be discussed here. The benefit of wikicode is that the table is constructed of character symbols which tend to make it easier to perceive the table structure in the article editing view compared to XHTML table elements.
2
+
3
+ As a general rule, it is best to avoid using a table unless you need one. Table markup often complicates page editing.
4
+
5
+ == Wiki table markup summary ==
6
+ {|cellpadding="5" cellspacing="0" border="1" width="60%"
7
+ |
8
+ <nowiki>{|</nowiki>
9
+ | '''table start'''
10
+ |-
11
+ |
12
+ <nowiki>|+</nowiki>
13
+ | table '''caption,''' ''optional;'' only between '''table start''' and first '''table row'''
14
+ |-
15
+ |
16
+ <nowiki>|-</nowiki>
17
+ | '''table row,''' ''optional on first row'' -- wiki engine assumes the first row
18
+ |-
19
+ |
20
+ <nowiki>!</nowiki>
21
+ | '''table header''' cell, ''optional.'' Consecutive '''table header''' cells may be added on same line separated by double marks (<code>!!</code>) or start on new lines, each with its own single mark (<code>!</code>).
22
+ |-
23
+ |
24
+ <nowiki>|</nowiki>
25
+ | '''table data''' cell, ''required!'' Consecutive '''table data''' cells may be added on same line separated by double marks (<code><nowiki>||</nowiki></code>) or start on new lines, each with its own single mark (<code><nowiki>|</nowiki></code>).
26
+ |-
27
+ |
28
+ <nowiki>|}</nowiki>
29
+ | '''table end'''
30
+ |}
31
+ *The above marks must '''start on a new line''' except the double <code>||</code> and <code>!!</code> for optionally adding consecutive cells to a line. However, blank spaces at the beginning of a line are ignored.
32
+ *'''XHTML attributes.''' Each mark, except table end, optionally accepts one or more XHTML attributes. Attributes must be on the same line as the mark. Separate attributes from each other with a single space.
33
+ **Cells and caption (<code>|</code> or <code>||</code>, <code>!</code> or <code>!!</code>, and <code>|+</code>) hold content. So separate any attributes from content with a single pipe (<code>|</code>). Cell content may follow on same line or on following lines.
34
+ **Table and row marks (<code>{|</code> and <code>|-</code>) do not directly hold content. Do ''not'' add pipe (<code>|</code>) after their optional attributes. If you erroneously add a pipe after attributes for the table mark or row mark the parser will delete it ''and'' your final attribute if it was touching the erroneous pipe!
35
+ *'''Content''' may (a) follow its cell mark on the same line after any optional XHTML attributes or (b) on lines below the cell mark. Content that uses wiki markup that itself needs to start on a new line, such as lists, headings, or nested tables, must be on its own new line.
36
+
37
+ ==Basics==
38
+ The following table lacks borders and good spacing but shows the simplest wiki markup table structure.
39
+
40
+ {| cellspacing="0" border="1"
41
+ !style="width:50%"|You type
42
+ !style="width:50%"|You get
43
+ |-
44
+ |
45
+ <pre>
46
+ {|
47
+ |Orange
48
+ |Apple
49
+ |-
50
+ |Bread
51
+ |Pie
52
+ |-
53
+ |Butter
54
+ |Ice cream
55
+ |}
56
+ </pre>
57
+ |
58
+ {|
59
+ |Orange
60
+ |Apple
61
+ |-
62
+ |Bread
63
+ |Pie
64
+ |-
65
+ |Butter
66
+ |Ice cream
67
+ |}
68
+ |}
69
+
70
+ The cells in the same row can be listed on one line separated by <code>||</code>.
71
+
72
+ Extra spaces within cells in the wiki markup, as in the wiki markup below, do not affect the actual table rendering.
73
+
74
+ {| cellspacing="0" border="1"
75
+ !style="width:50%"|You type
76
+ !style="width:50%"|You get
77
+ |-
78
+ |
79
+ <pre>
80
+ {|
81
+ | Orange || Apple || more
82
+ |-
83
+ | Bread || Pie || more
84
+ |-
85
+ | Butter || Ice cream || and more
86
+ |}
87
+ </pre>
88
+ |
89
+ {|
90
+ | Orange || Apple || more
91
+ |-
92
+ | Bread || Pie || more
93
+ |-
94
+ | Butter || Ice cream || and more
95
+ |}
96
+ |}
97
+
98
+ === Table headers ===
99
+ Table headers can be created by using "<code>!</code>" instead of "<code>|</code>". Headers usually show up bold and centered by default.
100
+
101
+ {| cellspacing="0" border="1"
102
+ !style="width:50%"|You type
103
+ !style="width:50%"|You get
104
+ |-
105
+ |
106
+ <pre>
107
+ {|
108
+ ! Item
109
+ ! Amount
110
+ ! Cost
111
+ |-
112
+ |Orange
113
+ |10
114
+ |7.00
115
+ |-
116
+ |Bread
117
+ |4
118
+ |3.00
119
+ |-
120
+ |Butter
121
+ |1
122
+ |5.00
123
+ |-
124
+ !Total
125
+ |
126
+ |15.00
127
+ |}
128
+ </pre>
129
+ |
130
+ {|
131
+ ! Item
132
+ ! Amount
133
+ ! Cost
134
+ |-
135
+ |Orange
136
+ |10
137
+ |7.00
138
+ |-
139
+ |Bread
140
+ |4
141
+ |3.00
142
+ |-
143
+ |Butter
144
+ |1
145
+ |5.00
146
+ |-
147
+ !Total
148
+ |
149
+ |15.00
150
+ |}
151
+ |}
152
+
153
+ ===Caption===
154
+ A '''table caption''' can be added to the top of any table as follows.
155
+
156
+ {| cellspacing="0" border="1"
157
+ !style="width:50%"|You type
158
+ !style="width:50%"|You get
159
+ |-
160
+ |
161
+ <pre>
162
+ {|
163
+ |+Food complements
164
+ |-
165
+ |Orange
166
+ |Apple
167
+ |-
168
+ |Bread
169
+ |Pie
170
+ |-
171
+ |Butter
172
+ |Ice cream
173
+ |}
174
+ </pre>
175
+ |
176
+ {|
177
+ |+ Food complements
178
+ |-
179
+ |Orange
180
+ |Apple
181
+ |-
182
+ |Bread
183
+ |Pie
184
+ |-
185
+ |Butter
186
+ |Ice cream
187
+ |}
188
+ |}
189
+
190
+ == XHTML attributes ==
191
+ You can add XHTML attributes to tables. For the authoriative source on these, see [http://www.w3.org/TR/REC-html40/struct/tables.html the W3C's HTML 4.01 Specification page on tables].
192
+
193
+ === Attributes on tables ===
194
+ Placing attributes after the table start tag (<code>{|</code>) applies attributes to the entire table.
195
+
196
+ {| cellspacing="0" border="1"
197
+ !style="width:50%"|You type
198
+ !style="width:50%"|You get
199
+ |-
200
+ |
201
+ <pre>
202
+ {| border="1"
203
+ |Orange
204
+ |Apple
205
+ |12,333.00
206
+ |-
207
+ |Bread
208
+ |Pie
209
+ |500.00
210
+ |-
211
+ |Butter
212
+ |Ice cream
213
+ |1.00
214
+ |}
215
+ </pre>
216
+ |
217
+ {| border="1"
218
+ |Orange
219
+ |Apple
220
+ |12,333.00
221
+ |-
222
+ |Bread
223
+ |Pie
224
+ |500.00
225
+ |-
226
+ |Butter
227
+ |Ice cream
228
+ |1.00
229
+ |}
230
+ |}
231
+
232
+ === Attributes on cells ===
233
+ You can put attributes on individual '''cells'''. For example, numbers may look better aligned right.
234
+
235
+ {| cellspacing="0" border="1"
236
+ !style="width:50%"|You type
237
+ !style="width:50%"|You get
238
+ |-
239
+ |
240
+ <pre>
241
+ {| border="1"
242
+ |Orange
243
+ |Apple
244
+ |align="right" | 12,333.00
245
+ |-
246
+ |Bread
247
+ |Pie
248
+ |align="right" | 500.00
249
+ |-
250
+ |Butter
251
+ |Ice cream
252
+ |align="right" | 1.00
253
+ |}
254
+ </pre>
255
+ |
256
+ {| border="1"
257
+ |Orange
258
+ |Apple
259
+ |align="right"|12,333.00
260
+ |-
261
+ |Bread
262
+ |Pie
263
+ |align="right"|500.00
264
+ |-
265
+ |Butter
266
+ |Ice cream
267
+ |align="right"|1.00
268
+ |}
269
+ |}
270
+
271
+ You can also use '''cell''' attributes when you are listing multiple '''cells''' on a single line. Note that the '''cells''' are separated by <code>||</code>, and within each '''cell''' the attribute(s) and value are separated by <code>|</code>.
272
+
273
+ {| cellspacing="0" border="1"
274
+ !style="width:50%"|You type
275
+ !style="width:50%"|You get
276
+ |-
277
+ |
278
+ <pre>
279
+ {| border="1"
280
+ | Orange || Apple || align="right" | 12,333.00
281
+ |-
282
+ | Bread || Pie || align="right" | 500.00
283
+ |-
284
+ | Butter || Ice cream || align="right" | 1.00
285
+ |}
286
+ </pre>
287
+ |
288
+ {| border="1"
289
+ | Orange || Apple || align="right" | 12,333.00
290
+ |-
291
+ | Bread || Pie || align="right" | 500.00
292
+ |-
293
+ | Butter || Ice cream || align="right" | 1.00
294
+ |}
295
+ |}
296
+
297
+ ===Attributes on rows===
298
+ You can put attributes on individual '''rows''', too.
299
+
300
+ {| cellspacing="0" border="1"
301
+ !style="width:50%"|You type
302
+ !style="width:50%"|You get
303
+ |-
304
+ |
305
+ <pre>
306
+ {| border="1"
307
+ |Orange
308
+ |Apple
309
+ |align="right"|12,333.00
310
+ |-
311
+ |Bread
312
+ |Pie
313
+ |align="right"|500.00
314
+ |- style="font-style:italic; color:green;"
315
+ |Butter
316
+ |Ice cream
317
+ |align="right"|1.00
318
+ |}
319
+ </pre>
320
+ |
321
+ {| border="1"
322
+ |Orange
323
+ |Apple
324
+ |align="right"|12,333.00
325
+ |-
326
+ |Bread
327
+ |Pie
328
+ |align="right"|500.00
329
+ |- style="font-style:italic; color:green;"
330
+ |Butter
331
+ |Ice cream
332
+ |align="right"|1.00
333
+ |}
334
+ |}
335
+
336
+ ===With HTML attributes and CSS styles===
337
+ CSS style attributes can be added with or without other HTML attributes.
338
+
339
+ {| cellspacing="0" border="1"
340
+ !style="width:50%"|You type
341
+ !style="width:50%"|You get
342
+ |-
343
+ |
344
+ <pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word; word-break:break-all;">
345
+ {| style="color:green; background-color:#ffffcc;" cellpadding="20" cellspacing="0" border="1"
346
+ |Orange
347
+ |Apple
348
+ |-
349
+ |Bread
350
+ |Pie
351
+ |-
352
+ |Butter
353
+ |Ice cream
354
+ |}
355
+ </pre>
356
+ |
357
+ {| style="color:green; background-color:#ffffcc;" cellpadding="20" cellspacing="0" border="1"
358
+ |Orange
359
+ |Apple
360
+ |-
361
+ |Bread
362
+ |Pie
363
+ |-
364
+ |Butter
365
+ |Ice cream
366
+ |}
367
+ |}
368
+
369
+ '''Attributes''' can be added to the caption and headers as follows.
370
+
371
+ {| cellspacing="0" border="1"
372
+ !style="width:50%"|You type
373
+ !style="width:50%"|You get
374
+ |-
375
+ |
376
+ <pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word; word-break:break-all;">
377
+ {| border="1" cellpadding="20" cellspacing="0"
378
+ |+ align="bottom" style="color:#e76700;" |''Food complements''
379
+ |-
380
+ |Orange
381
+ |Apple
382
+ |-
383
+ |Bread
384
+ |Pie
385
+ |-
386
+ |Butter
387
+ |Ice cream
388
+ |}
389
+ </pre>
390
+ |
391
+ {| border="1" cellpadding="20" cellspacing="0"
392
+ |+ align="bottom" style="color:#e76700;" |''Food complements''
393
+ |-
394
+ |Orange
395
+ |Apple
396
+ |-
397
+ |Bread
398
+ |Pie
399
+ |-
400
+ |Butter
401
+ |Ice cream
402
+ |}
403
+ |}
404
+
405
+ ==Caveats==
406
+ ===Negative numbers===
407
+ If you start a cell on a new line with a negative number with a minus sign (or a parameter that evaluates to a negative number), your table can get broken, because the characters <code>|-</code> will be parsed as the wiki markup for table row, not table cell. To avoid this, insert a space before the value (<code>| -6</code>) or use in-line cell markup (<code>|| -6</code>).
408
+ ===CSS vs Attributes===
409
+ Table borders specified through CSS rather then the border attribute will render incorrectly in a small subset of text browsers.
410
+
File without changes
@@ -0,0 +1,3 @@
1
+ equire 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class WikiClothTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
data/wikicloth.gemspec ADDED
@@ -0,0 +1,69 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ files = %W{
4
+ MIT-LICENSE
5
+ Rakefile
6
+ run_tests.rb
7
+ wikicloth.gemspec
8
+ README
9
+ test/wiki_cloth_test.rb
10
+ test/test_helper.rb
11
+ init.rb
12
+ lib
13
+ lib/wiki_buffer
14
+ lib/wiki_buffer/html_element.rb
15
+ lib/wiki_buffer/var.rb
16
+ lib/wiki_buffer/link.rb
17
+ lib/wiki_buffer/table.rb
18
+ lib/core_ext.rb
19
+ lib/wiki_cloth.rb
20
+ lib/wikicloth.rb
21
+ lib/wiki_buffer.rb
22
+ lib/wiki_link_handler.rb
23
+ tasks/wikicloth_tasks.rake
24
+ sample_documents
25
+ sample_documents/wiki_tables.wiki
26
+ sample_documents/tv.wiki
27
+ sample_documents/elements.wiki
28
+ sample_documents/air_force_one.wiki
29
+ sample_documents/cheatsheet.wiki
30
+ sample_documents/default.css
31
+ sample_documents/george_washington.wiki
32
+ sample_documents/wiki.png
33
+ sample_documents/random.wiki
34
+ sample_documents/pipe_trick.wiki
35
+ sample_documents/lists.wiki
36
+ sample_documents/images.wiki
37
+ }
38
+
39
+ test_files = %W{
40
+ run_tests.rb
41
+ test/test_helper.rb
42
+ test/wiki_cloth_test.rb
43
+ }
44
+
45
+ Gem::Specification.new do |s|
46
+ s.name = %q{wikicloth}
47
+ s.version = '0.1.3'
48
+
49
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
50
+ s.authors = ["nricciar"]
51
+ s.email = "nricciar@gmail.com"
52
+ s.date = %q{2009-07-16}
53
+ s.description = %q{mediawiki parser}
54
+ s.extra_rdoc_files = %W{README MIT-LICENSE}
55
+ s.files = files
56
+ s.has_rdoc = true
57
+ s.homepage = %q{http://github.com/nricciar/wikicloth}
58
+ s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
59
+ s.require_paths = ["lib"]
60
+ s.rubyforge_project = %q{wikicloth}
61
+ s.rubygems_version = %q{1.3.0}
62
+ s.summary = %q{An implementation of the mediawiki markup in ruby}
63
+ s.test_files = test_files
64
+
65
+ if s.respond_to? :specification_version then
66
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
+ s.specification_version = 2
68
+ end
69
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wikicloth
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
+ platform: ruby
12
+ authors:
13
+ - nricciar
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2009-07-16 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: mediawiki parser
23
+ email: nricciar@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ - MIT-LICENSE
31
+ files:
32
+ - MIT-LICENSE
33
+ - Rakefile
34
+ - run_tests.rb
35
+ - wikicloth.gemspec
36
+ - README
37
+ - test/wiki_cloth_test.rb
38
+ - test/test_helper.rb
39
+ - init.rb
40
+ - lib/wiki_buffer/html_element.rb
41
+ - lib/wiki_buffer/var.rb
42
+ - lib/wiki_buffer/link.rb
43
+ - lib/wiki_buffer/table.rb
44
+ - lib/core_ext.rb
45
+ - lib/wiki_cloth.rb
46
+ - lib/wikicloth.rb
47
+ - lib/wiki_buffer.rb
48
+ - lib/wiki_link_handler.rb
49
+ - tasks/wikicloth_tasks.rake
50
+ - sample_documents/wiki_tables.wiki
51
+ - sample_documents/tv.wiki
52
+ - sample_documents/elements.wiki
53
+ - sample_documents/air_force_one.wiki
54
+ - sample_documents/cheatsheet.wiki
55
+ - sample_documents/default.css
56
+ - sample_documents/george_washington.wiki
57
+ - sample_documents/wiki.png
58
+ - sample_documents/random.wiki
59
+ - sample_documents/pipe_trick.wiki
60
+ - sample_documents/lists.wiki
61
+ - sample_documents/images.wiki
62
+ has_rdoc: true
63
+ homepage: http://github.com/nricciar/wikicloth
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options:
68
+ - --inline-source
69
+ - --charset=UTF-8
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 3
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ requirements: []
91
+
92
+ rubyforge_project: wikicloth
93
+ rubygems_version: 1.3.7
94
+ signing_key:
95
+ specification_version: 2
96
+ summary: An implementation of the mediawiki markup in ruby
97
+ test_files:
98
+ - run_tests.rb
99
+ - test/test_helper.rb
100
+ - test/wiki_cloth_test.rb