We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging CommonMarker::Node is a pain because it doesn't support pp.
CommonMarker::Node
pp
I have defined a monkey patch which is something like this:
class CommonMarker class Node # @param [PrettyPrint] pp def pretty_print(pp) pp.group(PP_INDENT_SIZE, "#<#{self.class}(#{type}): ", ">") do pp.breakable attrs = [ :sourcepos, :string_content, :url, :title, :header_level, :list_type, :list_start, :list_tight, :fence_info, # the label for fenced code blocks :first_child, ].map do |name| [name, __send__(name)] rescue nil end.compact pp.seplist(attrs) do |name, value| if name != :first_child pp.text "#{name}=" pp.pp value elsif value pp.group(PP_INDENT_SIZE) do children = [] node = first_child while node children << node node = node.next end pp.text "children=" pp.pp children end end end end end end end
With this routine pp CommonMarker.render_doc("foo **bar** baz") results in:
pp CommonMarker.render_doc("foo **bar** baz")
#<CommonMarker::Node(document): sourcepos={:start_line=>1, :start_column=>1, :end_line=>1, :end_column=>15}, children=[#<CommonMarker::Node(paragraph): sourcepos={:start_line=>1, :start_column=>1, :end_line=>1, :end_column=>15}, children=[#<CommonMarker::Node(text): sourcepos={:start_line=>0, :start_column=>0, :end_line=>0, :end_column=>0}, string_content="foo ", >, #<CommonMarker::Node(strong): sourcepos={:start_line=>0, :start_column=>0, :end_line=>0, :end_column=>0}, children=[#<CommonMarker::Node(text): sourcepos={:start_line=>0, :start_column=>0, :end_line=>0, :end_column=>0}, string_content="bar", >]>, #<CommonMarker::Node(text): sourcepos={:start_line=>0, :start_column=>0, :end_line=>0, :end_column=>0}, string_content=" baz", >]>]>
The text was updated successfully, but these errors were encountered:
I'm afraid I don't know much about extending support for pretty print. Your code looks good to me, would you mind submitting a pull request?
Sorry, something went wrong.
support p and pp for CommonMarker::Node (gjtorikian#42)
b29e92e
No branches or pull requests
Debugging
CommonMarker::Node
is a pain because it doesn't supportpp
.I have defined a monkey patch which is something like this:
With this routine
pp CommonMarker.render_doc("foo **bar** baz")
results in:The text was updated successfully, but these errors were encountered: