in src/utils/custom-highlight-lang/swift.js [13:35]
export default function (hljs) {
const language = swift(hljs);
const isClassMode = ({ beginKeywords = '' }) => beginKeywords
.split(' ')
.includes('class');
const classModeIndex = language.contains.findIndex(isClassMode);
if (classModeIndex >= 0) {
const {
beginKeywords, // purposefully strip this out
...classMode
} = language.contains[classModeIndex];
// Update the existing "class" mode by replacing the `beginKeywords` with
// a `begin` regular expression, which is careful not to mistakenly
// recognize class function declarations as class declarations
language.contains[classModeIndex] = {
...classMode,
begin: /(struct|protocol|extension|enum|actor|class\b(?!.*\bfunc\b))/,
};
}
return language;
}