gmalette/ansi_stream — pull request #1 by dylanahsmith (2014-07-24 02:17:14+00:00)
Title: Avoid matching lines without escapes that start with the letter 'm'.

## Problem

When a stream of text is processed with no escapes, then a match will be made on any lines that start with the letter `m`. E.g.

```
preceding text
mkdir:
cannot create directory `data`: Permission denied
```

will get converted into

```
kdir:
cannot create directory `data`: Permission denied
```

where everything before "\nm" is removed from the text.

This is happening because
* ansi control sequences are detected by splitting on the escape characters `"\e["` then all lines are treated as if they are preceded by these characters, even the first line which should never be considered to start with a control sequence
* the regexp to match the style control sequence uses the `m` flag, which causes the `^` to match the start of the line rather than just the start of the string

## Solution

* Remove the first part after splitting the string by the escape characters to avoid treating it like anything other than plain text.
* Remove the `m` flag from the regexp