Class: Slamdown::Conversion::Tables::Analyser

Inherits:
Object
  • Object
show all
Defined in:
lib/slamdown/conversion/tables.rb

Overview

Reads table groups without rendering or mutating the normalised tree.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.analyse(table) ⇒ Object



425
426
427
# File 'lib/slamdown/conversion/tables.rb', line 425

def analyse(table)
	new.analyse(table)
end

Instance Method Details

#analyse(table) ⇒ Object

Raises:

  • (ArgumentError)


430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/slamdown/conversion/tables.rb', line 430

def analyse(table)
	raise ArgumentError, "table must be a normalised Slamdown table" unless table.is_a?(NormalisedNode) && table.semantic_kind == :table

	@credible_width = credible_table_width(table)
	table = sanitise_table_spans(table)
	@html_required = structural_html_required?(table)
	@captions = []
	@head_rows = []
	@body_groups = []
	@foot_rows = []
	@direct_rows = []
	@dropped_spans = false
	cleaned_children = table.children.each_with_object([]) do |child, children|
		next if ignorable_whitespace?(child)

		cleaned = clean_table_structure(child)
		next unless cleaned

		interpret_child(cleaned)
		children << cleaned
	end
	flush_direct_rows
	caption, cleaned_children, captions_merged = normalise_captions(cleaned_children)

	Analysis.new(table.with(:children => cleaned_children), caption, @head_rows, @body_groups, @foot_rows, @html_required, captions_merged, @dropped_spans)
end