← Questions

Split Markdown into chunks that keep their headers

0
SierraCodingLast asked Apr 2026

Split a Markdown file into chunks no larger than a size limit. When a new chunk starts in the middle of a section, it must begin with the headers that text sits under (for example its level-1 and level-2 headers), followed by the text itself. Decide how the repeated headers count against the size limit and what to do with a single piece of text that is too big on its own.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding