Only inject TODO and hyperlink into CSS when needed

This commit is contained in:
Andrew Dupont 2024-01-08 17:38:41 -08:00
parent bbf4cb4417
commit 351493fc35

View File

@ -1,22 +1,25 @@
exports.activate = () => {
atom.grammars.addInjectionPoint('source.css', {
type: 'comment',
language: () => 'todo',
content: (node) => node
});
const TODO_PATTERN = /\b(TODO|FIXME|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG|QUESTION|COMBAK|TEMP|DEBUG|OPTIMIZE|WARNING)\b/;
const HYPERLINK_PATTERN = /\bhttps?:/
atom.grammars.addInjectionPoint('source.css', {
type: 'comment',
language: () => 'hyperlink',
language(node) {
return TODO_PATTERN.test(node.text) ? 'todo' : undefined;
},
content: (node) => node
});
atom.grammars.addInjectionPoint('source.css', {
type: 'string_value',
language: () => 'hyperlink',
content: (node) => node
});
for (let type of ['comment', 'string_value']) {
atom.grammars.addInjectionPoint('source.css', {
type,
language(node) {
return HYPERLINK_PATTERN.test(node.text) ? 'hyperlink' : undefined;
},
content: (node) => node
});
}
// Catch things like
//