Class: Markbridge::Parsers::TextFormatter::Handlers::QuoteHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Markbridge::Parsers::TextFormatter::Handlers::QuoteHandler
- Defined in:
- lib/markbridge/parsers/text_formatter/handlers/quote_handler.rb
Overview
Handler for QUOTE elements in s9e/TextFormatter XML
Maps phpBB-style attribution attributes: post_id and
user_id are database ids and land in AST::Quote#post_id /
AST::Quote#user_id — deliberately not in
AST::Quote#post_number, which carries Discourse post-number
semantics that s9e exports don't provide.
A bare topic attribute feeds AST::Quote#topic_id (a topic
reference is an id in every dialect we know). A bare post
attribute is deliberately NOT mapped: without knowing the
exporting platform it is undecidable whether it holds a post
id or a post number, and guessing wrong produces attributions
that link the wrong post. Register a custom handler when your
export carries one and you know its semantics.
Instance Attribute Summary collapse
-
#element_class ⇒ Object
readonly
Returns the value of attribute element_class.
Instance Method Summary collapse
-
#initialize ⇒ QuoteHandler
constructor
A new instance of QuoteHandler.
- #process(element:, parent:, processor: nil) ⇒ Object
Constructor Details
#initialize ⇒ QuoteHandler
Returns a new instance of QuoteHandler.
23 24 25 |
# File 'lib/markbridge/parsers/text_formatter/handlers/quote_handler.rb', line 23 def initialize @element_class = AST::Quote end |
Instance Attribute Details
#element_class ⇒ Object (readonly)
Returns the value of attribute element_class.
43 44 45 |
# File 'lib/markbridge/parsers/text_formatter/handlers/quote_handler.rb', line 43 def element_class @element_class end |
Instance Method Details
#process(element:, parent:, processor: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/markbridge/parsers/text_formatter/handlers/quote_handler.rb', line 27 def process(element:, parent:, processor: nil) attrs = extract_attributes(element) node = AST::Quote.new( author: attrs[:author], post_id: integer_or_nil(attrs[:post_id]), topic_id: integer_or_nil(attrs[:topic_id] || attrs[:topic]), username: attrs[:username], user_id: integer_or_nil(attrs[:user_id]), ) parent << node # Return node to signal: process children into this node node end |