"""Componente para renderizar diffs unificados con coloreado básico.""" from __future__ import annotations import streamlit as st def render_unified_diff(diff_text: str) -> None: if not diff_text.strip(): st.info("Sin diferencias entre las versiones seleccionadas.") return lines: list[str] = [] for line in diff_text.splitlines(): if line.startswith("+") and not line.startswith("+++"): lines.append(f'{line}') elif line.startswith("-") and not line.startswith("---"): lines.append(f'{line}') elif line.startswith("@@"): lines.append(f'{line}') else: lines.append(line) html = ( "
" + "\n".join(lines) + "
" ) st.markdown(html, unsafe_allow_html=True)