public abstract class XhtmlRenderer extends Object implements Renderer
Constructor and Description |
---|
XhtmlRenderer() |
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getCssClass(int style)
Looks up the CSS class identifier that corresponds to the syntax style.
|
protected String |
getCssClassDefinitions()
Returns all the CSS class definitions that should appear within the
style XHTML tag. |
protected abstract Map |
getDefaultCssStyles()
Returns a map of all the CSS styles that the renderer requires,
together with default definitions for them.
|
protected abstract ExplicitStateHighlighter |
getHighlighter()
Returns the language-specific highlighting lexer that should be used
|
protected String |
getXhtmlFooter()
Returns the XHTML footer that nicely finishes the file after the
highlighted source code.
|
protected String |
getXhtmlHeader(String name)
Returns the XHTML header that preceedes the highlighted source code.
|
protected String |
getXhtmlHeaderFragment(String name)
Returns the XHTML header that preceedes the highlighted source code for
a fragment.
|
void |
highlight(String name,
InputStream in,
OutputStream out,
String encoding,
boolean fragment)
Transforms source code that's provided through an
InputStream to highlighted syntax in XHTML and writes it
back to an OutputStream . |
String |
highlight(String name,
String in,
String encoding,
boolean fragment)
Transforms source code that's provided through a
String to highlighted syntax in XHTML and returns it
as a String . |
public void highlight(String name, InputStream in, OutputStream out, String encoding, boolean fragment) throws IOException
InputStream
to highlighted syntax in XHTML and writes it
back to an OutputStream
.
If the highlighting has to become a fragment, no CSS styles will be generated.
For complete documents, there's a collection of default styles that
will be included. It's possible to override these by changing the
provided jhighlight.properties
file. It's best to look at
this file in the JHighlight archive and modify the styles that are
there already.
highlight
in interface Renderer
name
- The name of the source file.in
- The input stream that provides the source code that needs to
be transformed.out
- The output stream to which to resulting XHTML should be
written.encoding
- The encoding that will be used to read and write the
text.fragment
- true
if the generated XHTML should be a
fragment; or false
if it should be a complete pageIOException
highlight(String, String, String, boolean)
public String highlight(String name, String in, String encoding, boolean fragment) throws IOException
String
to highlighted syntax in XHTML and returns it
as a String
.
If the highlighting has to become a fragment, no CSS styles will be generated.
highlight
in interface Renderer
name
- The name of the source file.in
- The input string that provides the source code that needs to
be transformed.encoding
- The encoding that will be used to read and write the
text.fragment
- true
if the generated XHTML should be a
fragment; or false
if it should be a complete page
or false
if it should be a complete documentIOException
highlight(String, InputStream, OutputStream, String, boolean)
protected abstract Map getDefaultCssStyles()
protected abstract String getCssClass(int style)
style
- The syntax style.null
if the syntax style isn't supported.
protected abstract ExplicitStateHighlighter getHighlighter()
protected String getCssClassDefinitions()
style
XHTML tag.
This should support all the classes that the
getCssClass(int)
method returns.
getCssClass(int)
protected String getXhtmlHeader(String name)
It will integrate the CSS class definitions and use the source's name to indicate in XHTML which file has been highlighted.
name
- The name of the source file.protected String getXhtmlHeaderFragment(String name)
name
- The name of the source file.protected String getXhtmlFooter()
Copyright © 2011–2021. All rights reserved.