view trunk/src/docgen/misc/textutils.d @ 469:e562d455cbbe

Fixed latex regressions, added html file lists.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Wed, 31 Oct 2007 21:42:33 +0200
parents 4e5b35df3060
children e48a011e687a
line wrap: on
line source

/**
 * Author: Aziz Köksal & Jari-Matti Mäkelä
 * License: GPL3
 */
module docgen.misc.textutils;

// copied from Generate.d
char[] xml_escape(char[] text)
{
  char[] result;
  result.length = text.length;
  result.length = 0;
  foreach(c; text)
    switch(c)
    {
      case '<': result ~= "&lt;";  break;
      case '>': result ~= "&gt;";  break;
      case '&': result ~= "&amp;"; break;
      default:  result ~= c;
    }
  return result;
}

char[] plainTextHeading(char[] s) {
  char[] line;
  line.length = 80;
  line[] = "=";

  return s ~ \n ~ line[0..s.length].dup ~ \n ~ \n;
}

char[] plainTextHorizLine(int l = 80) {
  char[] line;
  line.length = 80;
  line[] = "-";
  
  return line[0..l].dup ~ \n;
}