omf_web 0.9.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +31 -0
  3. data/bin/omf_web_server.rb +157 -0
  4. data/doc/screenshot2.png +0 -0
  5. data/doc/widget_detail.png +0 -0
  6. data/example/demo/data_sources/downloads.rb +2 -1
  7. data/example/simple/README.md +12 -13
  8. data/example/simple/create_waveform.rb +29 -0
  9. data/example/simple/introduction.md +17 -0
  10. data/example/simple/sample.sq3 +0 -0
  11. data/example/simple/sample.sql +1008 -0
  12. data/example/simple/simple.yaml +62 -0
  13. data/example/simple/simple_dynamic.yaml +66 -0
  14. data/lib/irods4r/file.rb +15 -14
  15. data/lib/irods4r/icommands.rb +18 -18
  16. data/lib/irods4r.rb +9 -9
  17. data/lib/omf-web/config.ru +41 -16
  18. data/lib/omf-web/content/git_repository.rb +32 -31
  19. data/lib/omf-web/content/irods_repository.rb +34 -33
  20. data/lib/omf-web/content/repository.rb +48 -44
  21. data/lib/omf-web/data_source_proxy.rb +33 -22
  22. data/lib/omf-web/rack/session_authenticator.rb +48 -12
  23. data/lib/omf-web/rack/tab_mapper.rb +30 -36
  24. data/lib/omf-web/rack/websocket_handler.rb +26 -25
  25. data/lib/omf-web/session_store.rb +16 -13
  26. data/lib/omf-web/theme/abstract_page.rb +26 -22
  27. data/lib/omf-web/theme/bright/page.rb +84 -34
  28. data/lib/omf-web/theme/bright/stacked_renderer.rb +20 -19
  29. data/lib/omf-web/theme.rb +14 -9
  30. data/lib/omf-web/thin/runner.rb +38 -36
  31. data/lib/omf-web/thin/server.rb +255 -0
  32. data/lib/omf-web/version.rb +1 -1
  33. data/lib/omf-web/widget/data_widget.rb +6 -6
  34. data/lib/omf-web/widget/text/maruku/helpers.rb +33 -30
  35. data/lib/omf-web/widget/text/maruku/input/parse_block.rb +117 -117
  36. data/lib/omf-web/widget/text/maruku/output/to_html.rb +155 -154
  37. data/lib/omf-web/widget/text/maruku.rb +17 -16
  38. data/omf_web.gemspec +6 -2
  39. data/sample.sq3 +0 -0
  40. data/share/htdocs/graph/js/gauge.js +524 -0
  41. data/share/htdocs/vendor/VERSION_MAP.yaml +3 -3
  42. data/share/htdocs/vendor/backbone-1.0.0/backbone.js +1571 -0
  43. data/share/htdocs/vendor/d3-3.0/LICENSE.brewer.txt +38 -0
  44. data/share/htdocs/vendor/d3-3.0/colorbrewer.js +1 -0
  45. data/share/htdocs/vendor/d3-3.0/d3.js +8810 -0
  46. data/share/htdocs/vendor/d3-3.0/d3.min.js +5 -0
  47. data/share/htdocs/vendor/geo_json/Readme.txt +71 -0
  48. data/share/htdocs/vendor/geo_json/regions.json +41 -0
  49. data/share/htdocs/vendor/geo_json/switzerland.json +24 -0
  50. data/share/htdocs/vendor/geo_json/world.json +497 -0
  51. data/share/htdocs/vendor/nv_d3/js/nv.d3.js +8801 -4447
  52. data/share/htdocs/vendor/spin/jquery.spin.js +46 -0
  53. data/share/htdocs/vendor/spin/spin.js +349 -0
  54. data/share/htdocs/vendor/spin/spin.min.js +1 -0
  55. data/share/htdocs/vendor/underscore-1.4.4/underscore.js +1227 -0
  56. metadata +63 -48
  57. data/example/simple/data_sources/gimi31.sq3 +0 -0
  58. data/example/simple/data_sources/ping_source.rb +0 -56
  59. data/example/simple/simple_viz_server.rb +0 -39
  60. data/example/simple/widgets/charts_tab.yaml +0 -38
  61. data/share/.DS_Store +0 -0
  62. data/share/htdocs/.DS_Store +0 -0
  63. data/share/htdocs/vendor/backbone-0.5.3/backbone.js +0 -1158
  64. data/share/htdocs/vendor/underscore-1.2.1/underscore.js +0 -958
