@Override public Mustache.Compiler processCompiler(Mustache.Compiler compiler) { Mustache.Escaper SCALA = new Mustache.Escaper() { @Override public String escape(String text) { // Fix included as suggested by akkie in #6393 // The given text is a reserved word which is escaped by enclosing it with grave accents. If we would // escape that with the default Mustache `HTML` escaper, then the escaper would also escape our grave // accents. So we remove the grave accents before the escaping and add it back after the escaping. if (text.startsWith("`") && text.endsWith("`")) { String unescaped = text.substring(1, text.length() - 1); return "`" + Escapers.HTML.escape(unescaped) + "`"; } // All none reserved words will be escaped with the default Mustache `HTML` escaper return Escapers.HTML.escape(text); } }; return compiler.withEscaper(SCALA); }
@Override public Mustache.Compiler processCompiler(Mustache.Compiler compiler) { Mustache.Escaper SCALA = new Mustache.Escaper() { @Override public String escape (String text) { // Fix included as suggested by akkie in #6393 // The given text is a reserved word which is escaped by enclosing it with grave accents. If we would // escape that with the default Mustache `HTML` escaper, then the escaper would also escape our grave // accents. So we remove the grave accents before the escaping and add it back after the escaping. if (text.startsWith("`") && text.endsWith("`")) { String unescaped = text.substring(1, text.length() - 1); return "`" + Escapers.HTML.escape(unescaped) + "`"; } // All none reserved words will be escaped with the default Mustache `HTML` escaper return Escapers.HTML.escape(text); } }; return compiler.withEscaper(SCALA); }
/** * Markdown conversion emits HTML and by default, the Mustache * {@link Compiler} will escape HTML. For example a summary * <code>"Text with **bold**"</code> is converted from Markdown to HTML as * <code>"Text with <strong>bold</strong> text"</code> and then * the default compiler with HTML escaping on turns this into * <code>"Text with &lt;strong&gt;bold&lt;/strong&gt; text"</code>. * Here, we disable escaping by setting the compiler to {@link Escapers#NONE * Escapers.NONE} */ @Override public Compiler processCompiler(Compiler compiler) { return compiler.withEscaper(Escapers.NONE); }
/** * Override the Mustache compiler configuration. * <p> * We don't want to have special characters escaped * * @param compiler the compiler. * @return the compiler to use. */ @Override public Mustache.Compiler processCompiler(Mustache.Compiler compiler) { compiler = super.processCompiler(compiler).emptyStringIsFalse(true); return compiler.withEscaper(Escapers.NONE); }
/** Returns a compiler that either does or does not escape HTML by default. Note: this * overrides any escaper set via {@link #withEscaper}. */ public Compiler escapeHTML (boolean escapeHTML) { return withEscaper(escapeHTML ? Escapers.HTML : Escapers.NONE); }
/** Returns a compiler that either does or does not escape HTML by default. Note: this * overrides any escaper set via {@link #withEscaper}. */ public Compiler escapeHTML (boolean escapeHTML) { return withEscaper(escapeHTML ? Escapers.HTML : Escapers.NONE); }