Skip to content

Commit 9ed12fd

Browse files
Add regex explanation
Co-authored-by: Zeus <[email protected]>
1 parent 154dbf9 commit 9ed12fd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/planer.coffee

+17
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,23 @@ exports.processMarkedLines = (lines, markers, returnFlags = {}) ->
207207
return lines
208208

209209
# Find inline replies (tm's following the first m in markers string)
210+
# This RegExp is designed to find inline replies which are defined as messages that
211+
# contain new content (m) before and after some amount of quoted text (t)
212+
#
213+
# This RegExp is executed on the processed line markers,
214+
# rather than the raw message lines themselves
215+
#
216+
# The RegExp can be broken into two parts. A middle part that is meant
217+
# to capture the quoted text, and the surrounding "m" markers.
218+
#
219+
# The (?=e*) is designated as a non-capturing group, because we want
220+
# the index of the match to be the start of the inline reply while
221+
# excluding any preceding empty lines ("e" markers).
222+
# The t[te]* is meant to capture any combination of t and e markers, with
223+
# the capture group starting at the first line of quoted text ("t" marker).
224+
#
225+
# Together, the previous two components of the RegExp capture the quoted text
226+
# To get the final RegExp, we surround those components with two "m" markers.
210227
inlineMatchRegex = new RegExp('m(?=e*(t[te]*)m)', 'g')
211228
while inlineReplyMatch = inlineMatchRegex.exec(markers)
212229
inlineReplyIndex = markers.indexOf(inlineReplyMatch[1], inlineReplyMatch.index)

0 commit comments

Comments
 (0)