Class: Charming::Markdown::RenderContext

Inherits:
Data
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url

Returns:

  • (Object)

    the current value of base_url



6
7
8
# File 'lib/charming/presentation/markdown/render_context.rb', line 6

def base_url
  @base_url
end

#current_styleObject (readonly)

Returns the value of attribute current_style

Returns:

  • (Object)

    the current value of current_style



6
7
8
# File 'lib/charming/presentation/markdown/render_context.rb', line 6

def current_style
  @current_style
end

#list_depthObject (readonly)

Returns the value of attribute list_depth

Returns:

  • (Object)

    the current value of list_depth



6
7
8
# File 'lib/charming/presentation/markdown/render_context.rb', line 6

def list_depth
  @list_depth
end

#source_linesObject (readonly)

Returns the value of attribute source_lines

Returns:

  • (Object)

    the current value of source_lines



6
7
8
# File 'lib/charming/presentation/markdown/render_context.rb', line 6

def source_lines
  @source_lines
end

#styleObject (readonly)

Returns the value of attribute style

Returns:

  • (Object)

    the current value of style



6
7
8
# File 'lib/charming/presentation/markdown/render_context.rb', line 6

def style
  @style
end

#widthObject (readonly)

Returns the value of attribute width

Returns:

  • (Object)

    the current value of 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