Path 1: 1016 calls (0.82)

'\n' (1016)

False (1012) True (4)

True (1011) False (5)

Lines (1016)

1def split(
2        self,
3        separator: str = "\n",
4        *,
5        include_separator: bool = False,
6        allow_blank: bool = False,
7    ) -> Lines:
8        """Split rich text in to lines, preserving styles.
9
10        Args:
11            separator (str, optional): String to split on. Defaults to "\\\\n".
12            include_separator (bool, optional): Include the separator in the lines. Defaults to False.
13            allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.
14
15        Returns:
16            List[RichText]: A list of rich text, one per line of the original.
17        """
18        assert separator, "separator must not be empty"
19
20        text = self.plain
21        if separator not in text:
22            return Lines([self.copy()])
23
24        if include_separator:
25            lines = self.divide(
26                match.end() for match in re.finditer(re.escape(separator), text)
27            )
28        else:
29
30            def flatten_spans() -> Iterable[int]:
31                for match in re.finditer(re.escape(separator), text):
32                    start, end = match.span()
33                    yield start
34                    yield end
35
36            lines = Lines(
37                line for line in self.divide(flatten_spans()) if line.plain != separator
38            )
39
40        if not allow_blank and text.endswith(separator):
41            lines.pop()
42
43        return lines
            

Path 2: 204 calls (0.16)

'\n' (202) ' ' (2)

False (204)

True (200) False (4)

Lines (204)

1def split(
2        self,
3        separator: str = "\n",
4        *,
5        include_separator: bool = False,
6        allow_blank: bool = False,
7    ) -> Lines:
8        """Split rich text in to lines, preserving styles.
9
10        Args:
11            separator (str, optional): String to split on. Defaults to "\\\\n".
12            include_separator (bool, optional): Include the separator in the lines. Defaults to False.
13            allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.
14
15        Returns:
16            List[RichText]: A list of rich text, one per line of the original.
17        """
18        assert separator, "separator must not be empty"
19
20        text = self.plain
21        if separator not in text:
22            return Lines([self.copy()])
23
24        if include_separator:
25            lines = self.divide(
26                match.end() for match in re.finditer(re.escape(separator), text)
27            )
28        else:
29
30            def flatten_spans() -> Iterable[int]:
31                for match in re.finditer(re.escape(separator), text):
32                    start, end = match.span()
33                    yield start
34                    yield end
35
36            lines = Lines(
37                line for line in self.divide(flatten_spans()) if line.plain != separator
38            )
39
40        if not allow_blank and text.endswith(separator):
41            lines.pop()
42
43        return lines
            

Path 3: 22 calls (0.02)

'\n' (15) ' ' (7)

False (22)

False (22)

Lines (22)

1def split(
2        self,
3        separator: str = "\n",
4        *,
5        include_separator: bool = False,
6        allow_blank: bool = False,
7    ) -> Lines:
8        """Split rich text in to lines, preserving styles.
9
10        Args:
11            separator (str, optional): String to split on. Defaults to "\\\\n".
12            include_separator (bool, optional): Include the separator in the lines. Defaults to False.
13            allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.
14
15        Returns:
16            List[RichText]: A list of rich text, one per line of the original.
17        """
18        assert separator, "separator must not be empty"
19
20        text = self.plain
21        if separator not in text:
22            return Lines([self.copy()])
23
24        if include_separator:
25            lines = self.divide(
26                match.end() for match in re.finditer(re.escape(separator), text)
27            )
28        else:
29
30            def flatten_spans() -> Iterable[int]:
31                for match in re.finditer(re.escape(separator), text):
32                    start, end = match.span()
33                    yield start
34                    yield end
35
36            lines = Lines(
37                line for line in self.divide(flatten_spans()) if line.plain != separator
38            )
39
40        if not allow_blank and text.endswith(separator):
41            lines.pop()
42
43        return lines
            

Path 4: 3 calls (0.0)

'\t' (3)

True (3)

False (3)

Lines (3)

1def split(
2        self,
3        separator: str = "\n",
4        *,
5        include_separator: bool = False,
6        allow_blank: bool = False,
7    ) -> Lines:
8        """Split rich text in to lines, preserving styles.
9
10        Args:
11            separator (str, optional): String to split on. Defaults to "\\\\n".
12            include_separator (bool, optional): Include the separator in the lines. Defaults to False.
13            allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.
14
15        Returns:
16            List[RichText]: A list of rich text, one per line of the original.
17        """
18        assert separator, "separator must not be empty"
19
20        text = self.plain
21        if separator not in text:
22            return Lines([self.copy()])
23
24        if include_separator:
25            lines = self.divide(
26                match.end() for match in re.finditer(re.escape(separator), text)
27            )
28        else:
29
30            def flatten_spans() -> Iterable[int]:
31                for match in re.finditer(re.escape(separator), text):
32                    start, end = match.span()
33                    yield start
34                    yield end
35
36            lines = Lines(
37                line for line in self.divide(flatten_spans()) if line.plain != separator
38            )
39
40        if not allow_blank and text.endswith(separator):
41            lines.pop()
42
43        return lines
            

Path 5: 1 calls (0.0)

'\t' (1)

True (1)

False (1)

Lines (1)

1def split(
2        self,
3        separator: str = "\n",
4        *,
5        include_separator: bool = False,
6        allow_blank: bool = False,
7    ) -> Lines:
8        """Split rich text in to lines, preserving styles.
9
10        Args:
11            separator (str, optional): String to split on. Defaults to "\\\\n".
12            include_separator (bool, optional): Include the separator in the lines. Defaults to False.
13            allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False.
14
15        Returns:
16            List[RichText]: A list of rich text, one per line of the original.
17        """
18        assert separator, "separator must not be empty"
19
20        text = self.plain
21        if separator not in text:
22            return Lines([self.copy()])
23
24        if include_separator:
25            lines = self.divide(
26                match.end() for match in re.finditer(re.escape(separator), text)
27            )
28        else:
29
30            def flatten_spans() -> Iterable[int]:
31                for match in re.finditer(re.escape(separator), text):
32                    start, end = match.span()
33                    yield start
34                    yield end
35
36            lines = Lines(
37                line for line in self.divide(flatten_spans()) if line.plain != separator
38            )
39
40        if not allow_blank and text.endswith(separator):
41            lines.pop()
42
43        return lines