Class: Slamdown::Document

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

Overview

Owns Slamdown's immutable, format-neutral representation of one HTML input.

Constant Summary collapse

ERROR_MODES =
[:raise, :warn, :silent].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, errors: :warn) ⇒ Document

Returns a new instance of Document.



11
12
13
14
# File 'lib/slamdown/document.rb', line 11

def initialize(input, errors: :warn)
	validate_error_mode(errors)
	construct(input, errors)
end

Instance Attribute Details

#diagnosticsObject (readonly)

Returns the value of attribute diagnostics.



9
10
11
# File 'lib/slamdown/document.rb', line 9

def diagnostics
  @diagnostics
end

#treeObject (readonly)

Returns the value of attribute tree.



9
10
11
# File 'lib/slamdown/document.rb', line 9

def tree
  @tree
end

Class Method Details

.convert(input, format:, options: {}, errors: :warn) ⇒ Object

Converts a document or block-level parsed subtree through the selected output pipeline.



18
19
20
# File 'lib/slamdown/document.rb', line 18

def convert(input, format:, options: {}, errors: :warn)
	Conversion::Converter.convert(input, :format => format, :options => options, :errors => errors)
end

Instance Method Details

#to_kramdown(options = {}, controls = {}) ⇒ Object

Returns only the rendered Kramdown string for the common convenience path.



29
30
31
# File 'lib/slamdown/document.rb', line 29

def to_kramdown(options = {}, controls = {})
	convert_convenience(:kramdown, options, controls)
end

#to_markdown(options = {}, controls = {}) ⇒ Object

Returns only the rendered Markdown string for the common convenience path.



24
25
26
# File 'lib/slamdown/document.rb', line 24

def to_markdown(options = {}, controls = {})
	convert_convenience(:markdown, options, controls)
end