private Map getStylePropertiesLowerCase()

in jspwiki-wysiwyg/src/main/java/org/apache/wiki/htmltowiki/XHtmlElementToWikiTranslator.java [180:231]


    private Map< Object, Object > getStylePropertiesLowerCase( final Element base ) {
        final String n = base.getName().toLowerCase();

        // "font-weight: bold; font-style: italic;"
        String style = base.getAttributeValue( "style" );
        if( style == null ) {
            style = "";
        }

        if( n.equals( "p" ) || n.equals( "div" ) ) {
            final String align = base.getAttributeValue( "align" );
            if( align != null ) {
                // only add the value of the align attribute if the text-align style didn't already exist.
                if( !style.contains( "text-align" ) ) {
                    style += ";text-align:" + align + ";";
                }
            }
        }

        if( n.equals( "font" ) ) {
            final String color = base.getAttributeValue( "color" );
            final String face = base.getAttributeValue( "face" );
            final String size = base.getAttributeValue( "size" );
            if( color != null ) {
                style = style + "color:" + color + ";";
            }
            if( face != null ) {
                style = style + "font-family:" + face + ";";
            }
            if( size != null ) {
                switch ( size ) {
                    case "1": style += "font-size:xx-small;"; break;
                    case "2": style += "font-size:x-small;"; break;
                    case "3": style += "font-size:small;"; break;
                    case "4": style += "font-size:medium;"; break;
                    case "5": style += "font-size:large;"; break;
                    case "6": style += "font-size:x-large;"; break;
                    case "7": style += "font-size:xx-large;"; break;
                }
            }
        }

        if( style.equals( "" ) ) {
            return null;
        }

        final Map< Object, Object > m = new LinkedHashMap<>();
        Arrays.stream( style.toLowerCase().split( ";" ) )
              .filter( StringUtils::isNotBlank )
              .forEach( prop -> m.put( prop.split( ":" )[ 0 ].trim(), prop.split( ":" )[ 1 ].trim() ) );
        return m;
    }