From 80da05fd6a9fe75f977f70577731abc4c3220579 Mon Sep 17 00:00:00 2001 From: Marc Bernard Date: Tue, 17 Dec 2024 19:06:07 +0000 Subject: [PATCH] Fix indent of `
` tags in HTML

`
...
` sections do not render correctly since the HTML is indented, which leads to extra whitespace. abapGit is not impacted but tooling on top of abapGit is. --- src/ui/core/zcl_abapgit_html.clas.abap | 51 +++++++++++++++++++------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/ui/core/zcl_abapgit_html.clas.abap b/src/ui/core/zcl_abapgit_html.clas.abap index a8aaafdf7..f0936f9d6 100644 --- a/src/ui/core/zcl_abapgit_html.clas.abap +++ b/src/ui/core/zcl_abapgit_html.clas.abap @@ -48,6 +48,7 @@ CLASS zcl_abapgit_html DEFINITION within_style TYPE abap_bool, within_js TYPE abap_bool, within_textarea TYPE abap_bool, + within_pre TYPE abap_bool, indent TYPE i, indent_str TYPE string, END OF ty_indent_context . @@ -59,6 +60,8 @@ CLASS zcl_abapgit_html DEFINITION script_close TYPE abap_bool, textarea_open TYPE abap_bool, textarea_close TYPE abap_bool, + pre_open TYPE abap_bool, + pre_close TYPE abap_bool, tag_close TYPE abap_bool, curly_close TYPE abap_bool, openings TYPE i, @@ -85,7 +88,7 @@ ENDCLASS. -CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. +CLASS zcl_abapgit_html IMPLEMENTATION. METHOD checkbox. @@ -120,10 +123,6 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. ENDMETHOD. - METHOD set_debug_mode. - gv_debug_mode = iv_mode. - ENDMETHOD. - METHOD create. CREATE OBJECT ri_instance TYPE zcl_abapgit_html. IF iv_initial_chunk IS NOT INITIAL. @@ -134,11 +133,11 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. METHOD icon. - DATA: lv_hint TYPE string, - lv_name TYPE string, - lv_color TYPE string, - lv_class TYPE string, - lv_onclick TYPE string. + DATA: lv_hint TYPE string, + lv_name TYPE string, + lv_color TYPE string, + lv_class TYPE string, + lv_onclick TYPE string. SPLIT iv_name AT '/' INTO lv_name lv_color. @@ -181,6 +180,17 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. RETURN. ENDIF. + " No indent for pre tags + IF ls_study-pre_open = abap_true. + cs_context-within_pre = abap_true. + RETURN. + ELSEIF ls_study-pre_close = abap_true. + cs_context-within_pre = abap_false. + RETURN. + ELSEIF cs_context-within_pre = abap_true. + RETURN. + ENDIF. + " First closing tag - shift back exceptionally IF ( ls_study-script_close = abap_true OR ls_study-style_close = abap_true @@ -239,6 +249,11 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. ENDMETHOD. + METHOD set_debug_mode. + gv_debug_mode = iv_mode. + ENDMETHOD. + + METHOD study_line. DATA: lv_line TYPE string, @@ -309,6 +324,16 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. ENDIF. ENDIF. + " Pre (same assumptions as above) + IF is_context-within_pre = abap_true AND lv_len >= 5 AND lv_line(5) = '= 4 AND lv_line(4) = ' 0. " Not found + rs_result-pre_open = abap_true. + ENDIF. + ENDIF. + ENDMETHOD. @@ -564,10 +589,10 @@ CLASS ZCL_ABAPGIT_HTML IMPLEMENTATION. DATA lv_close_tag TYPE string. DATA ls_data_attr LIKE LINE OF it_data_attrs. - DATA: lv_class TYPE string, - lv_id TYPE string, + DATA: lv_class TYPE string, + lv_id TYPE string, lv_data_attr TYPE string, - lv_title TYPE string. + lv_title TYPE string. IF iv_id IS NOT INITIAL. lv_id = | id="{ iv_id }"|.