{"record":{"id":"f2830f69618c3423","repo":"rust-lang/mdBook","slug":"the-link-items-for-nested-chapters-must-only-conta","errorCode":null,"errorMessage":"The link items for nested chapters must only contain a hyperlink","messagePattern":"The link items for nested chapters must only contain a hyperlink","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/mdbook-summary/src/lib.rs","lineNumber":558,"sourceCode":"                    let mut number = parent.clone();\n                    number.push(num_existing_items as u32 + 1);\n                    trace!(\n                        \"Found chapter: {} {} ({})\",\n                        number,\n                        link.name,\n                        link.location\n                            .as_ref()\n                            .map(|p| p.to_str().unwrap_or(\"\"))\n                            .unwrap_or(\"[draft]\")\n                    );\n\n                    link.number = Some(number);\n\n                    return Ok(SummaryItem::Link(link));\n                }\n                other => {\n                    warn!(\"Expected a start of a link, actually got {:?}\", other);\n                    bail!(self.parse_error(\n                        \"The link items for nested chapters must only contain a hyperlink\"\n                    ));\n                }\n            }\n        }\n    }\n\n    fn parse_error<D: Display>(&self, msg: D) -> Error {\n        let (line, col) = self.current_location();\n        anyhow::anyhow!(\n            \"failed to parse SUMMARY.md line {}, column {}: {}\",\n            line,\n            col,\n            msg\n        )\n    }\n\n    /// Try to parse the title line.","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/rust-lang/mdBook/blob/dc21064fc21d955a0e1f67e65e336883c3e5260b/crates/mdbook-summary/src/lib.rs#L540-L576","documentation":"Nested chapters in SUMMARY.md are written as a link whose item is a nested list. parse_nested_item expects the first event of a nested item to be the start of a hyperlink; if it sees any other event (paragraph text, list item with extra content, etc.), it warns and raises this error because nested items must contain only a hyperlink.","triggerScenarios":"Writing nested chapter entries in SUMMARY.md where a nested list item contains more than a bare link — e.g. \"- [Parent](parent.md) some text\" followed by an indented list, or a nested item with emphasis/inline HTML instead of a plain link.","commonSituations":"Adding descriptive text after a parent link expecting it to be ignored; accidentally inserting characters or formatting inside nested list items; hand-generating SUMMARY.md with scripts that emit extra markup.","solutions":["Make each nested list item contain exactly one hyperlink, e.g. \"  - [Child](child.md)\".","Remove any text, formatting, or HTML that follows the parent link or appears inside nested items.","Regenerate SUMMARY.md with `mdbook build`'s create/scaffold output as a template for correct nesting."],"exampleFix":"<!-- before: SUMMARY.md -->\n- [Parent](parent.md) — advanced topics\n  - [Child](child.md)\n\n<!-- after -->\n- [Parent](parent.md)\n  - [Child](child.md)","handlingStrategy":"validation","validationCode":"// Ensure nested list items contain only a link\nfor (const line of summary.split('\\n')) {\n  if (/^\\s+-\\s/.test(line) && !/^\\s+-\\s\\[[^\\]]+\\]\\([^)]+\\)\\s*$/.test(line)) {\n    throw new Error(`nested item must be only a link: ${line}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put descriptive text inside the chapter file, never next to the link in SUMMARY.md.","Generate SUMMARY.md programmatically with a strict line template."],"tags":["summary","parse","nested-items","mdbook"],"backgroundTag":"malformed-summary-nested-item","analyzedSha":"dc21064fc21d955a0e1f67e65e336883c3e5260b","analyzedAt":"2026-09-01T10:15:12.134Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}