Giter VIP home page Giter VIP logo

bsp-pretty-printer's Introduction

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.