{"version":3,"file":"has-parbreak-BVWIw5ma.cjs","names":[],"sources":["../utils/has-parbreak.ts"],"sourcesContent":["import * as Ast from \"@unified-latex/unified-latex-types\";\nimport { match } from \"@unified-latex/unified-latex-util-match\";\n\n/**\n * Returns whether there is a parbreak in `nodes` (either a parsed parbreak,\n * or the macro `\\par`)\n */\nexport function hasParbreak(nodes: Ast.Node[]) {\n    return nodes.some(\n        (node) => match.parbreak(node) || match.macro(node, \"par\")\n    );\n}\n\n/**\n * Is there a parbreak or a macro/environment that acts like a parbreak (e.g. \\section{...})\n * in the array?\n */\nexport function hasBreakingNode(\n    nodes: Ast.Node[],\n    options?: {\n        macrosThatBreakPars?: string[];\n        environmentsThatDontBreakPars?: string[];\n    }\n): boolean {\n    if (hasParbreak(nodes)) {\n        return true;\n    }\n\n    const {\n        macrosThatBreakPars = [\n            \"part\",\n            \"chapter\",\n            \"section\",\n            \"subsection\",\n            \"subsubsection\",\n            \"vspace\",\n            \"smallskip\",\n            \"medskip\",\n            \"bigskip\",\n            \"hfill\",\n        ],\n        environmentsThatDontBreakPars = [],\n    } = options || {};\n\n    const macroMatcher = match.createMacroMatcher(macrosThatBreakPars);\n    const envMatcher = match.createEnvironmentMatcher(\n        environmentsThatDontBreakPars\n    );\n\n    return nodes.some(\n        (node) =>\n            macroMatcher(node) ||\n            (match.anyEnvironment(node) && !envMatcher(node))\n    );\n}\n"],"mappings":";;;;;;AAOA,SAAgB,YAAY,OAAmB;AAC3C,QAAO,MAAM,MACR,SAAS,wCAAA,MAAM,SAAS,KAAK,IAAI,wCAAA,MAAM,MAAM,MAAM,MAAM,CAC7D;;;;;;AAOL,SAAgB,gBACZ,OACA,SAIO;AACP,KAAI,YAAY,MAAM,CAClB,QAAO;CAGX,MAAM,EACF,sBAAsB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACH,EACD,gCAAgC,EAAE,KAClC,WAAW,EAAE;CAEjB,MAAM,eAAe,wCAAA,MAAM,mBAAmB,oBAAoB;CAClE,MAAM,aAAa,wCAAA,MAAM,yBACrB,8BACH;AAED,QAAO,MAAM,MACR,SACG,aAAa,KAAK,IACjB,wCAAA,MAAM,eAAe,KAAK,IAAI,CAAC,WAAW,KAAK,CACvD"}