{# Render line-level styling for one unified-diff body (single file chunk). #} {% macro render_diff_body(text) %}
{% for line in text.splitlines() -%}
{%- if line.startswith('@@') -%}
{{ line }}
{%- elif line.startswith('+++') or line.startswith('---') or line.startswith('diff ') or line.startswith('index ') -%}
{{ line }}
{%- elif line.startswith('+') -%}
{{ line }}
{%- elif line.startswith('-') -%}
{{ line }}
{%- else -%}
{{ line }}
{%- endif -%}
{% endfor %}
{% endmacro %} {# Legacy: one blob (still works for patches without diff --git splits). #} {% macro render_diff(text) %}
{{ render_diff_body(text) }}
{% endmacro %} {# Preferred: one card per file in the patch. #} {% macro render_diff_sections(sections) %}
{% for sec in sections %}
{{ sec.title }}
{{ render_diff_body(sec.body) }}
{% endfor %}
{% endmacro %}