1 /*************************************************************************** 2 latexgenerator.h - description 3 ------------------- 4 begin : Mit Jul 24 2002 5 copyright : (C) 2002-2021 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 #ifndef LATEXGENERATOR_H 29 #define LATEXGENERATOR_H 30 31 #include <string> 32 #include <iostream> 33 #include <sstream> 34 35 #include "codegenerator.h" 36 #include "version.h" 37 #include "charcodes.h" 38 39 40 namespace highlight 41 { 42 43 /** 44 \brief This class generates LaTeX. 45 46 It contains information about the resulting document structure (document 47 header and footer), the colour system, white space handling and text 48 formatting attributes. 49 50 * @author Andre Simon 51 */ 52 53 class LatexGenerator : public highlight::CodeGenerator 54 { 55 public: 56 LatexGenerator(); 57 ~LatexGenerator(); 58 59 /** set replace quotes flag 60 \param b flag 61 */ setLATEXReplaceQuotes(bool b)62 void setLATEXReplaceQuotes ( bool b ) 63 { 64 replaceQuotes = b; 65 } 66 67 /** set disable babel shorthand flag 68 \param b flag 69 */ setLATEXNoShorthands(bool b)70 void setLATEXNoShorthands ( bool b ) 71 { 72 disableBabelShortHand = b; 73 } 74 75 /** set pretty symbols flag 76 \param b flag 77 */ setLATEXPrettySymbols(bool b)78 void setLATEXPrettySymbols ( bool b ) 79 { 80 prettySymbols = b; 81 } 82 83 /** set Beamer mode flag 84 \param b flag 85 */ setLATEXBeamerMode(bool b)86 void setLATEXBeamerMode ( bool b ) 87 { 88 beamerMode = b; 89 newLineTag = beamerMode ? "\n\n" : "\\\\\n"; 90 longLineTag = "\\hspace*{\\fill}" + newLineTag; 91 } 92 93 private: 94 95 /** prints document header 96 */ 97 string getHeader(); 98 99 /** Prints document footer*/ 100 string getFooter(); 101 102 /** Prints document body*/ 103 void printBody(); 104 105 /** initialize tags in specific format according to colouring information provided in DucumentStyle */ 106 void initOutputTags(); 107 108 string styleDefinitionCache; 109 string longLineTag; 110 111 /** \return escaped character*/ 112 virtual string maskCharacter ( unsigned char ); 113 114 /**\return text formatting attributes in LaTeX format */ 115 string getAttributes ( const string & elemName, 116 const ElementStyle & elem ); 117 118 /** test if double quotes should be replaced by \dq{} */ 119 bool replaceQuotes; 120 121 /** test if Babel shorthand for " should be disabled */ 122 bool disableBabelShortHand; 123 124 /** test if symbols like <,>,{,},~ should be replaced by nicer definitions */ 125 bool prettySymbols; 126 127 bool beamerMode; 128 129 string getNewLine(); 130 131 string getStyleDefinition(); 132 133 string getKeywordOpenTag ( unsigned int styleID ); 134 string getKeywordCloseTag ( unsigned int styleID ); 135 }; 136 137 } 138 139 #endif 140