@@ -2,17 +2,17 @@
2
2
  # Copyright (C) 2006 Andrea Censi <andrea (at) rubyforge.org>
3
3
  #
4
4
  # This file is part of Maruku.
5
- #
5
+ #
6
6
  # Maruku is free software; you can redistribute it and/or modify
7
7
  # it under the terms of the GNU General Public License as published by
8
8
  # the Free Software Foundation; either version 2 of the License, or
9
9
  # (at your option) any later version.
10
- #
10
+ #
11
11
  # Maruku is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU General Public License for more details.
15
- #
15
+ #
16
16
  # You should have received a copy of the GNU General Public License
17
17
  # along with Maruku; if not, write to the Free Software
18
18
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -33,32 +33,32 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
33
33
  desc.map{|x| "\n -" + x.inspect}.join
34
34
  end
35
35
  end
36
-
36
+
37
37
  # Splits the string and calls parse_lines_as_markdown
38
38
  def parse_text_as_markdown(text)
39
39
  lines = split_lines(text)
40
40
  src = LineSource.new(lines)
41
41
  return parse_blocks(src)
42
42
  end
43
-
43
+
44
44
  # Input is a LineSource
45
45
  def parse_blocks(src)
46
46
  output = BlockContext.new
47
-
47
+
48
48
  # run state machine
49
49
  while src.cur_line
50
-
50
+
51
51
  next if check_block_extensions(src, output, src.cur_line)
52
-
52
+
53
53
  # Prints detected type (useful for debugging)
54
54
  # puts "#{src.cur_line.md_type}|#{src.cur_line}"
55
55
  case src.cur_line.md_type
56
- when :empty;
56
+ when :empty;
57
57
  output.push :empty
58
58
  src.ignore_line
59
59
  when :ial
60
60
  m = InlineAttributeList.match src.shift_line
61
- content = m[1] || ""
61
+ content = m[1] || ""
62
62
  # puts "Content: #{content.inspect}"
63
63
  src2 = CharSource.new(content, src)
64
64
  interpret_extension(src2, output, [nil])
@@ -77,7 +77,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
77
77
  list_type = src.cur_line.md_type == :ulist ? :ul : :ol
78
78
  li = read_list_item(src)
79
79
  # append to current list if we have one
80
- if output.last.kind_of?(MDElement) &&
80
+ if output.last.kind_of?(MDElement) &&
81
81
  output.last.node_type == list_type then
82
82
  output.last.children << li
83
83
  else
@@ -88,7 +88,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
88
88
  when :raw_html; e = read_raw_html(src); output << e if e
89
89
 
90
90
  when :footnote_text; output.push read_footnote_text(src)
91
- when :ref_definition;
91
+ when :ref_definition
92
92
  if src.parent && (src.cur_index == 0)
93
93
  read_text_material(src, output)
94
94
  else
@@ -96,7 +96,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
96
96
  end
97
97
  when :abbreviation; output.push read_abbreviation(src)
98
98
  when :xml_instr; read_xml_instruction(src, output)
99
- when :metadata;
99
+ when :metadata;
100
100
  maruku_error "Please use the new meta-data syntax: \n"+
101
101
  " http://maruku.rubyforge.org/proposal.html\n", src
102
102
  src.ignore_line
@@ -111,44 +111,44 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
111
111
  merge_ial(output, src, output)
112
112
  output.delete_if {|x| x.kind_of?(MDElement) &&
113
113
  x.node_type == :ial}
114
-
114
+
115
115
  # get rid of empty line markers
116
116
  output.delete_if {|x| x == :empty}
117
117
  # See for each list if we can omit the paragraphs and use li_span
118
118
  # TODO: do this after
119
- output.each do |c|
119
+ output.each do |c|
120
120
  # Remove paragraphs that we can get rid of
121
- if [:ul,:ol].include? c.node_type
121
+ if [:ul,:ol].include? c.node_type
122
122
  if c.children.all? {|li| !li.want_my_paragraph} then
123
123
  c.children.each do |d|
124
124
  d.node_type = :li_span
125
- d.children = d.children[0].children
125
+ d.children = d.children[0].children
126
126
  end
127
127
  end
128
- end
128
+ end
129
129
  if c.node_type == :definition_list
130
130
  if c.children.all?{|defi| !defi.want_my_paragraph} then
