Class: TipTap::Markdown::Context
- Inherits:
-
Object
- Object
- TipTap::Markdown::Context
- Defined in:
- lib/tip_tap/markdown_renderable.rb
Overview
Rendering context for markdown serialization. Tracks indentation for nested blocks and whether we are currently inside a fenced code block so nodes can adjust formatting.
Instance Attribute Summary collapse
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#within_code_block ⇒ Object
readonly
Returns the value of attribute within_code_block.
Class Method Summary collapse
Instance Method Summary collapse
- #increase_indent(amount) ⇒ Object
- #indentation ⇒ Object
-
#initialize(indent: 0, within_code_block: false) ⇒ Context
constructor
A new instance of Context.
- #with_code_block ⇒ Object
- #within_code_block? ⇒ Boolean
Constructor Details
#initialize(indent: 0, within_code_block: false) ⇒ Context
Returns a new instance of Context.
11 12 13 14 |
# File 'lib/tip_tap/markdown_renderable.rb', line 11 def initialize(indent: 0, within_code_block: false) @indent = indent @within_code_block = within_code_block end |
Instance Attribute Details
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
9 10 11 |
# File 'lib/tip_tap/markdown_renderable.rb', line 9 def indent @indent end |
#within_code_block ⇒ Object (readonly)
Returns the value of attribute within_code_block.
9 10 11 |
# File 'lib/tip_tap/markdown_renderable.rb', line 9 def within_code_block @within_code_block end |
Class Method Details
.root ⇒ Object
16 17 18 |
# File 'lib/tip_tap/markdown_renderable.rb', line 16 def self.root new end |
Instance Method Details
#increase_indent(amount) ⇒ Object
24 25 26 |
# File 'lib/tip_tap/markdown_renderable.rb', line 24 def increase_indent(amount) self.class.new(indent: indent + amount, within_code_block: within_code_block) end |
#indentation ⇒ Object
20 21 22 |
# File 'lib/tip_tap/markdown_renderable.rb', line 20 def indentation " " * indent end |
#with_code_block ⇒ Object
28 29 30 |
# File 'lib/tip_tap/markdown_renderable.rb', line 28 def with_code_block self.class.new(indent: indent, within_code_block: true) end |
#within_code_block? ⇒ Boolean
32 33 34 |
# File 'lib/tip_tap/markdown_renderable.rb', line 32 def within_code_block? within_code_block end |