@exercism/codemirror-lang-php 0.0.0-stage → 1.0.1
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/CHANGELOG.md +49 -0
- package/LICENSE +21 -0
- package/README.md +109 -2
- package/dist/index.cjs +621 -0
- package/dist/index.d.cts +52 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +615 -0
- package/package.json +54 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
## 1.0.1
|
|
2
|
+
|
|
3
|
+
The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
|
|
4
|
+
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
This is Exercism's first release of the package, published as
|
|
8
|
+
`@exercism/codemirror-lang-php`. It adds completion of keywords, built-ins,
|
|
9
|
+
snippets, the names declared in the file and class members, and uses Exercism's
|
|
10
|
+
fork of the grammar, `@exercism/lezer-php`.
|
|
11
|
+
|
|
12
|
+
## 6.0.2 (2025-06-19)
|
|
13
|
+
|
|
14
|
+
### Bug fixes
|
|
15
|
+
|
|
16
|
+
Add a .d.cts file to make TypeScript happy.
|
|
17
|
+
## 6.0.1 (2022-10-24)
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
Fix (non-)auto indentation in template strings and comments.
|
|
22
|
+
|
|
23
|
+
Allow prefixed strings to be closed by `closeBrackets`.
|
|
24
|
+
|
|
25
|
+
## 6.0.0 (2022-06-08)
|
|
26
|
+
|
|
27
|
+
### Breaking changes
|
|
28
|
+
|
|
29
|
+
Update dependencies to 6.0.0
|
|
30
|
+
|
|
31
|
+
## 0.20.0 (2022-04-20)
|
|
32
|
+
|
|
33
|
+
### Bug fixes
|
|
34
|
+
|
|
35
|
+
Fix missing highlighting info for the `declare`, `enddeclare`, and `interface` keywords.
|
|
36
|
+
|
|
37
|
+
## 0.19.1 (2021-09-04)
|
|
38
|
+
|
|
39
|
+
### Bug fixes
|
|
40
|
+
|
|
41
|
+
Fix the `plain` option, which was accidentally ignored before.
|
|
42
|
+
|
|
43
|
+
Improve indentation of colon block syntax constructs.
|
|
44
|
+
|
|
45
|
+
## 0.19.0 (2021-09-03)
|
|
46
|
+
|
|
47
|
+
### Breaking changes
|
|
48
|
+
|
|
49
|
+
First numbered release.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- NOTE: README.md is generated from src/README.md -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @codemirror/lang-php [](https://www.npmjs.org/package/@codemirror/lang-php)
|
|
4
|
+
|
|
5
|
+
## Exercism's fork
|
|
6
|
+
|
|
7
|
+
This is Exercism's fork of [@codemirror/lang-php](https://code.haverbeke.berlin/codemirror/lang-php).
|
|
8
|
+
Exercism uses it in the PHP editor on [exercism.org](https://exercism.org).
|
|
9
|
+
It is published on npm as `@exercism/codemirror-lang-php`.
|
|
10
|
+
Our changes are on the `exercism` branch, and the `main` branch follows upstream.
|
|
11
|
+
Below this section, the README is upstream's.
|
|
12
|
+
|
|
13
|
+
The grammar comes from `@exercism/lezer-php`, Exercism's fork of `@lezer/php`.
|
|
14
|
+
It parses a few things that are errors in the official grammar: `function from()`, `foreach ($xs as &$x)`, and mixed-case `Class` and `Static`.
|
|
15
|
+
|
|
16
|
+
The fork adds completion to `php()`:
|
|
17
|
+
|
|
18
|
+
- keywords, types, and the built-in functions, classes and constants
|
|
19
|
+
that are used most often in PHP solutions
|
|
20
|
+
- snippets for functions, methods, classes, loops, `if`, `switch`,
|
|
21
|
+
`match` and `try`
|
|
22
|
+
- the names declared in the file: functions, classes, interfaces,
|
|
23
|
+
traits, enums, constants and imported names, and the variables in
|
|
24
|
+
scope at the cursor (parameters, locals, `foreach` and `catch`
|
|
25
|
+
variables, closure `use` variables and `$this`)
|
|
26
|
+
- after `$this->`, the class's properties and methods, and after
|
|
27
|
+
`self::`, `static::`, `parent::` or a class name, its static
|
|
28
|
+
members, constants and enum cases
|
|
29
|
+
|
|
30
|
+
In PHP, a function can use only its own variables, so inside a function completion offers none of the variables at the top level of the file.
|
|
31
|
+
Inside an arrow function, it also offers the variables around it. Completion offers nothing inside strings and comments.
|
|
32
|
+
|
|
33
|
+
### Install
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install @exercism/codemirror-lang-php
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Building and testing
|
|
40
|
+
|
|
41
|
+
To build and test it from a checkout, run `npm install` (which also builds the package), then `npm test`.
|
|
42
|
+
|
|
43
|
+
### Contributing
|
|
44
|
+
|
|
45
|
+
Contributions to this fork follow the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
|
|
46
|
+
Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/lang-php/src/branch/main/CHANGELOG.md) ]
|
|
51
|
+
|
|
52
|
+
This package implements PHP language support for the
|
|
53
|
+
[CodeMirror](https://codemirror.net/) code editor.
|
|
54
|
+
|
|
55
|
+
The [project page](https://codemirror.net/) has more information, a
|
|
56
|
+
number of [examples](https://codemirror.net/examples/) and the
|
|
57
|
+
[documentation](https://codemirror.net/docs/).
|
|
58
|
+
|
|
59
|
+
This code is released under an
|
|
60
|
+
[MIT license](https://code.haverbeke.berlin/codemirror/lang-php/tree/main/LICENSE).
|
|
61
|
+
|
|
62
|
+
We aim to be an inclusive, welcoming community. To make that explicit,
|
|
63
|
+
we have a [code of
|
|
64
|
+
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
|
65
|
+
to communication around the project.
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
import {EditorView, basicSetup} from "codemirror"
|
|
71
|
+
import {php} from "@exercism/codemirror-lang-php"
|
|
72
|
+
|
|
73
|
+
const view = new EditorView({
|
|
74
|
+
parent: document.body,
|
|
75
|
+
doc: `<? echo "Hello world" ?>`,
|
|
76
|
+
extensions: [basicSetup, php()]
|
|
77
|
+
})
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## API Reference
|
|
81
|
+
|
|
82
|
+
<dl>
|
|
83
|
+
<dt id="user-content-php">
|
|
84
|
+
<code><strong><a href="#user-content-php">php</a></strong>(<a id="user-content-php^config" href="#user-content-php^config">config</a>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a> = {}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
|
85
|
+
|
|
86
|
+
<dd><p>PHP language support.</p>
|
|
87
|
+
<dl><dt id="user-content-php^config">
|
|
88
|
+
<code><strong><a href="#user-content-php^config">config</a></strong></code></dt>
|
|
89
|
+
|
|
90
|
+
<dd><dl><dt id="user-content-php^config.baselanguage">
|
|
91
|
+
<code><strong><a href="#user-content-php^config.baselanguage">baseLanguage</a></strong>⁠?: <a href="https://codemirror.net/docs/ref#language.Language">Language</a></code></dt>
|
|
92
|
+
|
|
93
|
+
<dd><p>By default, the parser will treat content outside of <code><?</code> and
|
|
94
|
+
<code>?></code> markers as HTML. You can pass a different language here to
|
|
95
|
+
change that. Explicitly passing disables parsing of such content.</p>
|
|
96
|
+
</dd><dt id="user-content-php^config.plain">
|
|
97
|
+
<code><strong><a href="#user-content-php^config.plain">plain</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
|
98
|
+
|
|
99
|
+
<dd><p>By default, PHP parsing only starts at the first <code><?</code> marker.
|
|
100
|
+
When you set this to true, it starts immediately at the start of
|
|
101
|
+
the document.</p>
|
|
102
|
+
</dd></dl></dd></dl></dd>
|
|
103
|
+
<dt id="user-content-phplanguage">
|
|
104
|
+
<code><strong><a href="#user-content-phplanguage">phpLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
|
105
|
+
|
|
106
|
+
<dd><p>A language provider based on the <a href="https://code.haverbeke.berlin/lezer/php">Lezer PHP
|
|
107
|
+
parser</a>, extended with
|
|
108
|
+
highlighting and indentation information.</p>
|
|
109
|
+
</dd>
|
|
110
|
+
</dl>
|