Class: Charming::Markdown::RenderContext
- Inherits:
-
Data
- Object
- Data
- Charming::Markdown::RenderContext
- Defined in:
- lib/charming/presentation/markdown/render_context.rb
Overview
RenderContext carries render-time state that needs to flow down the Markdown AST.
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#current_style ⇒ Object
readonly
Returns the value of attribute current_style.
-
#list_depth ⇒ Object
readonly
Returns the value of attribute list_depth.
-
#source_lines ⇒ Object
readonly
Returns the value of attribute source_lines.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #inherit(style_name) ⇒ Object
- #nested_list(width: self.width) ⇒ Object
- #with(width: self.width, list_depth: self.list_depth, current_style: self.current_style) ⇒ Object
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url
6 7 8 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 6 def base_url @base_url end |
#current_style ⇒ Object (readonly)
Returns the value of attribute current_style
6 7 8 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 6 def current_style @current_style end |
#list_depth ⇒ Object (readonly)
Returns the value of attribute list_depth
6 7 8 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 6 def list_depth @list_depth end |
#source_lines ⇒ Object (readonly)
Returns the value of attribute source_lines
6 7 8 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 6 def source_lines @source_lines end |
#style ⇒ Object (readonly)
Returns the value of attribute style
6 7 8 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 6 def style @style end |
#width ⇒ Object (readonly)
Returns the value of attribute width
6 7 8 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 6 def width @width end |
Class Method Details
.from(width:, style:, base_url: nil, source_lines: [], list_depth: 0, current_style: nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 7 def self.from(width:, style:, base_url: nil, source_lines: [], list_depth: 0, current_style: nil) new( width: width, list_depth: list_depth, style: style, current_style: current_style || style[:document], base_url: base_url, source_lines: source_lines ) end |
Instance Method Details
#inherit(style_name) ⇒ Object
33 34 35 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 33 def inherit(style_name) current_style.inherit_visual(style[style_name]) end |
#nested_list(width: self.width) ⇒ Object
29 30 31 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 29 def nested_list(width: self.width) with(width: width, list_depth: list_depth + 1) end |
#with(width: self.width, list_depth: self.list_depth, current_style: self.current_style) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/charming/presentation/markdown/render_context.rb', line 18 def with(width: self.width, list_depth: self.list_depth, current_style: self.current_style) self.class.new( width: width, list_depth: list_depth, style: style, current_style: current_style, base_url: base_url, source_lines: source_lines ) end |