Added support for merging lists and list items while extracting contents.
Tests: Added tests for merging adjacent lists and list items.
Code refactoring: Micro-optimizations for collapsed ranges.