2024-05-10 09:49:22 -07:00
|
|
|
# n8n Expression language support
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { parserWithMetaData as n8nParser } from '@n8n/codemirror-lang';
|
|
|
|
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
|
|
|
import { parseMixed } from '@lezer/common';
|
|
|
|
import { parser as jsParser } from '@lezer/javascript';
|
|
|
|
|
|
|
|
const n8nPlusJsParser = n8nParser.configure({
|
|
|
|
wrap: parseMixed((node) => {
|
|
|
|
if (node.type.isTop) return null;
|
|
|
|
|
|
|
|
return node.name === 'Resolvable'
|
|
|
|
? { parser: jsParser, overlay: (node) => node.type.name === 'Resolvable' }
|
|
|
|
: null;
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
const n8nLanguage = LRLanguage.define({ parser: n8nPlusJsParser });
|
|
|
|
|
|
|
|
export function n8nExpressionLanguageSupport() {
|
|
|
|
return new LanguageSupport(n8nLanguage);
|
|
|
|
}
|
|
|
|
```
|
2024-05-16 05:42:47 -07:00
|
|
|
|
|
|
|
## Supported Unicode ranges
|
|
|
|
|
|
|
|
- From `Basic Latin` up to and including `Currency Symbols`
|
|
|
|
- `Miscellaneous Symbols and Pictographs`
|
|
|
|
- `CJK Unified Ideographs`
|