Modify document nodes and attributes
mainOnce you have parsed a document, you can manipulate the AST using the following methods and attribute assignments:
Structural Operations:
insert_before(node)insert_after(node)prepend_child(node)append_child(node)delete
Attribute Modifications: You can directly modify the following attributes on supported nodes:
urltitleheader_levellist_typelist_startlist_tightfence_infoalert_type
Source Position:
Call source_position on a node to retrieve its location in the original string as a hash containing :start_line, :start_column, :end_line, and :end_column.
doc = Commonmarker.parse("*Hello* world")
puts doc.first_child.first_child.source_position
# => {:start_line=>1, :start_column=>1, :end_line=>1, :end_column=>7}