Skip to content

Commit 7bf3093

Browse files
author
Nikos M
committed
v. 2.6.0 + Codemirror latest 5.8.1
1 parent d853e66 commit 7bf3093

18 files changed

+211
-388
lines changed

README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ __Transform a JSON grammar into a CodeMirror syntax-highlight parser__
55

66

77

8-
A simple and light-weight (~ 30kB minified, ~ 11kB zipped) [CodeMirror](https://github.com/marijnh/codemirror) add-on
8+
A simple and light-weight (~ 37kB minified, ~ 13kB zipped) [CodeMirror](https://github.com/marijnh/codemirror) add-on
99

1010
to generate syntax-highlight parsers (codemirror modes) from a grammar specification in JSON format.
1111

@@ -30,13 +30,9 @@ See also: [ace-grammar](https://github.com/foo123/ace-grammar) , [prism-grammar]
3030

3131
###Todo
3232

33-
Code Indentation is (Codemirror default) <del>and Code Folding is based on existing Codemirror folders (if available)</del>
33+
Code Indentation is Codemirror default, see [Modularity and Future Directions](https://github.com/foo123/editor-grammar/blob/master/grammar-reference.md#modularity-and-future-directions)
3434

35-
*generic code-folders implementations have been added, specified in grammar.Extra.fold option*
3635

37-
see [Modularity and Future Directions](https://github.com/foo123/editor-grammar/blob/master/grammar-reference.md#modularity-and-future-directions)
38-
39-
* handle arbitrary, user-defined, code `folding` in the `grammar` specification (e.g via `fold action` tokens)
4036
* handle arbitrary, user-defined, code `(de-)indentation` in the `grammar` specification (e.g via `indent action` tokens)
4137
* handle arbitrary, user-defined, code `matching` (e.g `brackets`, `tags`, etc..) in the `grammar` specification (e.g via `match action` tokens)
4238
* handle arbitrary, user-defined, `(operator) precedence` relations in the `grammar` specification (e.g via `precedence action` tokens)
@@ -45,6 +41,7 @@ see [Modularity and Future Directions](https://github.com/foo123/editor-grammar/
4541
* enable grammar add-on to pre-compile a grammar specification directly into mode source code, so it can be used without the add-on as standalone mode [TODO, maybe]
4642

4743

44+
4845
###Features
4946

5047
* A [`Grammar`](https://github.com/foo123/editor-grammar/blob/master/grammar-reference.md) can **extend other `Grammars`** (so arbitrary `variations` and `dialects` can be handled more easily)
@@ -56,6 +53,7 @@ see [Modularity and Future Directions](https://github.com/foo123/editor-grammar/
5653
* `Grammar` can define [*action* tokens](https://github.com/foo123/editor-grammar/blob/master/grammar-reference.md#action-tokens) to perform *complex context-specific* parsing functionality, including **associated tag matching** and **duplicate identifiers** (see for example `xml.grammar` example) (**NEW feature**)
5754
* Generated highlight modes can support **toggle comments** and **keyword autocompletion** functionality if defined in the grammar
5855
* Generated highlight modes can support **lint-like syntax-annotation** functionality generated from the grammar
56+
* Generated highlight modes can support custom, user-defined, **code folding** functionality from the [grammar `fold` model](https://github.com/foo123/editor-grammar/blob/master/grammar-reference.md#code-folding) (**NEW feature**)
5957
* Generated parsers are **optimized for speed and size**
6058
* Can generate a syntax-highlight parser from a grammar **interactively and on-the-fly** ( see example, http://foo123.github.io/examples/codemirror-grammar )
6159
* see also [Modularity and Future Directions](https://github.com/foo123/editor-grammar/blob/master/grammar-reference.md#modularity-and-future-directions)
@@ -144,7 +142,7 @@ var xml_grammar = {
144142
};
145143

146144
// 2. parse the grammar into a Codemirror syntax-highlight mode
147-
var xml_mode = CodeMirrorGrammar.getMode(xml_grammar);
145+
var xml_mode = CodeMirrorGrammar.getMode( xml_grammar );
148146

149147

150148
// 3. use it with Codemirror
@@ -159,11 +157,12 @@ xml_mode.supportGrammarAnnotations = true;
159157
CodeMirror.registerHelper("lint", "xml", xml_mode.validator);
160158

161159
// enable user-defined autocompletion (if defined)
162-
var autocomplete_cmd = 'autocomplete_grammar_'+lang;
163160
xml_mode.supportAutoCompletion = true;
164161
CodeMirror.commands['my_autocompletion'] = function( cm ) {
165-
CodeMirror.showHint(cm, xml_mode.autocompleter, {prefixMatch:true,caseInsensitiveMatch:false});
162+
CodeMirror.showHint(cm, xml_mode.autocompleter, {prefixMatch:true, caseInsensitiveMatch:false});
166163
};
164+
// this also works (takes priority if set)
165+
xml_mode.autocompleter.options = {prefixMatch:true, caseInsensitiveMatch:false};
167166

168167
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
169168
mode: "xml",

0 commit comments

Comments
 (0)