Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.selesse.jxlint.report;
 
 
public class HtmlTemplateHelper {
    private static final Pattern alphanumeric = Pattern.compile("[a-zA-Z0-9_]");
    public static String getHrefSafeName(String string) {
        String hrefSafeName = "" + string.hashCode();
        Matcher alphanumericMatcher = .matcher(string);
        StringBuilder stringBuilder = new StringBuilder();
        while (alphanumericMatcher.find()) {
            stringBuilder.append(alphanumericMatcher.group());
        }
        if (stringBuilder.length() > 0) {
            hrefSafeName = stringBuilder.toString();
        }
        return hrefSafeName.toLowerCase();
    }
    public static String relativize(File file) {
        return FileUtils.getRelativePath(LintRulesImpl.getInstance().getSourceDirectory(), file);
    }
    public static String htmlEscape(String string) {
        return HtmlEscapers.htmlEscaper().escape(string);
    }
    public static String getLabel(Severity severity) {
        switch (severity) {
            case :
            case :
                return "danger";
            case :
                return "warning";
        }
        return "warning";
    }
    public static String sanitizeStackTrace(Exception exception) {
        StringBuilder sanitizedStackTrace = new StringBuilder(exception.getMessage()).append("\n");
        List<StackTraceElementstackTrace = Lists.newArrayList(exception.getStackTrace());
        for (StackTraceElement stackTraceElement : stackTrace) {
            sanitizedStackTrace.append(HtmlTemplateHelper.htmlEscape(stackTraceElement.toString())).append("\n");
        }
        return sanitizedStackTrace.toString();
    }
    public static String markdownToHtml(String description) {
        PegDownProcessor pegDownProcessor = new PegDownProcessor();
        return pegDownProcessor.markdownToHtml(description);
    }
New to GrepCode? Check out our FAQ X