annotate src/docgen/misc/textutils.d @ 806:bcb74c9b895c

Moved out files in the trunk folder to the root.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 09 Mar 2008 00:12:19 +0100
parents trunk/src/docgen/misc/textutils.d@e48a011e687a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
451
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
1 /**
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
2 * Author: Aziz Köksal & Jari-Matti Mäkelä
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
3 * License: GPL3
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
4 */
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
5 module docgen.misc.textutils;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
6
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
7 // copied from Generate.d
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
8 char[] xml_escape(char[] text)
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
9 {
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
10 char[] result;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
11 result.length = text.length;
469
e562d455cbbe Fixed latex regressions, added html file lists.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 453
diff changeset
12 result.length = 0;
451
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
13 foreach(c; text)
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
14 switch(c)
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
15 {
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
16 case '<': result ~= "&lt;"; break;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
17 case '>': result ~= "&gt;"; break;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
18 case '&': result ~= "&amp;"; break;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
19 default: result ~= c;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
20 }
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
21 return result;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
22 }
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
23
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
24 char[] plainTextHeading(char[] s) {
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
25 char[] line;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
26 line.length = 80;
470
e48a011e687a Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 469
diff changeset
27 line[] = '=';
451
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
28
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
29 return s ~ \n ~ line[0..s.length].dup ~ \n ~ \n;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
30 }
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
31
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
32 char[] plainTextHorizLine(int l = 80) {
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
33 char[] line;
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
34 line.length = 80;
470
e48a011e687a Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 469
diff changeset
35 line[] = '-';
451
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
36
3f44c38bf870 Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
37 return line[0..l].dup ~ \n;
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 451
diff changeset
38 }