Module: Markbridge::Normalizer::TextProjection
- Defined in:
- lib/markbridge/normalizer/text_projection.rb
Overview
Best-effort plain-text projection of a subtree, used by the
:textify strategy. Concatenates text content; renders a AST::Mention
as its literal @name, and opaque leaf nodes as their alt/raw text
when they carry one, otherwise the empty string.
Class Method Summary collapse
Class Method Details
.call(node) ⇒ String
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/markbridge/normalizer/text_projection.rb', line 13 def call(node) case node when AST::Text, AST::MarkdownText node.text when AST::Mention "@#{node.name}" when AST::Element node.children.map { |child| call(child) }.join else leaf_text(node) end end |
.leaf_text(node) ⇒ String
28 29 30 31 32 33 |
# File 'lib/markbridge/normalizer/text_projection.rb', line 28 def leaf_text(node) return node.alt if node.respond_to?(:alt) && node.alt return node.raw if node.respond_to?(:raw) && node.raw "" end |