// -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*- // vi:set ts=4 sts=4 sw=4 noet : // // Copyright 2010, 2011 wkhtmltopdf authors // // This file is part of wkhtmltopdf. // // wkhtmltopdf is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // wkhtmltopdf is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with wkhtmltopdf. If not, see . #include "outputter.hh" #include #if QT_VERSION >= 0x050000 #define S(x) x.toHtmlEscaped().toUtf8().constData() #else #define S(x) Qt::escape(x).toUtf8().constData() #endif class HtmlOutputter: public Outputter { private: FILE * fd; bool ordered; public: HtmlOutputter(FILE * _): fd(_) { fprintf(fd, "\n" "\n" "\n" " \n" " wkhtmltopdf - Manual\n" " \n" ""); } ~HtmlOutputter() { fprintf(fd,"\n"); } void beginSection(const QString & name) { fprintf(fd, "

%s

\n", S(name), S(name)); } void endSection() { } void beginParagraph() { fprintf(fd,"

"); } void endParagraph() { fprintf(fd,"

\n"); } void text(const QString & t) { fprintf(fd, "%s", S(t)); } void sectionLink(const QString & s) { fprintf(fd, "%s", S(s), S(s)); } void bold(const QString & t) { fprintf(fd, "%s", S(t)); } void italic(const QString & t) { fprintf(fd, "%s", S(t)); } void link(const QString & t) { fprintf(fd, "%s", S(t),S(t)); } void verbatim(const QString & t) { fprintf(fd, "
%s
", S(t)); } void beginList(bool o) { ordered = o; fprintf(fd, ordered?"
    ":"
      "); } void endList() { fprintf(fd, ordered?"
":""); } void listItem(const QString & s) { fprintf(fd, "
  • %s
  • \n", S(s)); } void beginSwitch() { fprintf(fd, "\n"); } void cswitch(const ArgHandler * h) { fprintf(fd, "\n",S(h->getDesc())); } void endSwitch() { fprintf(fd, "
    "); if (h->shortSwitch) fprintf(fd, "-%c,",h->shortSwitch); fprintf(fd, "--%s%s",S(h->longName), (h->qthack?"*":"")); foreach (const QString & arg, h->argn) fprintf(fd, "<%s> ",S(arg)); fprintf(fd, "%s
    \n"); fprintf(fd, "

    Items marked * are only available using patched QT.

    "); } }; /*! Create a Html outputter \param fd A file description to output to */ Outputter * Outputter::html(FILE * fd) { return new HtmlOutputter(fd); }