Example usage for com.google.common.html HtmlEscapers htmlEscaper

List of usage examples for com.google.common.html HtmlEscapers htmlEscaper

Introduction

In this page you can find the example usage for com.google.common.html HtmlEscapers htmlEscaper.

Prototype

public static Escaper htmlEscaper() 

Source Link

Document

Returns an Escaper instance that escapes HTML metacharacters as specified by <a href="http://www.w3.org/TR/html4/">HTML 4.01</a>.

Usage

From source file:org.dllearner.algorithms.qtl.experiments.Queries.java

public static void main(String[] args) throws Exception {
    File queries = new File(args[0]);
    File targetFile = new File(args[1]);

    List<String> lines = Files.readLines(queries, Charsets.UTF_8);

    String css = "<style>table.reference {\n" + "   width:100%;\n" + "   max-width:100%;\n"
            + "   border-left:1px solid #dddddd;\n" + "   border-right:1px solid #dddddd;   \n"
            + "   border-bottom:1px solid #dddddd;      \n" + "}\n"
            + "table.reference>thead>tr>th, table.reference>tbody>tr>th, table.reference>tfoot>tr>th, table.reference>thead>tr>td, table.reference>tbody>tr>td, table.reference>tfoot>tr>td {\n"
            + "    padding: 8px;\n" + "    line-height: 1.42857143;\n" + "    vertical-align: top;\n"
            + "    border-top: 1px solid #ddd;\n" + "}\n"
            + "table.reference tr:nth-child(odd)   {background-color:#ffffff;}\n"
            + "table.reference tr:nth-child(even)   {background-color:#f1f1f1;}</style>\n\n";

    String html = "<table class=\"reference\">\n";

    html += "<thead><tr><th>ID</th><th>Query</th></tr></thead>\n";

    html += "<tbody>\n";
    int row = 1;/*from   ww w. j  a  v  a  2  s .  c  o m*/
    for (String line : lines) {
        html += "<tr>\n";

        html += "<td>" + row++ + "</td>\n";

        Query query = QueryFactory.create(line);
        html += "<td><pre>" + HtmlEscapers.htmlEscaper().escape(query.toString()) + "</pre></td>\n";
        html += "</tr>\n";
    }

    html += "</tbody>\n";
    html += "</table>";

    Files.write(css + html, targetFile, Charsets.UTF_8);
}

From source file:org.haiku.haikudepotserver.multipage.markup.PlainTextContentTag.java

@Override
protected int doStartTagInternal() throws Exception {

    if (!Strings.isNullOrEmpty(value)) {

        pageContext.getOut().print(String.join("<br/>\n", Arrays.stream(value.split("[\n\r]"))
                .map(s -> HtmlEscapers.htmlEscaper().escape(s)).collect(Collectors.toList())));

    }/*from  www  .ja v  a  2s  .com*/

    return SKIP_BODY;
}

From source file:com.seleritycorp.common.base.escape.Escaper.java

@Inject
Escaper() {
    htmlEscaper = HtmlEscapers.htmlEscaper();
}

From source file:org.haiku.haikudepotserver.multipage.markup.PkgVersionLabelTag.java

@Override
protected int doStartTagInternal() throws Exception {

    Preconditions.checkNotNull(pkgVersion);

    TagWriter tagWriter = new TagWriter(pageContext.getOut());

    tagWriter.startTag("span");
    tagWriter.appendValue(HtmlEscapers.htmlEscaper().escape(pkgVersion.toVersionCoordinates().toString()));
    tagWriter.endTag();//  w  w w . jav  a 2 s. c  o m

    return SKIP_BODY;
}

From source file:org.juckula.JuckulaTemplate.java

public String x(String unescapedString) {
    return HtmlEscapers.htmlEscaper().escape(unescapedString);
}

From source file:org.haiku.haikudepotserver.multipage.markup.TimestampTag.java

@Override
protected int doStartTagInternal() throws Exception {

    TagWriter tagWriter = new TagWriter(pageContext.getOut());

    if (null != getValue()) {
        tagWriter.startTag("span");
        tagWriter.appendValue(HtmlEscapers.htmlEscaper()
                .escape(FORMATTER.format(Instant.ofEpochMilli(getValue().getTime()))));
        tagWriter.endTag();//from   w w w. j  a  v a2 s. c  om
    }

    return SKIP_BODY;
}

From source file:com.github.foobar27.myhtml4j.example.Text.java

@Override
public String toHtml() {
    return HtmlEscapers.htmlEscaper().escape(text);
}

From source file:org.tzi.use.uml.ocl.expr.GenerateHTMLExpressionVisitor.java

@Override
protected String quoteContent(String s) {
    return HtmlEscapers.htmlEscaper().escape(s);
}

From source file:net.morimekta.providence.generator.format.java.utils.BlockCommentBuilder.java

public BlockCommentBuilder(IndentedPrintWriter writer) {
    this.html = HtmlEscapers.htmlEscaper();
    this.writer = writer;

    writer.appendln("/**").begin(" *");
}

From source file:com.facebook.buck.intellij.plugin.ui.tree.renderers.DetailNodeRenderer.java

@Override
public Component render(Object value) {
    BuckTreeNodeDetail node = (BuckTreeNodeDetail) value;

    Icon icon = AllIcons.Ide.Info_notifications;
    if (node.getType() == BuckTreeNodeDetail.DetailType.ERROR) {
        icon = AllIcons.Ide.Error;
    } else if (node.getType() == BuckTreeNodeDetail.DetailType.WARNING) {
        icon = AllIcons.Ide.Warning_notifications;
    }/*from   w  w w.j  ava 2 s . c  om*/

    String message = "<html><pre style='margin:0px'>" + HtmlEscapers.htmlEscaper().escape(node.getDetail())
            + "</pre></html>";

    JBLabel result = new JBLabel(message, icon, SwingConstants.HORIZONTAL);

    result.setToolTipText("<pre>" + node.getDetail() + "</pre>");

    return result;
}