ColorizerLibrary
A syntax colorizing control
Original Author: Jonathan de Halleux, dehalleux@pelikhan.com,
2003.
Modified by Eric Woodruff (Eric@EWoodruff.us) 11/2006. The original
Code Project article and code by Jonathan can be found at:
http://www.codeproject.com/csharp/highlightcs.asp.
Renders the code
You must specify a colorizing engine using SetSyntaxEngine
before calling this method
HTML writer
The syntax engine does the job.
Get or set the text to colorize
Code colorizer provides a flexible solution for colorizing code
Original Author: Jonathan de Halleux, dehalleux@pelikhan.com,
2003.
Modified by Eric Woodruff (Eric@EWoodruff.us) 11/2006. The original
Code Project article and code by Jonathan can be found at:
http://www.codeproject.com/csharp/highlightcs.asp.
Default constructor
Unless specified via the properties, the default language
and style files will be retrieved from the application
configuration file on first use.
There are two overloads for the constructor.
Constructor
XML syntax file name
XSL style file name
Converting to string
Returns the syntax and style in a string
Load the language file and preprocess it. Also loads the XSL file.
Call this method to reload the language files and reset
the colorizer to its default state.
Processes HTML and highlight code in
<code>...</code> and
<pre>...</pre> tags.
The HTML text to colorize
HTML with colorized code blocks
See highlight.xml for a list of available languages.
Loads the configuration from the App.config/Web.config and create a
CodeColorizer.
This is thrown if the
configuration file could not be loaded, if the
ColorizerLibrary/syntax node is not found, or if the
ColorizerLibrary/style node is not found.
This is used to strip a common amount of leading whitespace on all
lines of code in the block to colorize and to convert tabs to a
consistent number of spaces.
The text containing the lines to clean up.
The number of spaces to which tab characters
are converted.
This is used to number lines and/or add collapsible sections for
#region and #if/#else/#endif blocks based on the current settings.
The text containing the lines to modify.
Build the keyword family regular expressions.
This method creates regular expression that match a whole
keyword family and adds it as a parameter "regexp" to the
keywordlist node.
This builds regular expressions out of the context node
The language node.
The context node.
This method creates regular expressions that match all the
context rules and adds it as a parameter "regexp" to the context
node.
The regular expression string for the context node.
This is thrown if the
regular expression rule is missing the expression attribute, if the
keyword list could not be found, or if the keyword list family or
regular expression could not be found.
This precompiles regular expressions and search strings and
prepares rules attribute.
The context node
This prepares the syntax XML file for use.
This is thrown if the
highlight node could not be found in the configuration file.
This is used to find the rule that triggered the match.
The language node.
The context node.
The text that matched the context regular
expression
If the Regex finds a rule occurrence, this method is used
to find which rule has been triggered.
The node that triggered the match or null if no node is
found.
This is used to apply the context rules successively to the code
string that needs colorizing.
The language node.
The context node.
The code block to parse and convert.
Parent node that will contain the
parsed code.
This method uses the pre-computed regular expressions of
the context rules, rule matching, etc. The results are added to
the XML document in the parsedcodeNode.
This is thrown if a
rule match cannot be found or if a matching context node cannot
be found.
Create and populate an xml document with the corresponding parsed
language tree for highlighting.
The language node to use for parsing the
code.
Root tag (under parsed code) for the
generated xml tree.
The code to parse
Returns an document
containing the parsed nodes.
This method builds an XML tree containing context node.
Use an XSL file to render it.
This is thrown if the
language node does not contain any contexts or if there is no
default context node.
This is thrown if the
main node of the parsed code XML document cannot be created.
This method is used as the match evaluator for the main colorizer
regular expression
Full match
Replace a see tag with a marker and store it in the list
Replace a see tag marker with the next entry from the saved list
of tags.
The syntax file name
The style file name
This is used to set or get whether or not lines will be
numbered in code blocks without a numberLines attribute.
The default is false
This is used to set or get whether or not outlining of #region
and #if/#else#/endif blocks is enabled in blocks without an
outlining attribute.
The default is false. Note that if enabled, space for the
outline markers will only be reserved if the code contains any
collapsible regions.
This is used to set or get whether or not <see> tags
are preserved within the code.
The default is false to treat them as part of the colorized
code. If set to true, any <see> tags are preserved so
that they may be processed as normal HTML tags. This is useful when
using the code colorizer in conjunction with a documentation tool
such as the Sandcastle
Help File Builder.
This is used to set or get whether or not to use a default title
based on the language name if a title is not specified.
The default is true. If set to false, no title will appear
if one is not specified.
This is used to set or get the tab size override for the colorizer
for code blocks without a tabSize attribute and no tab size
defined in the syntax file for the selected language.
The default is eight.
This is used to set or get the text for the Copy link
The default is "Copy".
This is used to set or get the image URL for the Copy link.
The default is "CopyCode.gif". A copy of this file with
the same name suffixed with "_h" should exist to use as the image
when the link is highlighted (i.e. CopyCode_h.gif).
This is used to return a dictionary that maps the language IDs to
friendly names.
This is used to return a dictionary that maps the alternate IDs
to actual IDs present in the syntax file.
Constructor
The line number
The match
The nesting level
Constructor. This version assumes it's an #endif
The line number
The nesting level
The line number on which the region part occurs
This returns the nesting level for the entry
The region type
The description for the collapsed text
This returns true if this entry represents the start of a
region.
Some basic function helpers for xml creation.
Private constructor.
adds a CDATA child elem
node to append child
new child node name
CDATA value
If could not create child node
If could not create CDATA node
Adds or updates an attribute in the node
node to modify
Attribute name
Attribute value
Dictionary associating string to Regex
This implementation uses a
to store the Regex
objects.
Default constructor.
This returns the key name based on the IDs of the two specified
nodes.
The first node
The second node
There are two overloads for this method
This returns the key name based on the IDs of the three specified
nodes.
The first node
The second node
The third node
Retrieve the regular expression options from the language node
langue name
RegexOptions enumeration combination
Add a regex depending on two nodes
The language node
The sub-node
The regular expression string
This is thrown if a node
parameter is null or the regular expression is null.
This is thrown if a node
parameter does not have an 'id' attribute or if the regular
expression could not be created.
There are two overloads for this method
Add a regex depending on three nodes
The language node
The first sub-node
The second sub-node
The regular expression string
This is thrown if a node
parameter is null or the regular expression is null.
This is thrown if a node
parameter does not have an 'id' attribute or if the regular
expression could not be created.
Retrieves the regular expression out of 2 nodes
The language node
The sub-node
The regular expression
This is thrown if a node
parameter is null or the regular expression is null.
This is thrown if a node
parameter does not have an 'id' attribute.
Retrieves the regular expression out of 3 nodes
The language node
The first sub-node
The second sub-node
The regular expression
This is thrown if a node
parameter is null or the regular expression is null.
This is thrown if a node
parameter does not have an 'id' attribute.