Skip to content

Commit 4f47bc4

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: complete universal [/] closing tag migration in remaining Rich markup
The previous commit (8bca19b) converted compound styles but left simple single-style tags like [/red], [/dim], [/green], [/yellow] unconverted. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent 8bca19b commit 4f47bc4

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/ralphify/_console_emitter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _on_run_started(self, data: RunStartedData) -> None:
107107
if max_iter is not None:
108108
info_parts.append(f"max {_plural(max_iter, 'iteration')}")
109109
if info_parts:
110-
self._console.print(f" [dim]{' · '.join(info_parts)}[/dim]")
110+
self._console.print(f" [dim]{' · '.join(info_parts)}[/]")
111111

112112
def _start_live(self) -> None:
113113
spinner = _IterationSpinner()
@@ -135,10 +135,10 @@ def _on_iteration_ended(
135135
self._stop_live()
136136
iteration = data["iteration"]
137137
detail = data["detail"]
138-
self._console.print(f"[{color}]{icon} Iteration {iteration} {detail}[/{color}]")
138+
self._console.print(f"[{color}]{icon} Iteration {iteration} {detail}[/]")
139139
log_file = data["log_file"]
140140
if log_file:
141-
self._console.print(f" [dim]{_ICON_ARROW} {escape_markup(log_file)}[/dim]")
141+
self._console.print(f" [dim]{_ICON_ARROW} {escape_markup(log_file)}[/]")
142142
result_text = data["result_text"]
143143
if result_text:
144144
self._console.print(Markdown(result_text))
@@ -152,12 +152,12 @@ def _on_log_message(self, data: LogMessageData) -> None:
152152
msg = escape_markup(data["message"])
153153
level = data["level"]
154154
if level == LOG_ERROR:
155-
self._console.print(f"[red]{msg}[/red]")
155+
self._console.print(f"[red]{msg}[/]")
156156
tb = data.get("traceback")
157157
if tb:
158-
self._console.print(f"[dim]{escape_markup(tb)}[/dim]")
158+
self._console.print(f"[dim]{escape_markup(tb)}[/]")
159159
else:
160-
self._console.print(f"[dim]{msg}[/dim]")
160+
self._console.print(f"[dim]{msg}[/]")
161161

162162
def _on_run_stopped(self, data: RunStoppedData) -> None:
163163
self._stop_live()

src/ralphify/cli.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
def _exit_error(msg: str) -> NoReturn:
5757
"""Print an error in red and exit with code 1."""
58-
_console.print(f"[red]{msg}[/red]")
58+
_console.print(f"[red]{msg}[/]")
5959
raise typer.Exit(1)
6060

6161

@@ -150,9 +150,9 @@ def _print_banner() -> None:
150150
_console.print(f"[italic {_brand.PURPLE}]{TAGLINE:^{width}}[/]")
151151
_console.print()
152152
help_text = "Run 'ralph --help' for usage information"
153-
_console.print(f"[dim]{help_text:^{width}}[/dim]")
153+
_console.print(f"[dim]{help_text:^{width}}[/]")
154154
star_text = "⭐ Star us on GitHub: https://github.com/computerlovetech/ralphify"
155-
_console.print(f"[dim]{star_text:^{width}}[/dim]")
155+
_console.print(f"[dim]{star_text:^{width}}[/]")
156156
_console.print()
157157

158158

@@ -201,8 +201,8 @@ def scaffold(
201201

202202
ralph_file.write_text(_INIT_TEMPLATE, encoding="utf-8")
203203
rel = ralph_file.relative_to(Path.cwd())
204-
_console.print(f"[green]Created[/green] {rel}")
205-
_console.print(f"[dim]Edit the file, then run:[/dim] ralph run {name or '.'}")
204+
_console.print(f"[green]Created[/] {rel}")
205+
_console.print(f"[dim]Edit the file, then run:[/] ralph run {name or '.'}")
206206

207207

208208
def _parse_user_args(
@@ -370,7 +370,7 @@ def _resolve_ralph_paths(ralph_path: str) -> tuple[Path, Path]:
370370
if installed is not None:
371371
ralph_dir = installed
372372
ralph_file = installed / RALPH_MARKER
373-
_console.print(f"[dim]Resolved:[/dim] {ralph_file}")
373+
_console.print(f"[dim]Resolved:[/] {ralph_file}")
374374
else:
375375
_exit_error(
376376
f"'{ralph_path}' is not a directory, {RALPH_MARKER} file, or installed ralph."
@@ -535,7 +535,7 @@ def run(
535535
)
536536

537537
if log_dir:
538-
_console.print(f"[dim]Logging output to {log_dir}/[/dim]")
538+
_console.print(f"[dim]Logging output to {log_dir}/[/]")
539539

540540
state = RunState(run_id=generate_run_id())
541541
emitter = ConsoleEmitter(_console)
@@ -549,7 +549,7 @@ def _sigint_handler(signum: int, frame: Any) -> None:
549549
if ctrl_c_count == 1:
550550
state.request_stop()
551551
_console.print(
552-
"\n[yellow]Finishing current iteration… (Ctrl+C again to force stop)[/yellow]"
552+
"\n[yellow]Finishing current iteration… (Ctrl+C again to force stop)[/]"
553553
)
554554
else:
555555
signal.signal(signal.SIGINT, original_handler)

0 commit comments

Comments
 (0)