module Inspect
Provides concise pretty-printing for Markdown nodes.
Definitions
PP_INDENT_SIZE = 2
Signature
- constant
The indentation width used for nested node attributes.
def inspect
Returns a pretty-printed representation of the node.
Signature
-
returns
String The formatted node representation.
Implementation
def inspect
PP.pp(self, +"", Float::INFINITY)
end
def pretty_print(printer)
Pretty-print this node and its children.
Signature
-
parameter
printerPrettyPrint The pretty-print formatter.
Implementation
def pretty_print(printer)
printer.group(PP_INDENT_SIZE, "#<#{self.class}(#{type}):", ">") do
printer.breakable
attrs = %i[
source_position
string_content
url
title
header_level
list_type
list_start
list_tight
code_info
].map do |name|
begin
[name, __send__(name)]
rescue Error
nil
end
end.compact
printer.seplist(attrs) do |name, value|
printer.text "#{name}="
printer.pp value
end
if first_child
printer.breakable
printer.group(PP_INDENT_SIZE) do
children = []
node = first_child
while node
children << node
node = node.next
end
printer.text "children="
printer.pp children
end
end
end
end