site/node_modules/@citation-js/plugin-csl/lib-mjs/affix.js

12 lines
491 B
JavaScript
Raw Permalink Normal View History

2024-10-14 06:09:33 +00:00
const getAffix = (source, affix) => typeof affix === 'function' ? affix(source) : typeof affix === 'string' ? affix : '';
const htmlRegex = /^([^>]+>)([\s\S]+)(<[^<]+)$/i;
const getWrappedEntry = (value, source, {
prepend,
append
}) => {
const [, start = '', content = value, end = ''] = value.match(htmlRegex) || [];
const prefix = getAffix(source, prepend);
const suffix = getAffix(source, append);
return start + prefix + content + suffix + end;
};
export { getWrappedEntry };