"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/src/include/htmlgenerator.h" (12 May 2020, 5383 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "htmlgenerator.h": 3.53_vs_3.54.

    1 /***************************************************************************
    2                           htmlgenerator.h  -  description
    3                              -------------------
    4     begin                : Wed Nov 28 2001
    5     copyright            : (C) 2001-2015 by Andre Simon
    6     email                : a.simon@mailbox.org
    7  ***************************************************************************/
    8 
    9 
   10 /*
   11 This file is part of Highlight.
   12 
   13 Highlight is free software: you can redistribute it and/or modify
   14 it under the terms of the GNU General Public License as published by
   15 the Free Software Foundation, either version 3 of the License, or
   16 (at your option) any later version.
   17 
   18 Highlight is distributed in the hope that it will be useful,
   19 but WITHOUT ANY WARRANTY; without even the implied warranty of
   20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   21 GNU General Public License for more details.
   22 
   23 You should have received a copy of the GNU General Public License
   24 along with Highlight.  If not, see <http://www.gnu.org/licenses/>.
   25 */
   26 
   27 
   28 
   29 #ifndef HTMLGENERATOR_H
   30 #define HTMLGENERATOR_H
   31 
   32 #include <string>
   33 
   34 #include "codegenerator.h"
   35 
   36 #include "stylecolour.h"
   37 #include "elementstyle.h"
   38 
   39 namespace highlight
   40 {
   41 
   42 /**
   43    \brief This class generates HTML.
   44 
   45    It contains information about the resulting document structure (document
   46    header and footer), the colour system, white space handling and text
   47    formatting attributes.
   48 
   49 * @author Andre Simon
   50 */
   51 
   52 class HtmlGenerator  : public highlight::CodeGenerator
   53 {
   54 public:
   55 
   56     HtmlGenerator();
   57 
   58     /** Destructor, virtual as it is base for xhtmlgenerator*/
   59     virtual ~HtmlGenerator() {};
   60 
   61     /** Print style definitions to external file
   62      \param outFile Path of external style definition
   63      */
   64     bool printExternalStyle ( const string &outFile );
   65 
   66     /** Print index file with all input file names
   67       \param fileList List of output file names
   68       \param outPath Output path
   69     */
   70     bool printIndexFile ( const vector<string> & fileList, const string &outPath );
   71 
   72     /**
   73       \param  b set true if anchors should be attached to line numbers
   74     */
   75     void setHTMLAttachAnchors ( bool b )
   76     {
   77         attachAnchors = b;
   78     }
   79 
   80     /**
   81       \param  prefix anchor prefix
   82     */
   83     void setHTMLAnchorPrefix ( const string & prefix )
   84     {
   85         anchorPrefix = prefix;
   86     }
   87 
   88     /**
   89       \param  b if true line numbers should be replaced by list items
   90     */
   91     void setHTMLOrderedList ( bool b ) ;
   92 
   93     /**
   94       \param  b if true CSS formatting will be inserted into each tag
   95     */
   96     void setHTMLInlineCSS ( bool b )
   97     {
   98         useInlineCSS = b;
   99     }
  100 
  101     /**
  102       \param  b if true fragmented output will be enclosed in pre tag
  103     */
  104     void setHTMLEnclosePreTag ( bool b )
  105     {
  106         enclosePreTag = b;
  107     }
  108 
  109     /**
  110       \param name CSS Class name
  111     */
  112     void setHTMLClassName ( const string& name )
  113     {
  114         cssClassName  = (StringTools::change_case ( name ) =="none") ? "" : name;
  115     }
  116 
  117 protected:
  118 
  119     string brTag,       ///< break tag
  120            hrTag,       ///< horizontal ruler tag
  121            fileSuffix,   ///< filename extension
  122            cssClassName; ///< css class name prefix
  123 
  124     /** caches style definition */
  125     string styleDefinitionCache;
  126 
  127     /** line count should be replaced by ordered list*/
  128     bool orderedList;
  129 
  130     /** CSS definition should be outputted inline */
  131     bool useInlineCSS;
  132 
  133     /** pre tag should be outputted in fragment mode*/
  134     bool enclosePreTag;
  135 
  136     /** \return CSS definition */
  137     string  getStyleDefinition();
  138 
  139     /** \return Content of user defined style file */
  140     string readUserStyleDef();
  141 
  142     /** \param title Dociment title
  143         \return Start of file header */
  144     virtual string getHeaderStart ( const string &title );
  145 
  146     /** \return Comment with program information */
  147     string getGeneratorComment();
  148 
  149 private:
  150 
  151     /** insert line number in the beginning of the new line
  152     */
  153     virtual void insertLineNumber ( bool insertNewLine=true );
  154 
  155     /** add Lua state variables specific to the output format */
  156    // virtual void addSpecificVars();
  157     
  158     /** Print document header
  159     */
  160     string getHeader();
  161 
  162     /** Print document body*/
  163     void printBody();
  164 
  165     /** Print document footer*/
  166     string getFooter();
  167 
  168     /** initialize tags in specific format according to colouring information provided in DucumentStyle */
  169     void initOutputTags();
  170 
  171     /**  \param styleName Style name
  172          \return Opening tag of the given style
  173     */
  174     string getOpenTag ( const string& styleName );
  175 
  176     string getOpenTag ( const ElementStyle& elem );
  177 
  178     /** \return escaped character*/
  179     virtual string maskCharacter ( unsigned char );
  180 
  181     /** test if anchors should be applied to line numbers*/
  182     bool attachAnchors;
  183 
  184     /**Optional anchor prefix */
  185     string anchorPrefix;
  186 
  187     /**\return text formatting attributes in HTML format */
  188     string  getAttributes ( const string & elemName, const ElementStyle & elem );
  189 
  190     /**  \param styleID Style ID
  191          \return Opening tag of the given style
  192     */
  193     string getKeywordOpenTag ( unsigned int styleID );
  194 
  195     /**  \param styleID Style ID
  196          \return Closing tag of the given style
  197     */
  198     string getKeywordCloseTag ( unsigned int styleID );
  199 
  200     /** @return Newline string */
  201     string getNewLine();
  202 };
  203 
  204 }
  205 
  206 #endif