001package gwt.material.design.client.base.helper;
002
003/*
004 * #%L
005 * GwtMaterial
006 * %%
007 * Copyright (C) 2015 - 2017 GwtMaterialDesign
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024import com.google.gwt.safehtml.shared.SafeHtml;
025import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
026import com.google.gwt.safehtml.shared.SafeHtmlUtils;
027
028public final class CodeHelper {
029    public static SafeHtml parseCode(String code) {
030        SafeHtmlBuilder builder = new SafeHtmlBuilder();
031        String[] splitted = code.replaceAll("\\\\s", " ").split("\\\\n\\s?");
032        String[] arr$ = splitted;
033        int len$ = splitted.length;
034
035        for (int i$ = 0; i$ < len$; ++i$) {
036            String s = arr$[i$];
037            builder.append(SafeHtmlUtils.fromTrustedString(SafeHtmlUtils.htmlEscapeAllowEntities(s)));
038            builder.appendHtmlConstant("<br>");
039        }
040
041        return builder.toSafeHtml();
042    }
043
044    private CodeHelper() {
045    }
046}