Class: Slamdown::Conversion::Normaliser::ElementActions

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

Overview

Recursively applies resolved source-element actions and delegates specialised inline and break corrections to their focused collaborators.

Constant Summary collapse

INTEGER_ATTRIBUTE =
/\A[+-]?\d+\z/.freeze
ORDERED_LIST_START_RANGE =
(2..100_000).freeze
TABLE_SEMANTICS =
{
	"caption" => :table_caption,
	"colgroup" => :table_colgroup,
	"col" => :table_column
}.freeze
SOURCE_SEMANTICS =
{
	"p" => :paragraph,
	"blockquote" => :blockquote,
	"ol" => :ordered_list,
	"ul" => :unordered_list,
	"li" => :list_item,
	"dl" => :definition_list,
	"dt" => :definition_term,
	"dd" => :definition_description,
	"details" => :definition_list,
	"summary" => :definition_term,
	"hr" => :horizontal_rule,
	"br" => :line_break,
	"code" => :code_span,
	"kbd" => :code_span,
	"samp" => :code_span,
	"tt" => :code_span,
	"var" => :code_span,
	"pre" => :code_block,
	"a" => :link,
	"img" => :image,
	"em" => :emphasis,
	"i" => :emphasis,
	"strong" => :strong,
	"b" => :strong,
	"s" => :deletion,
	"strike" => :deletion,
	"del" => :deletion,
	"table" => :table,
	"thead" => :table_head,
	"tbody" => :table_body,
	"tfoot" => :table_foot,
	"tr" => :table_row,
	"td" => :table_cell,
	"th" => :table_cell
}.merge(TABLE_SEMANTICS).freeze

Instance Method Summary collapse

Constructor Details

#initialize(configuration, node_factory, content, breaks, diagnostics) ⇒ ElementActions

Returns a new instance of ElementActions.



53
54
55
56
57
58
59
60
61
62
# File 'lib/slamdown/conversion/normaliser/element_actions.rb', line 53

def initialize(configuration, node_factory, content, breaks, diagnostics)
	@configuration = configuration
	@node_factory = node_factory
	@content = content
	@breaks = breaks
	@diagnostics = diagnostics
	@policy = Policy::Resolver.new(configuration)
	url_rewriter = UrlRewriter.new(configuration.urls)
	@inline_semantics = InlineSemantics.new(@policy, node_factory, content, breaks, url_rewriter, diagnostics)
end

Instance Method Details

#normalise_root(root) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/slamdown/conversion/normaliser/element_actions.rb', line 64

def normalise_root(root)
	if root.kind == :document
		normalise_children(root.children, [], @configuration.inline)
	else
		normalise_node(root, [], @configuration.inline)
	end
end