131
- c.children.each do |definition|
131
+ c.children.each do |definition|
132
132
  definition.definitions.each do |dd|
133
- dd.children = dd.children[0].children
133
+ dd.children = dd.children[0].children
134
134
  end
135
135
  end
136
136
  end
137
- end
137
+ end
138
138
  end
139
-
139
+
140
140
  output
141
141
  end
142
-
142
+
143
143
  def read_text_material(src, output)
144
- if src.cur_line =~ MightBeTableHeader and
144
+ if src.cur_line =~ MightBeTableHeader and
145
145
  (src.next_line && src.next_line =~ TableSeparator)
146
146
  output.push read_table(src)
147
147
  elsif [:header1,:header2].include? src.next_line.md_type
148
148
  output.push read_header12(src)
149
149
  elsif eventually_comes_a_def_list(src)
150
150
  definition = read_definition(src)
151
- if output.last.kind_of?(MDElement) &&
151
+ if output.last.kind_of?(MDElement) &&
152
152
  output.last.node_type == :definition_list then
153
153
  output.last.children << definition
154
154
  else
@@ -158,8 +158,8 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
158
158
  output.push read_paragraph(src)
159
159
  end
160
160
  end
161
-
162
-
161
+
162
+
163
163
  def read_ald(src)
164
164
  if (l=src.shift_line) =~ AttributeDefinitionList
165
165
  id = $1; al=$2;
@@ -171,7 +171,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
171
171
  return nil
172
172
  end
173
173
  end
174
-
174
+
175
175
  # reads a header (with ----- or ========)
176
176
  def read_header12(src)
177
177
  line = src.shift_line.strip
@@ -183,12 +183,12 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
183
183
  al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil])
184
184
  end
185
185
  text = parse_lines_as_span [ line ]
186
- level = src.cur_line.md_type == :header2 ? 2 : 1;
186
+ level = src.cur_line.md_type == :header2 ? 2 : 1;
187
187
  src.shift_line
188
188
  return md_header(level, text, al, src.cur_index)
189
189
  end
190
190
 
191
- # reads a header like '#### header ####'
191
+ # reads a header like '#### header ####'
192
192
  def read_header3(src)
193
193
  # puts "READ_H3: #{src.inspect}"
194
194
  line = src.shift_line.strip
@@ -200,7 +200,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
200
200
  al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil])
201
201
  end
202
202
  level = num_leading_hashes(line)
203
- text = parse_lines_as_span [strip_hashes(line)]
203
+ text = parse_lines_as_span [strip_hashes(line)]
204
204
  return md_header(level, text, al, src.cur_index)
205
205
  end
206
206
 
@@ -218,9 +218,9 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
218
218
  add_tabs(code, 1, '|'), src
219
219
  end
220
220
  code.gsub!(/\?>\s*$/, '')
221
-
221
+
222
222
  if target == 'mrk' && MaRuKu::Globals[:unsafe_features]
223
- result = safe_execute_code(self, code)
223
+ result = safe_execute_code(self, code)
224
224
  if result
225
225
  if result.kind_of? String
226
226
  raise "Not expected"
@@ -232,13 +232,13 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
232
232
  output.push md_xml_instr(target, code)
233
233
  end
234
234
  end
235
-
235
+
236
236
  def read_raw_html(src)
237
237
  h = HTMLHelper.new
238
- begin
238
+ begin
239
239
  h.eat_this(l=src.shift_line)
240
240
  # puts "\nBLOCK:\nhtml -> #{l.inspect}"
241
- while src.cur_line and not h.is_finished?
241
+ while src.cur_line and not h.is_finished?
242
242
  l=src.shift_line
243
243
  # puts "html -> #{l.inspect}"
244
244
  h.eat_this "\n"+l
@@ -252,13 +252,13 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
252
252
  "I see that #{h.rest.inspect} is left after the raw HTML.", src
253
253
  end
254
254
  raw_html = h.stuff_you_read
255
-
255
+
256
256
  return md_html(raw_html)
257
257
  end
258
-
258
+
259
259
  def read_paragraph(src)
260
260
  lines = [src.shift_line]
261
- while src.cur_line
261
+ while src.cur_line
262
262
  # :olist does not break
263
263
  case t = src.cur_line.md_type
264
264
  when :quote,:header3,:empty,:ref_definition,:ial #,:xml_instr,:raw_html
