Method: rich.markup._parse
Calls: 226, Exceptions: 5, Paths: 13Back
Path 1: 108 calls (0.48)
'[progress.description]test' (10) '[green]Date' (8) '[blue]Title' (8) '[cyan]Production Budget' (8) '[magenta]Box Office' (8) '[layout.tree.column]⬍' ...
tuple (108) None (108) (22, 'test', None) (10) (7, 'Date', None) (8) (6, 'Title', None) (8) (6, 'Production Budget', None) (8) (9, 'Box Office', None)...
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 2: 67 calls (0.3)
'[traceback.title]Traceback [dim](most recent call last)' (18) '✓ [bold green]4-bit color[/]\n✓ [bold blue]8-bit color[/]\n✓ [bold magenta]Truecolor (...
tuple (314) None (67) (27, 'Traceback ', None) (18) (32, '(most recent call last)', None) (18) (2, '✓ ', None) (9) (25, '4-bit color', None) (9) (31, ...
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 3: 36 calls (0.16)
'[bold]$1,332,539,889[/bold]' (8) '[b red on blue reverse]foo[/] [blink][link=https://example.org]Click[/link]' (3) 'foo 3.141 127.0.0.1 [red]alert[/r...
tuple (101) (20, '$1,332,539,889', None) (8) (26, 'foo', None) (3) (30, ' ', None) (3) (68, 'Click', None) (3) (20, 'foo 3.141 127.0.0.1 ', None) (3) ...
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 4: 3 calls (0.01)
'\\\\\\[red]' (1) '\\\\\\\\\\[red]' (1) '\\\\\\\\\\\\\\[red]' (1)
(0, '\\', None) (1) (2, '[red]', None) (1) (0, '\\\\', None) (1) (4, '[red]', None) (1) (0, '\\\\\\', None) (1) (6, '[red]', None) (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 5: 3 calls (0.01)
'[foo]hello[/bar]' (1) '[@click=sdfwer(sfs)]foo[/]' (1) "[@click='view.toggle]foo[/]" (1)
tuple (6) None (3) (10, 'hello', None) (1) (23, 'foo', None) (1) (24, 'foo', None) (1)
GeneratorExit (3)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 6: 2 calls (0.01)
'foo[/]' (1) 'foo[/bar]' (1)
(3, 'foo', None) (2) tuple (2) None (2)
GeneratorExit (2)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 7: 1 calls (0.0)
'\\[red]' (1)
(0, '[red]', None) (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 8: 1 calls (0.0)
'[foo]hello[/foo][bar]world[/]\\[escaped]' (1)
tuple (4) (10, 'hello', None) (1) (26, 'world', None) (1) (29, '[escaped]', None) (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 9: 1 calls (0.0)
'[[1], [1,2,3,4], ["hello"], [None], [False], [True]] []' (1)
(0, '[[1], [1,2,3,4], ["hello"], [None], [False], [True]] []', None) (1) None (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 10: 1 calls (0.0)
'\\\\[bold]FOO' (1)
(0, '\\', None) (1) tuple (1) (8, 'FOO', None) (1) None (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 11: 1 calls (0.0)
'\\[bold]FOO' (1)
(0, '[bold]', None) (1) (7, 'FOO', None) (1) None (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 12: 1 calls (0.0)
'\\\\[bold]some text[/]' (1)
tuple (2) (0, '\\', None) (1) (17, 'some text', None) (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None
Path 13: 1 calls (0.0)
'\\\\\\[bold]some text\\[/]' (1)
(0, '\\', None) (1) (2, '[bold]', None) (1) (18, 'some text', None) (1) (18, '[/]', None) (1)
1def _parse(markup: str) -> Iterable[Tuple[int, Optional[str], Optional[Tag]]]:
2 """Parse markup in to an iterable of tuples of (position, text, tag).
3
4 Args:
5 markup (str): A string containing console markup
6
7 """
8 position = 0
9 _divmod = divmod
10 _Tag = Tag
11 for match in RE_TAGS.finditer(markup):
12 full_text, escapes, tag_text = match.groups()
13 start, end = match.span()
14 if start > position:
15 yield start, markup[position:start], None
16 if escapes:
17 backslashes, escaped = _divmod(len(escapes), 2)
18 if backslashes:
19 # Literal backslashes
20 yield start, "\\" * backslashes, None
21 start += backslashes * 2
22 if escaped:
23 # Escape of tag
24 yield start, full_text[len(escapes) :], None
25 position = end
26 continue
27 text, equals, parameters = tag_text.partition("=")
28 yield start, None, _Tag(text, parameters if equals else None)
29 position = end
30 if position < len(markup):
31 yield position, markup[position:], None