anchor.diff:  
   ENDCLASS.                    "lcl_porcelain DEFINITION
   
  +*----------------------------------------------------------------------*
  +*       CLASS lcl_html_helper DEFINITION
  +*----------------------------------------------------------------------*
  +CLASS lcl_html_helper DEFINITION FINAL.
  +  PUBLIC SECTION.
  +    CONSTANTS mc_indent_size TYPE i VALUE 2.
  +
  +    DATA mv_html   TYPE string READ-ONLY.
  +    DATA mv_indent TYPE i READ-ONLY.
  +
  +    METHODS add IMPORTING iv_chunk TYPE any.
  +    METHODS reset.
  +
  +  PRIVATE SECTION.
  +    METHODS _add_str IMPORTING iv_str  TYPE csequence.
  +    METHODS _add_htm IMPORTING io_html TYPE REF TO lcl_html_helper.
  +
  +endclass.                    "lcl_html_helper DEFINITION
  +
  +*----------------------------------------------------------------------*
  +*       CLASS lcl_html_helper IMPLEMENTATION
  +*----------------------------------------------------------------------*
  +CLASS lcl_html_helper IMPLEMENTATION.
  +  METHOD add.
  +    DATA lo_type TYPE REF TO cl_abap_typedescr.
  +    DATA lo_html TYPE REF TO lcl_html_helper.
  +
  +    lo_type = cl_abap_typedescr=>describe_by_data( iv_chunk ).
  +
  +    CASE lo_type->type_kind.
  +    WHEN cl_abap_typedescr=>typekind_char OR cl_abap_typedescr=>typekind_string.
  +      _add_str( iv_chunk ).
  +    WHEN cl_abap_typedescr=>typekind_oref.
  +      ASSERT iv_chunk IS BOUND. " Dev mistake
  +      TRY.
  +        lo_html ?= iv_chunk.
  +      CATCH cx_sy_move_cast_error.
  +        ASSERT 1 = 0. " Dev mistake
  +      ENDTRY.
  +      _add_htm( lo_html ).
  +    WHEN OTHERS.
  +      ASSERT 1 = 0. " Dev mistake
  +    ENDCASE.
  +
  +  ENDMETHOD.  " add
  +
  +  METHOD reset.
  +    CLEAR: me->mv_html, me->mv_indent.
  +  ENDMETHOD.                    "reset
  +
  +  METHOD _add_str.
  +    DATA lv_tags        TYPE i.
  +    DATA lv_tags_open   TYPE i.
  +    DATA lv_tags_close  TYPE i.
  +    DATA lv_close_offs  TYPE i.
  +    DATA lv_shift_back  TYPE i.
  +
  +    FIND FIRST OCCURRENCE OF '</' IN iv_str MATCH OFFSET lv_close_offs.
  +    IF sy-subrc = 0 AND lv_close_offs = 0 AND mv_indent > 0. " Found close tag @beginning
  +      lv_shift_back = 1.
  +    ENDIF.
  +
  +    mv_html =   mv_html
  +            &&  repeat( val = ` ` occ = ( mv_indent - lv_shift_back ) * mc_indent_size )
  +            &&  iv_str
  +            &&  gc_newline.
  +
  +    FIND ALL OCCURRENCES OF '<'  IN iv_str MATCH COUNT lv_tags.
  +    FIND ALL OCCURRENCES OF '</' IN iv_str MATCH COUNT lv_tags_close.
  +    lv_tags_open = lv_tags - lv_tags_close.
  +
  +    IF lv_tags_open > lv_tags_close. " This logic chosen due to possible double tags in a line '<a><b>'
  +      mv_indent = mv_indent + 1.
  +    ELSEIF lv_tags_open < lv_tags_close AND mv_indent > 0.
  +      mv_indent = mv_indent - 1.
  +    ENDIF.
  +
  +  ENDMETHOD.                    "_add_str
  +
  +  METHOD _add_htm.
  +    DATA lv_indent_str  TYPE string.
  +    DATA lv_temp_str    TYPE string.
  +
  +    lv_indent_str = repeat( val = ` ` occ = mv_indent * mc_indent_size ).
  +    lv_temp_str   = io_html->mv_html.
  +
  +    IF me->mv_indent > 0.
  +      REPLACE ALL OCCURRENCES OF gc_newline IN lv_temp_str WITH gc_newline && lv_indent_str.
  +      SHIFT lv_temp_str RIGHT DELETING TRAILING space.
  +      SHIFT lv_temp_str LEFT  DELETING LEADING space.
  +    ENDIF.
  +
  +    mv_html   = mv_html && lv_indent_str && lv_temp_str.
  +    mv_indent = mv_indent + io_html->mv_indent.
  +
  +  ENDMETHOD.                    "_add_htm
  +
  +ENDCLASS.                    "lcl_html_helper IMPLEMENTATION
  +
  +*----------------------------------------------------------------------*
  +*       INTERFACE lif_gui_page DEFINITION
  +*----------------------------------------------------------------------*
   INTERFACE lif_gui_page.
   
     METHODS:
  
positive.code:     DATA: ms_result TYPE lcl_file_status=>ty_result,
            mo_diff   TYPE REF TO lcl_diff.
  
  ENDCLASS.
  
  CLASS lcl_gui_page_diff IMPLEMENTATION.
  
    METHOD constructor.
      ms_result = is_result.
      mo_diff = io_diff.
    ENDMETHOD.
  
    METHOD lif_gui_page~on_event.
  
  
negative.code:       WHEN 'back'.
          lcl_gui=>back( ).
        WHEN OTHERS.
          _raise 'Unknown action'. "#EC NOTEXT
      ENDCASE.
  
    ENDMETHOD.
  
    METHOD lif_gui_page~render.
  
      DATA: lv_html         TYPE string.
      DATA  lo_html  TYPE REF TO lcl_html_helper.
  
  * REDO
      lv_html = lcl_gui=>header( ).
  
      "TODO: crutch, redo later after unification
      replace first occurrence of '</style>' in lv_html
        with '</style>' && styles( )->mv_html.
  
      "TODO: crutch, move to SAP back button (code almost ready)
      lv_html = lv_html && '<div>' && '<a href="sapevent:back">Back</a>' && '</div>'.
      lo_html->add( lv_html ).
  * ^^^ REDO
  
      lo_html->add( '<div class="diff">' ).  "#EC NOTEXT
      lo_html->add( render_head( ) ).
      lo_html->add( render_diff( ) ).
      lo_html->add( '</div>' ).              "#EC NOTEXT
      lo_html->add( lcl_gui=>footer( ) ).
  
      rv_html = lo_html->mv_html.
  
    ENDMETHOD.
  
  