Mercurial > projects > dil
annotate trunk/src/docgen/misc/textutils.d @ 453:4e5b35df3060
Parsing bugfixes, cleaned up imports.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Thu, 25 Oct 2007 01:08:38 +0300 |
parents | 3f44c38bf870 |
children | e562d455cbbe |
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; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
12 foreach(c; text) |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
13 switch(c) |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
14 { |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
15 case '<': result ~= "<"; break; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
16 case '>': result ~= ">"; break; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
17 case '&': result ~= "&"; break; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
18 default: result ~= c; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
19 } |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
20 return result; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
21 } |
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 char[] plainTextHeading(char[] s) { |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
24 char[] line; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
25 line.length = 80; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
26 line[] = "="; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
27 |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
28 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
|
29 } |
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 char[] plainTextHorizLine(int l = 80) { |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
32 char[] line; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
33 line.length = 80; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
34 line[] = "-"; |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
35 |
3f44c38bf870
Page templates, more flexible writer interfaces, small fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
36 return line[0..l].dup ~ \n; |
453
4e5b35df3060
Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
451
diff
changeset
|
37 } |