• 
      

    Add a chunk generator for rendered text in diffs.

    Review Request #15533 — Created Nov. 16, 2026 and updated

    Information

    Review Board
    release-9.x

    Reviewers

    The text review UI can diff the rendered view of file attachments, such
    as rendered Markdown, but FileDiffs could only be diffed as plain
    text. This change adds RenderedDiffChunkGenerator, which brings the
    rendered view to FileDiffs.

    It loads both sides of the file just like DiffChunkGenerator,
    including base FileDiffs and interdiffs. It then renders each side
    into rows with a text review UI, and diffs the rows using that review
    UI's comparison rules.

    TextBasedReviewUI has two new classmethods for this:

    • render_text_rows() renders text into rows.

      The default generate_render() now uses this, so a review UI that
      implements it supports the rendered view for both file attachments
      and diffs. MarkdownReviewUI implements it with
      render_markdown_blocks().

    • get_rendered_diff_chunk_generator_cls() returns a chunk generator
      that uses the review UI.

    This can't do interdiff filtering, since that operates specifically on
    source lines, which do not necessarily map to rendered rows.

    This is not yet connected to the diff viewer.

    • Ran unit tests.
    • Used in conjunction with other changes.
    Summary ID
    Add a chunk generator for rendered text in diffs.
    The text review UI can diff the rendered view of file attachments, such as rendered Markdown, but `FileDiff`s could only be diffed as plain text. This change adds `RenderedDiffChunkGenerator`, which brings the rendered view to FileDiffs. It loads both sides of the file just like `DiffChunkGenerator`, including base `FileDiffs` and interdiffs. It then renders each side into rows with a text review UI, and diffs the rows using that review UI's comparison rules. `TextBasedReviewUI` has two new classmethods for this: - `render_text_rows()` renders text into rows. The default `generate_render()` now uses this, so a review UI that implements it supports the rendered view for both file attachments and diffs. `MarkdownReviewUI` implements it with `render_markdown_blocks()`. - `get_rendered_diff_chunk_generator_cls()` returns a chunk generator that uses the review UI. This can't do interdiff filtering, since that operates specifically on source lines, which do not necessarily map to rendered rows. This is not yet connected to the diff viewer. Testing Done: - Ran unit tests. - Used in conjunction with other changes.
    pnkmrwwyoolusqtpvsqnskwvuwvuymtt
    Description From Last Updated

    line too long (80 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    In the MarkdownReviewUI we catch any errors from render_markdown_blocks() and log and show an error message as the rendered lines. …

    maubin maubin
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    david
    maubin
    1. 
        
    2. reviewboard/reviews/chunk_generators.py (Diff revision 2)
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      In the MarkdownReviewUI we catch any errors from render_markdown_blocks() and log and show an error message as the rendered lines. We should probably do something similar here, otherwise users just see an ugly traceback in the diff fragment box. Might even be better to raise a UserVisibleError instead of putting the error in the row text.

      On a related note, the user wouldn't be able to switch back to the source view if the rendered view fails. Would be nice to allow that.

    3. 
        
    david
    Review request changed
    Commits:
    Summary ID
    Add a chunk generator for rendered text in diffs.
    The text review UI can diff the rendered view of file attachments, such as rendered Markdown, but `FileDiff`s could only be diffed as plain text. This change adds `RenderedDiffChunkGenerator`, which brings the rendered view to FileDiffs. It loads both sides of the file just like `DiffChunkGenerator`, including base `FileDiffs` and interdiffs. It then renders each side into rows with a text review UI, and diffs the rows using that review UI's comparison rules. `TextBasedReviewUI` has two new classmethods for this: - `render_text_rows()` renders text into rows. The default `generate_render()` now uses this, so a review UI that implements it supports the rendered view for both file attachments and diffs. `MarkdownReviewUI` implements it with `render_markdown_blocks()`. - `get_rendered_diff_chunk_generator_cls()` returns a chunk generator that uses the review UI. This can't do interdiff filtering, since that operates specifically on source lines, which do not necessarily map to rendered rows. This is not yet connected to the diff viewer. Testing Done: - Ran unit tests. - Used in conjunction with other changes.
    pnkmrwwyoolusqtpvsqnskwvuwvuymtt
    Add a chunk generator for rendered text in diffs.
    The text review UI can diff the rendered view of file attachments, such as rendered Markdown, but `FileDiff`s could only be diffed as plain text. This change adds `RenderedDiffChunkGenerator`, which brings the rendered view to FileDiffs. It loads both sides of the file just like `DiffChunkGenerator`, including base `FileDiffs` and interdiffs. It then renders each side into rows with a text review UI, and diffs the rows using that review UI's comparison rules. `TextBasedReviewUI` has two new classmethods for this: - `render_text_rows()` renders text into rows. The default `generate_render()` now uses this, so a review UI that implements it supports the rendered view for both file attachments and diffs. `MarkdownReviewUI` implements it with `render_markdown_blocks()`. - `get_rendered_diff_chunk_generator_cls()` returns a chunk generator that uses the review UI. This can't do interdiff filtering, since that operates specifically on source lines, which do not necessarily map to rendered rows. This is not yet connected to the diff viewer. Testing Done: - Ran unit tests. - Used in conjunction with other changes.
    pnkmrwwyoolusqtpvsqnskwvuwvuymtt

    Checks run (2 succeeded)

    flake8 passed.
    JSHint passed.
    maubin
    1. Ship It!
    2.