"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/src/core/xhtmlgenerator.cpp" (12 May 2020, 2986 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.

    1 /***************************************************************************
    2                      XHtmlGenerator.cpp  -  description
    3                              -------------------
    4     begin                : Wed Nov 28 2001
    5     copyright            : (C) 2001 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 #include "xhtmlgenerator.h"
   28 
   29 namespace highlight
   30 {
   31 
   32 XHtmlGenerator::XHtmlGenerator ()
   33 {
   34     fileSuffix=".xhtml";
   35     brTag="<br />";
   36     hrTag="<hr />";
   37     cssClassName="hl";
   38     setOutputType(XHTML);
   39 }
   40 
   41 string XHtmlGenerator::getHeaderStart ( const string &title )
   42 {
   43     ostringstream header;
   44     header << "<?xml version=\"1.0\"";
   45     if ( encodingDefined() ) {
   46         header << " encoding=\"" << encoding << "\"";
   47     }
   48     header << "?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\""
   49            << "  \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
   50            << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
   51            << "<head>\n<title>" << title << "</title>\n";
   52 
   53     return header.str();
   54 }
   55 
   56 
   57 string XHtmlGenerator::getHeader()
   58 {
   59     ostringstream os;
   60     os << getHeaderStart ( docTitle );
   61 
   62     if ( currentSyntax->highlightingEnabled() ) {
   63         if ( !useInlineCSS ) {
   64             if ( includeStyleDef ) {
   65                 os << "<style type=\"text/css\">\n";
   66                 os << "<![CDATA[\n";
   67                 os << getStyleDefinition();
   68                 os << CodeGenerator::readUserStyleDef();
   69                 os << "]]>\n";
   70                 os << "</style>\n";
   71             } else {
   72                 os << "<link rel=\"stylesheet\" type=\"text/css\" href=\""
   73                    << getStyleOutputPath()
   74                    << "\""
   75                    << "/"
   76                    << ">\n";
   77             }
   78             os << "</head>\n<body";
   79             if (!cssClassName.empty())
   80                 os << " class=\""<<cssClassName<<"\"";
   81             os << ">\n";
   82 
   83 
   84         } else {
   85             os << "</head>\n<body style=\""
   86                << "background-color:#"
   87                << ( docStyle.getBgColour().getRed ( HTML ) )
   88                << ( docStyle.getBgColour().getGreen ( HTML ) )
   89                << ( docStyle.getBgColour().getBlue ( HTML ) )
   90                << "\">\n";
   91         }
   92     }
   93     return os.str();
   94 }
   95 
   96 }