Class: Slamdown::Document
- Inherits:
-
Object
- Object
- Slamdown::Document
- 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
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Class Method Summary collapse
-
.convert(input, format:, options: {}, errors: :warn) ⇒ Object
Converts a document or block-level parsed subtree through the selected output pipeline.
Instance Method Summary collapse
-
#initialize(input, errors: :warn) ⇒ Document
constructor
A new instance of Document.
-
#to_kramdown(options = {}, controls = {}) ⇒ Object
Returns only the rendered Kramdown string for the common convenience path.
-
#to_markdown(options = {}, controls = {}) ⇒ Object
Returns only the rendered Markdown string for the common convenience path.
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
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
9 10 11 |
# File 'lib/slamdown/document.rb', line 9 def diagnostics @diagnostics end |
#tree ⇒ Object (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 => , :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( = {}, controls = {}) convert_convenience(:kramdown, , 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( = {}, controls = {}) convert_convenience(:markdown, , controls) end |