Class: Markbridge::Parsers::HTML::Handlers::SpanHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/markbridge/parsers/html/handlers/span_handler.rb

Overview

Maps recognized inline ‘style` declarations on `<span>` to AST formatting nodes. Supports text-decoration (underline, line-through), font-weight (bold), and font-style (italic). When multiple recognized styles are set, AST elements are nested in declaration order. Unrecognized styles are ignored; a span with no recognized styles is transparent (children processed into the parent).

Constant Summary collapse

STYLE_DECLARATION =
/([a-z-]+)\s*:\s*([^;]+)/i
BOLD_THRESHOLD =
600

Instance Attribute Summary

Attributes inherited from BaseHandler

#element_class

Instance Method Summary collapse

Instance Method Details

#process(element:, parent:) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/markbridge/parsers/html/handlers/span_handler.rb', line 18

def process(element:, parent:)
  ast_classes_for(element["style"]).reduce(parent) do |current, klass|
    child = klass.new
    current << child
    child
  end
end