https://github.com/xavierog/codemirror-mode-pcre
Perl Compatible Regular Expressions (PCRE) mode for CodeMirror
https://github.com/xavierog/codemirror-mode-pcre
codemirror-mode pcre pcre-regex
Last synced: 9 days ago
JSON representation
Perl Compatible Regular Expressions (PCRE) mode for CodeMirror
- Host: GitHub
- URL: https://github.com/xavierog/codemirror-mode-pcre
- Owner: xavierog
- License: bsd-3-clause
- Created: 2021-06-11T21:20:45.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-04T17:34:15.000Z (5 months ago)
- Last Synced: 2025-05-02T18:54:45.675Z (19 days ago)
- Topics: codemirror-mode, pcre, pcre-regex
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# CodeMirror PCRE mode
This is a [CodeMirror](https://codemirror.net/) mode that brings syntax highlighting for [Perl Compatible Regular Expressions (PCRE)](https://www.pcre.org/).
## How to use
### Basic use
Load `pcre.js` and `pcre.css` at adequate locations in your HTML structure.
Mention `mode: 'pcre'` when creating your CodeMirror instance.### Configuration
codemirror-mode-pcre supports extended mode (`x` flag) and actually enables it by default. This can be turned off by passing `extended: false` when creating the CodeMirror instance.### Theming
This mode does not leverage CodeMirror's default tokens (they are not exactly fitted for regular expressions). Consequently, if you use a theme other than the default one, you will likely want to write your own `pcre.css` file.**Breaking change:** starting with version 2.0.0, the `cm-end-group` style is no longer supported and should no longer be used. It is replaced with `cm-start-group`.
### Nesting
codemirror-mode-pcre can be nested within another mode, i.e. it can highlight regular expressions for another mode.
This requires adjusting the other mode though.
See the demo page for an example of such nesting.## Non-features
codemirror-mode-pcre does **not** offer:
- completion (e.g. suggesting POSIX class names or script names for `\p` and `\P`);
- tooltips reflecting what the various parts of an expression actually mean.Those may come in the future though.
## License
Like the PCRE library, this mode is released under the 3-clause BSD license.