Changeset 178


Ignore:
Timestamp:
Sep 2, 2006, 7:06:23 AM (13 years ago)
Author:
Peter Johansson
Message:

fixes #77 text to html translator

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/html_utility.cc

    r177 r178  
    4545  }
    4646
     47
     48 
     49  void html(std::istream& is, std::ostream& os, char delim)
     50  {
     51    char c;
     52    while (true){
     53      is.get(c);
     54      if (c==delim || !is.good()){
     55        return;
     56      }
     57      if (c=='"')
     58        os << '\"';
     59      else if (c=='\'')
     60        os << "\'";
     61      else if (c=='\n')
     62        os << "<br/>";
     63      else if (c=='<')
     64        os << "&lt;";
     65      else if (c=='>')
     66        os << "&gt;";
     67      else if (c=='&')
     68        os << "&amp;";
     69      else if (c=='\t')
     70        os << "&nbsp;&nbsp;";
     71      else
     72        os << c;
     73    }
     74  }
     75 
    4776
    4877  void print_css(std::ostream& s)
  • trunk/lib/html_utility.h

    r177 r178  
    2525*/
    2626
    27 #include <algorithm>
    28 #include <functional>
     27#include <iostream>
     28#include <fstream>
    2929#include <iosfwd>
    3030#include <string>
    31 #include <utility>
    32 #include <vector>
    33 
    34 #include <sys/stat.h>
    3531
    3632namespace theplu{
     
    5046
    5147  ///
     48  /// Function translating text to html format. Most character are
     49  /// just passing through (unary operation). The exceptions are:
     50  /// " becomes \"
     51  /// ' becomes \'
     52  /// \n becomes <br/>
     53  /// < becomes &lt;
     54  /// > becomes &gt;
     55  /// & becomes &amp;
     56  /// \t becomes &nbsp; &nbsp;
     57  ///
     58  void html(std::istream&, std::ostream&, char delim='\n');
     59
     60  ///
    5261  /// @printing cascading style sheet to stream @a s.
    5362  ///
Note: See TracChangeset for help on using the changeset viewer.