/** * Transforms source code that's provided through a * <code>String</code> to highlighted syntax in XHTML and returns it * as a <code>String</code>. * <p>If the highlighting has to become a fragment, no CSS styles will be * generated. * * @param name The name of the source file. * @param in The input string that provides the source code that needs to * be transformed. * @param encoding The encoding that will be used to read and write the * text. * @param fragment <code>true</code> if the generated XHTML should be a * fragment; or <code>false</code> if it should be a complete page * or <code>false</code> if it should be a complete document * @return the highlighted source code as XHTML in a string * @see #highlight(String, InputStream, OutputStream, String, boolean) * @since 1.0 */ public String highlight(String name, String in, String encoding, boolean fragment) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); highlight(name, new StringBufferInputStream(in), out, encoding, fragment); return out.toString(encoding); }
/** * Transforms source code that's provided through a * <code>String</code> to highlighted syntax in XHTML and returns it * as a <code>String</code>. * <p>If the highlighting has to become a fragment, no CSS styles will be * generated. * * @param name The name of the source file. * @param in The input string that provides the source code that needs to * be transformed. * @param encoding The encoding that will be used to read and write the * text. * @param fragment <code>true</code> if the generated XHTML should be a * fragment; or <code>false</code> if it should be a complete page * or <code>false</code> if it should be a complete document * @return the highlighted source code as XHTML in a string * @see #highlight(String, InputStream, OutputStream, String, boolean) * @since 1.0 */ public String highlight(String name, String in, String encoding, boolean fragment) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); highlight(name, new ByteArrayInputStream(in.getBytes(encoding)), out, encoding, fragment); return out.toString(encoding); }