test02/node_modules/@vuepress/highlighter-helper/lib/node/whitespace.js
罗佳鸿 6aa1ebe342
Some checks are pending
部署文档 / deploy-gh-pages (push) Waiting to run
first commit
2024-08-13 10:11:19 +08:00

14 lines
522 B
JavaScript

export const WHITESPACE_REGEXP = /:whitespace(?:=(all|boundary|trailing)?)?\b/;
export const NO_WHITESPACE_REGEXP = /:no-whitespace\b/;
export const resolveWhitespacePosition = (info, defaultPosition) => {
if (NO_WHITESPACE_REGEXP.test(info)) {
return false;
}
defaultPosition = defaultPosition === true ? undefined : defaultPosition;
const match = info.match(WHITESPACE_REGEXP);
if (match) {
return (match[1] || defaultPosition || 'all');
}
return defaultPosition ?? false;
};