{"id":"markdown-sections-chunk","version":"1.0.0","description":"Chunk a CommonMark document into sections at its top-level ATX and setext headings, with levels, paths and spans.","supported_operations":["split markdown into sections by heading","chunk a markdown document at its headings","markdown heading outline with section offsets","which lines belong under each markdown heading","heading breadcrumb path for every markdown chunk","find atx and setext headings outside code blocks"],"unsupported_operations":["rendering Markdown or parsing inline content (heading text is returned raw, e.g. \"foo *bar*\")","splitting at headings nested inside block quotes or list items (only top-level headings split)","token-size limits, overlap windows, or GitHub-flavored extensions such as front matter or tables"],"semantics":["Block structure follows CommonMark 0.31.2: lines and line endings (2.1), tabs (2.2), U+0000 read as U+FFFD (2.3), thematic breaks (4.1), ATX headings (4.2), setext headings (4.3), indented and fenced code (4.4, 4.5), HTML blocks (4.6), link reference definitions (4.7), paragraphs (4.8), block quotes (5.1) and list items (5.2, 5.3). A heading is a section boundary only when it is a child of the document, not inside a block quote or list item; \"#\" lines inside code or HTML blocks are not headings.","Each top-level heading starts a section that runs from the first character of the heading's first line (for a setext heading, the first line of its paragraph) to the first character of the next top-level heading's first line, or to the end of the text. Text before the first heading is a level-0 preamble section (heading null) only when it contains a non-blank line; a blank-only preamble belongs to no section.","heading is the raw heading content without inline parsing: for ATX the text after the opening sequence with the optional closing sequence and surrounding spaces/tabs removed; for setext the paragraph lines (each without its leading whitespace, link reference definitions at its start removed) joined by \"\\n\" and trimmed of spaces/tabs. heading_start_line and heading_end_line are the heading's source lines.","path lists the heading texts of the enclosing sections: walking the headings in order, a heading of level L replaces every open entry of level >= L; path is [] for the preamble.","start/end are Unicode code point offsets into markdown (end exclusive); line(pos) = 1 + number of line endings that end at or before pos; start_line = line(start), end_line = line(end - 1). text is the exact source slice, so the sections tile the text from the first section on.","Lone surrogates throw invalid_input. More than max_sections sections, container nesting deeper than max_nesting_depth, or more than max_output_bytes of listed sections throw limit_exceeded."],"limits":{"max_input_bytes":262144,"max_sections":4096,"max_nesting_depth":64,"max_output_bytes":1048576},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["markdown"],"properties":{"markdown":{"type":"string","description":"The CommonMark document (UTF-8, at most max_input_bytes)."}}},"output_schema":{"type":"object","additionalProperties":false,"required":["section_count","heading_count","sections"],"properties":{"section_count":{"type":"integer","minimum":0},"heading_count":{"type":"integer","minimum":0},"sections":{"type":"array","maxItems":4096,"items":{"type":"object","additionalProperties":false,"required":["index","level","heading","heading_kind","heading_start_line","heading_end_line","path","start","end","start_line","end_line","text"],"properties":{"index":{"type":"integer","minimum":0},"level":{"type":"integer","minimum":0,"maximum":6},"heading":{"type":["string","null"]},"heading_kind":{"type":["string","null"],"enum":["atx","setext",null]},"heading_start_line":{"type":["integer","null"],"minimum":1},"heading_end_line":{"type":["integer","null"],"minimum":1},"path":{"type":"array","maxItems":6,"items":{"type":"string"}},"start":{"type":"integer","minimum":0},"end":{"type":"integer","minimum":0},"start_line":{"type":"integer","minimum":1},"end_line":{"type":"integer","minimum":1},"text":{"type":"string"}}}}}},"examples":[{"input":{"markdown":"Intro line\n\n# Guide\nText.\n\nSetup\n-----\n```\n# not a heading\n```\n"},"output":{"section_count":3,"heading_count":2,"sections":[{"index":0,"level":0,"heading":null,"heading_kind":null,"heading_start_line":null,"heading_end_line":null,"path":[],"start":0,"end":12,"start_line":1,"end_line":2,"text":"Intro line\n\n"},{"index":1,"level":1,"heading":"Guide","heading_kind":"atx","heading_start_line":3,"heading_end_line":3,"path":["Guide"],"start":12,"end":27,"start_line":3,"end_line":5,"text":"# Guide\nText.\n\n"},{"index":2,"level":2,"heading":"Setup","heading_kind":"setext","heading_start_line":6,"heading_end_line":7,"path":["Guide","Setup"],"start":27,"end":63,"start_line":6,"end_line":10,"text":"Setup\n-----\n```\n# not a heading\n```\n"}]}},{"input":{"markdown":"> # quoted\n- # in a list\n## Real ##\n"},"output":{"section_count":2,"heading_count":1,"sections":[{"index":0,"level":0,"heading":null,"heading_kind":null,"heading_start_line":null,"heading_end_line":null,"path":[],"start":0,"end":25,"start_line":1,"end_line":2,"text":"> # quoted\n- # in a list\n"},{"index":1,"level":2,"heading":"Real","heading_kind":"atx","heading_start_line":3,"heading_end_line":3,"path":["Real"],"start":25,"end":36,"start_line":3,"end_line":3,"text":"## Real ##\n"}]}}],"execute_url":"/v1/tools/markdown-sections-chunk/versions/1.0.0/execute"}