@@ -266,10 +266,10 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
266
266
  when :olist,:ulist
267
267
  break if src.next_line.md_type == t
268
268
  end
269
- break if src.cur_line.strip.size == 0
269
+ break if src.cur_line.strip.size == 0
270
270
  break if [:header1,:header2].include? src.next_line.md_type
271
- break if any_matching_block_extension?(src.cur_line)
272
-
271
+ break if any_matching_block_extension?(src.cur_line)
272
+
273
273
  lines << src.shift_line
274
274
  end
275
275
  # dbg_describe_ary(lines, 'PAR')
@@ -277,11 +277,11 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
277
277
 
278
278
  return md_par(children, nil, src.cur_index)
279
279
  end
280
-
280
+
281
281
  # Reads one list item, either ordered or unordered.
282
282
  def read_list_item(src)
283
283
  parent_offset = src.cur_index
284
-
284
+
285
285
  item_type = src.cur_line.md_type
286
286
  first = src.shift_line
287
287
 
@@ -289,20 +289,20 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
289
289
  al = read_attribute_list(CharSource.new(ial,src), context=nil, break_on=[nil]) if ial
290
290
  break_list = [:ulist, :olist, :ial]
291
291
  # Ugly things going on inside `read_indented_content`
292
- lines, want_my_paragraph =
292
+ lines, want_my_paragraph =
293
293
  read_indented_content(src,indentation, break_list, item_type)
294
294
 
295
295
  # add first line
296
296
  # Strip first '*', '-', '+' from first line
297
297
  stripped = first[indentation, first.size-1]
298
298
  lines.unshift stripped
299
-
299
+
300
300
  # dbg_describe_ary(lines, 'LIST ITEM ')
301
301
 
302
302
  src2 = LineSource.new(lines, src, parent_offset)
303
303
  children = parse_blocks(src2)
304
304
  with_par = want_my_paragraph || (children.size>1)
305
-
305
+
306
306
  return md_li(children, with_par, al)
307
307
  end
308
308
 
@@ -310,48 +310,48 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
310
310
  if not (l=src.shift_line) =~ Abbreviation
311
311
  maruku_error "Bug: it's Andrea's fault. Tell him.\n#{l.inspect}"
312
312
  end
313
-
313
+
314
314
  abbr = $1
315
315
  desc = $2
316
-
316
+
317
317
  if (not abbr) or (abbr.size==0)
318
318
  maruku_error "Bad abbrev. abbr=#{abbr.inspect} desc=#{desc.inspect}"
319
319
  end
320
-
320
+
321
321
  self.abbreviations[abbr] = desc
322
-
322
+
323
323
  return md_abbr_def(abbr, desc)
324
324
  end
325
-
325
+
326
326
  def read_footnote_text(src)
327
327
  parent_offset = src.cur_index
328
-
328
+
329
329
  first = src.shift_line
330
-
331
- if not first =~ FootnoteText
330
+
331
+ if not first =~ FootnoteText
332
332
  maruku_error "Bug (it's Andrea's fault)"
333
333
  end
334
-
334
+
335
335
  id = $1
336
336
  text = $2
337
337
 
338
338
  # Ugly things going on inside `read_indented_content`
339
339
  indentation = 4 #first.size-text.size
340
-
340
+
341
341
  # puts "id =_#{id}_; text=_#{text}_ indent=#{indentation}"
342
-
342
+
343
343
  break_list = [:footnote_text, :ref_definition, :definition, :abbreviation]
344
344
  item_type = :footnote_text
345
- lines, want_my_paragraph =
345
+ lines, want_my_paragraph =
346
346
  read_indented_content(src,indentation, break_list, item_type)
347
347
 
348
348
  # add first line
349
349
  if text && text.strip != "" then lines.unshift text end
350
-
350
+
351
351
  # dbg_describe_ary(lines, 'FOOTNOTE')
352
352
  src2 = LineSource.new(lines, src, parent_offset)
353
353
  children = parse_blocks(src2)
354
-
354
+
355
355
  e = md_footnote(id, children)
356
356
  self.footnotes[id] = e
357
357
  return e
@@ -364,7 +364,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
364
364
  lines =[]
365
365
  # collect all indented lines
366
366
  saw_empty = false; saw_anything_after = false
367
- while src.cur_line
367
+ while src.cur_line
368
368
  # puts "Reading indent = #{indentation} #{src.cur_line.inspect}"
