MCPcopy Index your code
hub / github.com/prettier/prettier / parseSubHtml

Function parseSubHtml

src/language-html/parse/parse.js:137–174  ·  view source on GitHub ↗
(
  parser,
  text,
  subContent,
  startSpan,
  parseOptions,
  options,
)

Source from the content-addressed store, hash-verified

135}
136
137function 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

Callers 1

parseFunction · 0.85

Calls 3

atMethod · 0.80
parseFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…