( parser, text, subContent, startSpan, parseOptions, options, )
| 135 | } |
| 136 | |
| 137 | function parseSubHtml( |
| 138 | parser, |
| 139 | text, |
| 140 | subContent, |
| 141 | startSpan, |
| 142 | parseOptions, |
| 143 | options, |
| 144 | ) { |
| 145 | const { offset } = startSpan; |
| 146 | const textToParse = |
| 147 | replaceNonLineBreaksWithSpace(text.slice(0, offset)) + subContent; |
| 148 | const subAst = parse( |
| 149 | textToParse, |
| 150 | parser, |
| 151 | { ...parseOptions, shouldParseFrontMatter: false }, |
| 152 | options, |
| 153 | ); |
| 154 | |
| 155 | // @ts-expect-error |
| 156 | subAst.sourceSpan = new ParseSourceSpan( |
| 157 | startSpan, |
| 158 | // @ts-expect-error |
| 159 | subAst.children.at(-1).sourceSpan.end, |
| 160 | ); |
| 161 | // @ts-expect-error |
| 162 | const firstText = subAst.children[0]; |
| 163 | if (firstText.length === offset) { |
| 164 | /* c8 ignore next */ // @ts-expect-error |
| 165 | subAst.children.shift(); |
| 166 | } else { |
| 167 | firstText.sourceSpan = new ParseSourceSpan( |
| 168 | firstText.sourceSpan.start.moveBy(offset), |
| 169 | firstText.sourceSpan.end, |
| 170 | ); |
| 171 | firstText.value = firstText.value.slice(offset); |
| 172 | } |
| 173 | return subAst; |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | @param {string} text |
no test coverage detected
searching dependent graphs…