You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/mode-reference.rst
+32-2Lines changed: 32 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,19 @@ Regular expression starting a mode. For example a single quote for strings or tw
62
62
If absent, ``begin`` defaults to a regexp that matches anything, so the mode starts immediately.
63
63
64
64
65
+
on:begin
66
+
^^^^^^^^^^^
67
+
68
+
**type**: callback (matchData, response)
69
+
70
+
This callback is triggered the moment a begin match is detected. ``matchData`` includes the typical regex match data; the full match, match groups, etc. The ``response`` object is used to tell the parser how it should handle the match. It can be also used to temporarily store data.
71
+
72
+
- ``response.data`` - a simple object data store. Can be used for building more complex rules where the end rule is dependent on the content of begin, etc.
73
+
- ``response.ignoreMatch()`` - pretend as if this match never happened. The mode is not entered. Continues trying subsequent modes in the current mode's ``contains`` list
74
+
75
+
For an example of usage see ``END_SAME_AS_BEGIN`` in ``modes.js``.
76
+
77
+
65
78
end
66
79
^^^
67
80
@@ -79,6 +92,19 @@ Sometimes a mode can end not by itself but implicitly with its containing (paren
79
92
This is achieved with :ref:`endsWithParent <endsWithParent>` attribute.
80
93
81
94
95
+
on:end
96
+
^^^^^^^^^^^
97
+
98
+
**type**: callback (matchData, response)
99
+
100
+
This callback is triggered the moment an end match is detected. ``matchData`` includes the typical regex match data; the full match, match groups, etc. The ``response`` object is used to tell the parser how it should handle the match. It can also be used to retrieve data stored from a `begin` callback.
101
+
102
+
- ``response.data`` - a simple object data store. Can be used for building more complex rules where the end rule is dependent on the content of begin, etc.
103
+
- ``response.ignoreMatch()`` - pretend as if this match never happened. The mode is not entered. Continues trying subsequent modes in the current mode's ``contains`` list
104
+
105
+
For an example of usage see ``END_SAME_AS_BEGIN`` in ``modes.js``.
106
+
107
+
82
108
beginKeywords
83
109
^^^^^^^^^^^^^^^^
84
110
@@ -182,8 +208,12 @@ tell it to end the function definition after itself:
182
208
183
209
.. _endSameAsBegin:
184
210
185
-
endSameAsBegin
186
-
^^^^^^^^^^^^^^
211
+
endSameAsBegin (deprecated as of 10.1)
212
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
213
+
214
+
**Deprecated:** *This attribute has been deprecated.* You should instead use the
215
+
``END_SAME_AS_BEGIN`` mode or use the ``on:begin`` and ``on:end`` attributes to
0 commit comments