00001 /*************************************************************************** 00002 htmlgenerator.h - description 00003 ------------------- 00004 begin : Wed Nov 28 2001 00005 copyright : (C) 2001-2007 by Andre Simon 00006 email : andre.simon1@gmx.de 00007 ***************************************************************************/ 00008 00009 00010 /* 00011 This file is part of Highlight. 00012 00013 Highlight is free software: you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation, either version 3 of the License, or 00016 (at your option) any later version. 00017 00018 Highlight is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with Highlight. If not, see <http://www.gnu.org/licenses/>. 00025 */ 00026 00027 00028 00029 #ifndef HTMLGENERATOR_H 00030 #define HTMLGENERATOR_H 00031 00032 #include <string> 00033 00034 #include "codegenerator.h" 00035 00036 #include "stylecolour.h" 00037 #include "elementstyle.h" 00038 00039 namespace highlight 00040 { 00041 00052 class HtmlGenerator : public highlight::CodeGenerator 00053 { 00054 public: 00055 00056 HtmlGenerator(); 00057 00059 virtual ~HtmlGenerator() {}; 00060 00064 bool printExternalStyle ( const string &outFile ); 00065 00070 bool printIndexFile ( const vector<string> & fileList, const string &outPath ); 00071 00075 void setHTMLAttachAnchors ( bool b ) { attachAnchors = b; } 00076 00080 void setHTMLAnchorPrefix ( const string & prefix ) { anchorPrefix = prefix; } 00081 00085 void setHTMLOrderedList ( bool b ) { orderedList = b; } 00086 00090 void setHTMLInlineCSS ( bool b ) { useInlineCSS = b; } 00091 00095 void setHTMLEnclosePreTag ( bool b ) { enclosePreTag = b; } 00096 00100 void setHTMLClassName ( const string& name ) 00101 { 00102 cssClassName = name; 00103 } 00104 00105 protected: 00106 00107 string brTag, 00108 hrTag, 00109 idAttr, 00110 fileSuffix, 00111 cssClassName; 00112 00114 string styleDefinitionCache; 00115 00117 bool orderedList; 00118 00120 bool useInlineCSS; 00121 00123 bool enclosePreTag; 00124 00126 string getStyleDefinition(); 00127 00129 string readUserStyleDef(); 00130 00133 virtual string getHeaderStart ( const string &title ); 00134 00136 string getGeneratorComment(); 00137 00138 private: 00139 00142 virtual void insertLineNumber ( bool insertNewLine=true ); 00143 00146 string getHeader(); 00147 00149 void printBody(); 00150 00152 string getFooter(); 00153 00155 void initOutputTags(); 00156 00160 string getOpenTag ( const string& styleName ); 00161 00162 string getOpenTag ( const ElementStyle & elem ); 00163 00165 virtual string maskCharacter ( unsigned char ); 00166 00168 bool attachAnchors; 00169 00171 string anchorPrefix; 00172 00174 string getAttributes ( const string & elemName, const ElementStyle & elem ); 00175 00179 string getKeywordOpenTag ( unsigned int styleID ); 00180 00184 string getKeywordCloseTag ( unsigned int styleID ); 00185 00187 string getNewLine(); 00188 00189 string getMetaInfoOpenTag ( const TagInfo& info ); 00190 string getMetaInfoCloseTag(); 00191 }; 00192 00193 } 00194 00195 #endif