INNER CODE UNIT · JavaScript
minBoundary
rockbenben/ChatGPT-Shortcut · plugin-gen-geo.js:95
const minBoundary = Math.floor(maxLen * 0.7);
const boundaries = [
/[。!?.!?][^。!?.!?]*$/, // 句末标点
/[;;][^;;]*$/, // 分号
/[,,][^,,]*$/, // 逗号
/\s\S*$/, // 空格
];
for (const re of boundaries) {
const match = slice.match(re);
if (match && match.index >= minBoundary) {
return slice.slice(0, match.index + 1);
}
}
return slice;
}
module.exports = function (context, options) {
return {