369
369
  #puts "#{src.cur_line.md_type} #{src.cur_line.inspect}"
370
370
  if src.cur_line.md_type == :empty
@@ -372,7 +372,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
372
372
  lines << src.shift_line
373
373
  next
374
374
  end
375
-
375
+
376
376
  # after a white line
377
377
  if saw_empty
378
378
  # we expect things to be properly aligned
@@ -382,19 +382,19 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
382
382
  end
383
383
  saw_anything_after = true
384
384
  else
385
- # if src.cur_line[0] != ?\
385
+ # if src.cur_line[0] != ?\
386
386
  break if break_list.include? src.cur_line.md_type
387
387
  # end
388
388
  # break if src.cur_line.md_type != :text
389
389
  end
390
-
390
+
391
391
 
392
392
  stripped = strip_indent(src.shift_line, indentation)
393
393
  lines << stripped
394
394
 
395
395
  #puts "Accepted as #{stripped.inspect}"
396
-
397
- # You are only required to indent the first line of
396
+
397
+ # You are only required to indent the first line of
398
398
  # a child paragraph.
399
399
  if stripped.md_type == :text
400
400
  while src.cur_line && (src.cur_line.md_type == :text)
@@ -403,23 +403,23 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
403
403
  end
404
404
  end
405
405
 
406
- want_my_paragraph = saw_anything_after ||
407
- (saw_empty && (src.cur_line && (src.cur_line.md_type == item_type)))
408
-
406
+ want_my_paragraph = saw_anything_after ||
407
+ (saw_empty && (src.cur_line && (src.cur_line.md_type == item_type)))
408
+
409
409
  # dbg_describe_ary(lines, 'LI')
410
- # create a new context
411
-
410
+ # create a new context
411
+
412
412
  while lines.last && (lines.last.md_type == :empty)
413
413
  lines.pop
414
414
  end
415
-
415
+
416
416
  return lines, want_my_paragraph
417
417
  end
418
418
 
419
-
419
+
420
420
  def read_quote(src)
421
421
  parent_offset = src.cur_index
422
-
422
+
423
423
  lines = []
424
424
  # collect all indented lines
425
425
  while src.cur_line && src.cur_line.md_type == :quote
@@ -438,20 +438,20 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
438
438
  while src.cur_line && ([:code, :empty].include? src.cur_line.md_type)
439
439
  lines << strip_indent(src.shift_line, 4)
440
440
  end
441
-
441
+
442
442
  #while lines.last && (lines.last.md_type == :empty )
443
443
  while lines.last && lines.last.strip.size == 0
444
- lines.pop
444
+ lines.pop
445
445
  end
446
446
 
447
447
  while lines.first && lines.first.strip.size == 0
448
- lines.shift
448
+ lines.shift
449
449
  end
450
-
450
+
451
451
  return nil if lines.empty?
452
452
 
453
453
  source = lines.join("\n")
454
-
454
+
455
455
  # dbg_describe_ary(lines, 'CODE')
456
456
 
457
457
  return md_codeblock(source)
@@ -460,7 +460,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
460
460
  # Reads a series of metadata lines with empty lines in between
461
461
  def read_metadata(src)
462
462
  hash = {}
463
- while src.cur_line
463
+ while src.cur_line
464
464
  case src.cur_line.md_type
465
465
  when :empty; src.shift_line
466
466
  when :metadata; hash.merge! parse_metadata(src.shift_line)
@@ -469,33 +469,33 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
469
469
  end
470
470
  hash
471
471
  end
472
-
473
-
474
- def read_ref_definition(src, out)
472
+
473
+
474
+ def read_ref_definition(src, out)
475
475
  line = src.shift_line
476
-
477
-
476
+
477
+
478
478
  # if link is incomplete, shift next line
479
- if src.cur_line && !([:footnote_text, :ref_definition, :definition, :abbreviation].include? src.cur_line.md_type) &&
480
- ([1,2,3].include? number_of_leading_spaces(src.cur_line) )
479
+ if src.cur_line && !([:footnote_text, :ref_definition, :definition, :abbreviation].include? src.cur_line.md_type) &&
480
+ ([1,2,3].include? number_of_leading_spaces(src.cur_line) )
481
481
  line += " "+ src.shift_line
482
482
  end
483
-
483
+
484
484
  # puts "total= #{line}"
485
-
485
+
486
486
  match = LinkRegex.match(line)
487
487
  if not match
488
488
  maruku_error "Link does not respect format: '#{line}'"
489
489
  return
490
490
  end
491
-
492
- id = match[1]; url = match[2]; title = match[3];
491
+
492
+ id = match[1]; url = match[2]; title = match[3];
493
493
  id = sanitize_ref_id(id)
494
-
494
+
495
495
  hash = self.refs[id] = {:url=>url,:title=>title}
496
-
496
+
497
497
  stuff=match[4]
498
-
498
+
499
499
  if stuff
500
500
  stuff.split.each do |couple|
501
501
  # puts "found #{couple}"
@@ -507,10 +507,10 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
507
507
  end
508
508
  end
509
509
  # puts hash.inspect
510
-
510
+
511
511
  out.push md_ref_def(id, url, meta={:title=>title})
512
512
  end
513
-
513
+
514
514
  def split_cells(s)
515
515
  # s.strip.split('|').select{|x|x.strip.size>0}.map{|x|x.strip}
516
516
  # changed to allow empty cells
@@ -519,23 +519,23 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
519
519
 
520
520
  def read_table(src)
521
521
  head = split_cells(src.shift_line).map{|s| md_el(:head_cell, parse_lines_as_span([s])) }
522
-
522
+
523
523
  separator=split_cells(src.shift_line)
524
524
 
525
525
  align = separator.map { |s| s =~ Sep
526
526
  if $1 and $2 then :center elsif $2 then :right else :left end }
527
-
527
+
528
528
  num_columns = align.size
529
-
529
+
530
530
  if head.size != num_columns
531
531
  maruku_error "Table head does not have #{num_columns} columns: \n#{head.inspect}"
532
532
  tell_user "I will ignore this table."
533
533
  # XXX try to recover
534
534
  return md_br()
535
535
  end
536
-
536
+
537
537
  rows = []
538
-
538
+
539
539
  while src.cur_line && src.cur_line =~ /\|/
540
540
  row = split_cells(src.shift_line).map{|s|
541
541
  md_el(:cell, parse_lines_as_span([s]))}
@@ -551,18 +551,18 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
551
551
  children = (head+rows).flatten
552
552
  return md_el(:table, children, {:align => align})
553
553
  end
554
-
554
+
555
555
  # If current line is text, a definition list is coming
556
556
  # if 1) text,empty,[text,empty]*,definition
557
-
557
+
558
558
  def eventually_comes_a_def_list(src)
559
559
  future = src.tell_me_the_future
560
560
  ok = future =~ %r{^t+e?d}x
561
561
  # puts "future: #{future} - #{ok}"
562
562
  ok
563
563
  end
564
-
565
-
564
+
565
+
566
566
  def read_definition(src)
567
567
  # Read one or more terms
568
568
  terms = []
@@ -580,35 +580,35 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
580
580
  want_my_paragraph = true
581
581
  src.shift_line
582
582
  end
583
-
583
+
584
584
  raise "Chunky Bacon!" if src.cur_line.md_type != :definition
585
-
585
+
586
586
  # Read one or more definitions
587
587
  definitions = []
588
588
  while src.cur_line && src.cur_line.md_type == :definition
589
589
  parent_offset = src.cur_index
590
-
590
+
591
591
  first = src.shift_line
592
592
  first =~ Definition
593
593
  first = $1
594
-
594
+
595
595
  # I know, it's ugly!!!
596
596
 
597
- lines, w_m_p =
597
+ lines, w_m_p =
598
598
  read_indented_content(src,4, [:definition], :definition)
599
599
  want_my_paragraph ||= w_m_p
600
-
600
+
601
601
  lines.unshift first
602
-
602
+
603
603
  # dbg_describe_ary(lines, 'DD')
604
604
  src2 = LineSource.new(lines, src, parent_offset)
605
605
  children = parse_blocks(src2)
606
606
  definitions << md_el(:definition_data, children)
607
607
  end
608
-
609
- return md_el(:definition, terms+definitions, {
610
- :terms => terms,
611
- :definitions => definitions,
608
+
609
+ return md_el(:definition, terms+definitions, {
610
+ :terms => terms,
611
+ :definitions => definitions,
612
612
  :want_my_paragraph => want_my_paragraph})
613
613
  end
614
614
  end # BlockLevelParser