Class: Markdown::Merge::FreezeNode
- Inherits:
-
Ast::Merge::FreezeNodeBase
- Object
- Ast::Merge::FreezeNodeBase
- Markdown::Merge::FreezeNode
- Defined in:
- lib/markdown/merge/freeze_node.rb
Overview
Represents a frozen block of Markdown content that should be preserved during merges.
Freeze blocks are marked with HTML comments:
<!-- markdown-merge:freeze -->
... frozen content ...
<!-- markdown-merge:unfreeze -->
Content within freeze blocks is preserved exactly as-is during merge operations, preventing automated tools from modifying manually-curated sections.
Instance Method Summary collapse
-
#contains_type?(type) ⇒ Boolean
Check if block contains a specific node type.
-
#full_text ⇒ String
Get the full text including markers.
-
#initialize(start_line:, end_line:, content:, start_marker:, end_marker:, nodes: [], reason: nil) ⇒ FreezeNode
constructor
Initialize a new FreezeNode.
-
#inspect ⇒ String
String representation for debugging.
-
#line_count ⇒ Integer
Get line count of the freeze block.
-
#signature ⇒ Array<Symbol, String>
Generate a signature for matching this freeze block.
Constructor Details
#initialize(start_line:, end_line:, content:, start_marker:, end_marker:, nodes: [], reason: nil) ⇒ FreezeNode
Initialize a new FreezeNode
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/markdown/merge/freeze_node.rb', line 39 def initialize(start_line:, end_line:, content:, start_marker:, end_marker:, nodes: [], reason: nil) # Let the base class handle reason extraction via pattern_for super( start_line: start_line, end_line: end_line, content: content, nodes: nodes, start_marker: start_marker, end_marker: end_marker, pattern_type: :html_comment, reason: reason ) end |
Instance Method Details
#contains_type?(type) ⇒ Boolean
Check if block contains a specific node type
81 82 83 |
# File 'lib/markdown/merge/freeze_node.rb', line 81 def contains_type?(type) nodes.any? { |node| node.type == type } end |
#full_text ⇒ String
Get the full text including markers
66 67 68 |
# File 'lib/markdown/merge/freeze_node.rb', line 66 def full_text "#{start_marker}\n#{content}\n#{end_marker}" end |
#inspect ⇒ String
String representation for debugging
88 89 90 |
# File 'lib/markdown/merge/freeze_node.rb', line 88 def inspect "#<#{self.class.name} lines=#{start_line}..#{end_line} nodes=#{nodes.size} reason=#{reason.inspect}>" end |
#line_count ⇒ Integer
Get line count of the freeze block
73 74 75 |
# File 'lib/markdown/merge/freeze_node.rb', line 73 def line_count end_line - start_line + 1 end |
#signature ⇒ Array<Symbol, String>
Generate a signature for matching this freeze block
Signatures are based on the normalized content, allowing freeze blocks with the same content to be matched across files.
59 60 61 |
# File 'lib/markdown/merge/freeze_node.rb', line 59 def signature [:freeze_block, Digest::SHA256.hexdigest(content.strip)[0, 16]] end |