sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 218 forks source link

Nodes included in other nodes but not in children list do not adjust start/end offset for recursive parsing offset #213

Open vsch opened 8 years ago

vsch commented 8 years ago

Nodes get recursively parsed when they are part of list items, block quotes, etc. The start/end offset is adjusted after the parse is complete so the nodes reflect actual offset in the text.

However, the adjustment is done for nodes and their children but some nodes include other nodes that are not part of the child list. These do not get adjusted and this causes their offsets to be outside their parent range.

This affects:

I am changing the parser to let AbstractNode.shiftIndices() and AbstractNode.mapIndices() handle the adjustments for children. That way all nodes that have children not in the child list can override the methods and adjust their 'undeclared' child nodes.