Skip to content

rplantiko/bsp-pretty-printer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

For formatting the code of a BSP view, the ABAP workbench uses a standard formatter (implemented in method pretty_print of class CL_O2_CO2_PROCESSOR). This standard formatter only looks for the BSP elements of the view The output will be aligned according to the tree that is spanned by these BSP elements. All the rest of the view's content is treated as literal text, including HTML elements.

This standard behaviour is a general-purpose algorithm which has its justification in the fact that a BSP view can generate any output - may it be XML, HTML, JSON, YAML, or any text-based custom format. The standard has to provide an algorithm that is agnostic for the concrete content type.

For a BSP view that is used to generate HTML code, the standard behaviour is not what we want. Instead, the tree should be spanned by both BSP elements and HTML elements.

Since, as to my knowledge, there is no full-featured HTML parser available in ABAP, I chose to implement such a pretty printer in Perl, using the module HTML::Parser. The Perl program is made accessible to ABAP as a system command, and used as an alternative to the standard formatter by a simple modification described on bsp.mits.ch.

Features

  • Indentation

    The indentation is performed along the common tree spanned by HTML and BSP elements. The indentation depth per level is configurable.

    Exceptions are inline tags (like <i>) and non-closing tags (like <img>. The lists of these tags are configurable.

  • Attributes alignment

    Vertically if opening tag is "long enough" (configurable) to do so, or if the opening tag already contains a line break.

  • HTML tags to lower case

    While BSP element names have to be preserved in the given case, HTML element names will be transformed to lower case.

Reference

Ein Pretty Printer für BSP Views (German language)

About

A pretty printer for BSP views

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages