Class SourceHighlighter


  • final class SourceHighlighter
    extends java.lang.Object
    Creates a highlighted output of a source file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String lang  
      private java.util.Locale locale  
    • Constructor Summary

      Constructors 
      Constructor Description
      SourceHighlighter​(java.util.Locale locale)
      Creates a new highlighter with default settings.
    • Field Detail

      • locale

        private final java.util.Locale locale
      • lang

        private java.lang.String lang
    • Constructor Detail

      • SourceHighlighter

        public SourceHighlighter​(java.util.Locale locale)
        Creates a new highlighter with default settings.
        Parameters:
        locale - locale for tooltip rendering
    • Method Detail

      • setLanguage

        public void setLanguage​(java.lang.String lang)
        Specifies the source language. This value might be used for syntax highlighting. Default is "java".
        Parameters:
        lang - source language identifier
      • render

        public void render​(HTMLElement parent,
                           ISourceNode source,
                           java.io.Reader contents)
                    throws java.io.IOException
        Highlights the given source file.
        Parameters:
        parent - parent HTML element
        source - highlighting information
        contents - contents of the source file
        Throws:
        java.io.IOException - problems while reading the source file or writing the output
      • renderCodeLine

        private void renderCodeLine​(HTMLElement pre,
                                    java.lang.String linesrc,
                                    ILine line,
                                    int lineNr)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • highlight

        HTMLElement highlight​(HTMLElement pre,
                              ILine line,
                              int lineNr)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • span

        private HTMLElement span​(HTMLElement parent,
                                 java.lang.String id,
                                 java.lang.String style1,
                                 java.lang.String style2,
                                 java.lang.String title,
                                 ICounter branches)
                          throws java.io.IOException
        Throws:
        java.io.IOException