{"record":{"id":"66cc426628af43ba","repo":"swc-project/swc","slug":"no-cell-to-close","errorCode":null,"errorMessage":"No cell to close","messagePattern":"No cell to close","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"crates/swc_html_parser/src/parser/mod.rs","lineNumber":5590,"sourceCode":"                    Token::StartTag { tag_name, .. }\n                        if matches!(\n                            &**tag_name,\n                            \"caption\"\n                                | \"col\"\n                                | \"colgroup\"\n                                | \"tbody\"\n                                | \"td\"\n                                | \"tfoot\"\n                                | \"th\"\n                                | \"thead\"\n                                | \"tr\"\n                        ) =>\n                    {\n                        if !self.open_elements_stack.has_in_table_scope(\"td\")\n                            && !self.open_elements_stack.has_in_table_scope(\"th\")\n                        {\n                            self.errors\n                                .push(Error::new(token_and_info.span, ErrorKind::NoCellToClose));\n                        } else {\n                            self.close_the_cell();\n                            self.process_token(token_and_info, None)?;\n                        }\n                    }\n                    // An end tag whose tag name is one of: \"body\", \"caption\", \"col\", \"colgroup\",\n                    // \"html\"\n                    //\n                    // Parse error. Ignore the token.\n                    Token::EndTag { tag_name, .. }\n                        if matches!(\n                            &**tag_name,\n                            \"body\" | \"caption\" | \"col\" | \"colgroup\" | \"html\"\n                        ) =>\n                    {\n                        self.errors.push(Error::new(\n                            token_and_info.span,\n                            ErrorKind::StrayEndTag(tag_name.clone()),","sourceCodeStart":5572,"sourceCodeEnd":5608,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_html_parser/src/parser/mod.rs#L5572-L5608","documentation":"In the \"in cell\" insertion mode, an end tag `caption`, `table`, `tbody`, `tfoot`, `thead`, or `tr` was seen while neither `td` nor `th` is in table scope. HTML5 defines this as a parse error (\"no cell to close\"); the token is ignored. It means a table-structure closer arrived when the cell it should implicitly close is already gone.","triggerScenarios":"Deeply malformed/nested tables where the open cell was already popped from table scope (e.g. by a nested `<table>` reset or duplicated section closers) before `</table>`, `</tbody>`, `</tfoot>`, `</thead>`, `</caption>`, or `</tr>` arrived — e.g. `<table><tr><td><table><tr><td>x</table></tr></table></tr></table>`-style leftover closers.","commonSituations":"Machine-generated tables (Excel/Word exports, report engines) with extra section/row closers; hand-nested tables where inner and outer closers get confused; sanitizer output that removed cells but kept structure closers.","solutions":["Simplify the nesting: remove leftover `</tr>`/`</tbody>`/`</table>` closers that no longer have a matching open element.","Regenerate the table from data with a trusted template engine instead of patching broken markup.","Validate with the W3C/WHATWG checker; it reports every unmatched structure closer with its position.","Treat as recoverable for third-party content: the token is ignored; log the `NoCellToClose` entry from the `errors` vec and use the corrected tree."],"exampleFix":"<!-- before: leftover </tr> after the row was already closed -->\n<table><tr><td>a</td></tr></tr></table>\n\n<!-- after -->\n<table><tr><td>a</td></tr></table>","handlingStrategy":"validation","validationCode":"// Pre-check: structure closers without matching openers anywhere in the document\nfn stray_structure_closers(html: &str) -> Vec<&'static str> {\n    [\"caption\", \"table\", \"tbody\", \"tfoot\", \"thead\", \"tr\"]\n        .into_iter()\n        .filter(|t| html.matches(&format!(\"<{t}\")).count() < html.matches(&format!(\"</{t}\")).count())\n        .collect()\n}","typeGuard":"use swc_html_parser::error::{Error, ErrorKind};\n\nfn is_no_cell_to_close(err: &Error) -> bool {\n    matches!(err.kind(), ErrorKind::NoCellToClose)\n}","tryCatchPattern":"let mut errors = Vec::new();\nmatch parse_file_as_document(&fm, config, &mut errors) {\n    Ok(doc) => {\n        for e in errors.iter().filter(|e| matches!(e.kind(), ErrorKind::NoCellToClose)) {\n            // token ignored per spec; tree recovered — log with span for upstream fix\n        }\n    }\n    Err(fatal) => return Err(fatal.into()),\n}","preventionTips":["Never hand-nest tables; generate them from structured data with a trusted template engine.","Remove leftover section/row closers when deleting cells from exported tables (Excel/Word exports are repeat offenders).","Run the WHATWG/W3C checker on machine-generated tables before ingestion.","Monitor NoCellToClose in the errors vec as a data-quality signal for imported HTML."],"tags":["html","html-parser","table","stray-end-tag","parse-error","swc"],"backgroundTag":"html-table-structure-error","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}