MCPcopy
hub / github.com/ocsjs/ocsjs / resoleInputWrapLines

Function resoleInputWrapLines

packages/scripts/src/projects/unipus/exploration.ts:1254–1269  ·  view source on GitHub ↗

* 解决选词填空、填空题等存在横线的题目,这里吧横线(innerText无法读取)替换成 _____ 以便搜题 * @param root

(root: HTMLElement)

Source from the content-addressed store, hash-verified

1252 * @param root
1253 */
1254function resoleInputWrapLines(root: HTMLElement) {
1255 let temp_ques = '\n' + root?.innerText.trim() || '';
1256 if (temp_ques.match(/\s\d+\)/)) {
1257 // 如果有序号,则替换成空格,避免影响匹配
1258 temp_ques = temp_ques.replace(/\s(\d+)\)/g, ' ($1) _____ ');
1259 } else {
1260 const wrap = root.cloneNode(true) as HTMLElement;
1261 for (const input of Array.from(wrap.querySelectorAll('.fe-scoop'))) {
1262 input.replaceChildren(' _____ ');
1263 }
1264 document.body.appendChild(wrap);
1265 temp_ques = wrap.innerText.trim();
1266 document.body.removeChild(wrap);
1267 }
1268 return temp_ques;
1269}

Callers 1

jobFunction · 0.85

Calls 1

fromMethod · 0.80

Tested by

no test coverage detected