Class: MaquinaStream::Renderer::PostPass

Inherits:
Object
  • Object
show all
Defined in:
lib/maquina_stream/renderer/post_pass.rb

Overview

One walk over the parsed document. Everything that needs the tree happens here: fence strategies, table wrappers, element hooks, registered custom tags, and the reveal attributes that separate streaming from static.

It is one pass on purpose. Each extra traversal is paid on every frame of every message.

Constant Summary collapse

ELEMENT_HOOKS =
%w[h1 h2 h3 h4 h5 h6 p ul ol li table blockquote pre hr img a].freeze
ELEMENT_HOOK_SET =
ELEMENT_HOOKS.to_set.freeze
DIRECTIONAL =

Elements that hold text of their own, and are therefore the unit the bidi algorithm should decide a direction for. Containers are left out: a

    takes its direction from each
  • , not the other way round.

%w[p h1 h2 h3 h4 h5 h6 li blockquote td th dt dd figcaption summary].to_set.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fragment, markdown:, mode:, config:) ⇒ PostPass

Returns a new instance of PostPass.



22
23
24
25
26
27
# File 'lib/maquina_stream/renderer/post_pass.rb', line 22

def initialize(fragment, markdown:, mode:, config:)
  @fragment = fragment
  @markdown = markdown
  @mode = mode
  @config = config
end

Instance Attribute Details

#config ⇒ Object (readonly)

Returns the value of attribute config.



20
21
22
# File 'lib/maquina_stream/renderer/post_pass.rb', line 20

def config
  @config
end

#fragment ⇒ Object (readonly)

Returns the value of attribute fragment.



20
21
22
# File 'lib/maquina_stream/renderer/post_pass.rb', line 20

def fragment
  @fragment
end

#markdown ⇒ Object (readonly)

Returns the value of attribute markdown.



20
21
22
# File 'lib/maquina_stream/renderer/post_pass.rb', line 20

def markdown
  @markdown
end

#mode ⇒ Object (readonly)

Returns the value of attribute mode.



20
21
22
# File 'lib/maquina_stream/renderer/post_pass.rb', line 20

def mode
  @mode
end

Instance Method Details

#call ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/maquina_stream/renderer/post_pass.rb', line 29

def call
  collect

  rewrite_fences
  wrap_tables
  render_registered_tags
  apply_overrides
  annotate_blocks
  fragment
end