Skip to content

Commit

Permalink
Add flag support and enable multiline by default (#51)
Browse files Browse the repository at this point in the history
ManuelR-D authored Jan 11, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a9ea470 commit e73e671
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tuitorial/highlighting.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ class FocusType(Enum):
SYNTAX = auto()
MARKDOWN = auto()


@dataclass
class Focus:
"""A pattern to focus on with its style."""
@@ -69,10 +68,11 @@ def regex(
cls,
pattern: str | Pattern,
style: Style = Style(color="green", bold=True), # noqa: B008
flags: re.RegexFlag = re.MULTILINE,
) -> Focus:
"""Create a focus for a regular expression."""
if isinstance(pattern, str):
pattern = re.compile(pattern)
pattern = re.compile(pattern, flags)
return cls(pattern, style, FocusType.REGEX)

@classmethod

0 comments on commit e73e671

Please sign in to comment.