private Renderer getRenderer(String mimeType) { MediaType mt = MediaType.parse(mimeType); String type = TYPES_TO_RENDERER.get(mt); if (type == null) { throw new RuntimeException("unparseable content type " + mimeType); } return XhtmlRendererFactory.getRenderer(type); }
String encoding) throws IOException { Renderer jspRenderer = XhtmlRendererFactory.getRenderer(rendererName); if (jspRenderer == null) { return null; jspRenderer.highlight(name, input, bos, encoding, true);
Renderer renderer = getRenderer(type.toString()); String codeAsHtml = renderer.highlight(name, out.toString(), charset.name(), false);
throws IOException ExplicitStateHighlighter highlighter = getHighlighter(); w.write(getXhtmlHeaderFragment(name)); w.write(getXhtmlHeader(name)); newline) css_class = getCssClass(style); if (!fragment) w.write(getXhtmlFooter());
/** * 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); }
" <link rel=\"Help\" href=\"http://jhighlight.dev.java.net\" />\n" + " <style type=\"text/css\">\n" + getCssClassDefinitions() + " </style>\n" + "</head>\n" +
private static void highlightFile(String name, File in, File out, String encoding, boolean fragment, boolean verbose) throws IOException { out.getParentFile().mkdirs(); if (verbose) { System.out.print(name + " ... "); } XhtmlRendererFactory.getRenderer(FileUtils.getExtension(name)) .highlight(name, in.toURL().openStream(), new FileOutputStream(out), encoding, fragment); if (verbose) { System.out.println("done."); } } }
private Renderer getRenderer(String mimeType) { MediaType mt = MediaType.parse(mimeType); String type = TYPES_TO_RENDERER.get(mt); if (type == null) { throw new RuntimeException("unparseable content type " + mimeType); } return XhtmlRendererFactory.getRenderer(type); }
throws IOException ExplicitStateHighlighter highlighter = getHighlighter(); w.write(getXhtmlHeaderFragment(name)); w.write(getXhtmlHeader(name)); newline) css_class = getCssClass(style); if (!fragment) w.write(getXhtmlFooter());
Renderer renderer = getRenderer(type.toString()); String codeAsHtml = renderer.highlight(name, out.toString(), charset.name(), false);
/** * 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); }
" <link rel=\"Help\" href=\"http://jhighlight.dev.java.net\" />\n" + " <style type=\"text/css\">\n" + getCssClassDefinitions() + " </style>\n" + "</head>\n" +
private static void highlightFile(String name, File in, File out, String encoding, boolean fragment, boolean verbose) throws IOException { out.getParentFile().mkdirs(); if (verbose) { System.out.print(name + " ... "); } XhtmlRendererFactory.getRenderer(FileUtils.getExtension(name)) .highlight(name, in.toURL().openStream(), new FileOutputStream(out), encoding, fragment); if (verbose) { System.out.println("done."); } } }
private Renderer getRenderer(String mimeType) { MediaType mt = MediaType.parse(mimeType); String type = TYPES_TO_RENDERER.get(mt); if (type == null) { throw new RuntimeException("unparseable content type " + mimeType); } return XhtmlRendererFactory.getRenderer(type); }
XhtmlRendererFactory.getRenderer( highlightFilter ).highlight( file.getName(), new FileInputStream( file ), new FileOutputStream( destinationFilePath ), Charset.forName( outputEncoding ).name(),
public Renderer getRenderer(String type) { Renderer renderer = com.uwyn.jhighlight.renderer.XhtmlRendererFactory.getRenderer(type); if (renderer == null) { Object object = classNames.get(type.toLowerCase()); if (object != null) { String className = object.toString(); try { Class<?> class1 = Class.forName(className); Object newInstance = class1.newInstance(); if (newInstance instanceof Renderer) { return (Renderer) newInstance; } } catch (Exception e) { e.printStackTrace(); } } } return renderer; }
public static String highlightStream(String name, InputStream input, String rendererName, String encoding) throws IOException { Renderer jspRenderer = XhtmlRendererFactory.getRenderer(rendererName); if (jspRenderer != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); jspRenderer.highlight(name, input, bos, encoding, true);
extension.endsWith("s")) renderer = XhtmlRendererFactory.getRenderer(extension.substring(0, extension.length()-1)); renderer.highlight(http_request.getServletPath().substring(1), is, os, encoding, false);
extension.endsWith("s")) renderer = XhtmlRendererFactory.getRenderer(extension.substring(0, extension.length()-1)); renderer.highlight(name, is, os, encoding, false);
Renderer renderer = XhtmlRendererFactory.getRenderer(type); if (renderer != null) renderer.highlight(source, resourceAsStream, output, "UTF-8", true); return output.toString("UTF-8");