@haste-health/lang-fp 0.127.1 → 0.127.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @haste-health/lang-fp
|
|
2
|
+
|
|
3
|
+
FHIRPath language support for [CodeMirror 6](https://codemirror.net/): a [Lezer](https://lezer.codemirror.net/) grammar that gives an editor syntax highlighting, bracket-based indentation and folding, and `//` line comments for FHIRPath expressions. [`@haste-health/components`](https://www.npmjs.com/package/@haste-health/components) uses it in its `FHIRExpressionEditable` editor for FHIR `Expression` elements.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @haste-health/lang-fp codemirror
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package depends on `@codemirror/language` and the Lezer runtime itself; `codemirror` (or `@codemirror/view` and `@codemirror/state`) is what you build the editor with. Both ESM and CommonJS builds are published.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { EditorView, minimalSetup } from "codemirror";
|
|
17
|
+
import fhirpath from "@haste-health/lang-fp";
|
|
18
|
+
|
|
19
|
+
new EditorView({
|
|
20
|
+
doc: "Patient.name.where(use = 'official').given.first()",
|
|
21
|
+
extensions: [minimalSetup, fhirpath()],
|
|
22
|
+
parent: document.body,
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The default export returns a `LanguageSupport` ready to drop into `extensions`. The underlying `LRLanguage` is exported as `FPLanguage` for composing with your own extensions or completion sources.
|
|
27
|
+
|
|
28
|
+
Highlighted tokens: identifiers and function calls, `$this`, `%variables`, numbers, `true`/`false`, single-quoted strings, the operators `= != * / + -`, parentheses and line comments. The grammar is a lightweight token grammar for editing, not a full FHIRPath parser. Evaluate expressions with [`@haste-health/fhirpath`](https://www.npmjs.com/package/@haste-health/fhirpath).
|
|
29
|
+
|
|
30
|
+
## Links
|
|
31
|
+
|
|
32
|
+
- [API reference](https://typescript.haste.health/modules/_haste-health_lang-fp.html)
|
|
33
|
+
- [Source](https://github.com/HasteHealth/HasteHealth/tree/main/frontend/packages/lang-fp-codemirror)
|
|
34
|
+
- [CodeMirror language packages](https://codemirror.net/examples/lang-package/), the template this package follows
|
|
35
|
+
- [FHIRPath specification](https://hl7.org/fhirpath/)
|
|
36
|
+
|
|
37
|
+
Part of [Haste Health](https://haste.health). This package is published under the MIT license, as its `package.json` states.
|