Debian Codegraph @

terps/tads/tads3/test/data/spec2html.t

raw
1 #include <tads.h>
2
3 main(args)
4 {
5 local strs = [
6 'This is a test of the specialsToHtml() conversion process.',
7 'These first strings have no special characters, but we\'ll get '
8 + 'to that presently.',
9 'We have some \ \ quoted spaces \ \ in this one.',
10 'Mixing \ \ quoted and \ \ \ unquoted spaces.',
11 'This one has some <q>quote <q>markups</q> end quote</q>.',
12 'Let\'s try <q>quote ',
13 '<q>markups</q>',
14 'end quote</q> across elements!',
15 'Some newline conversions: newline\nblank\bthree newlines\n\n\n'
16 + 'three blanks\b\b\bnewline-blank-newline-blank\n\b\n\b',
17 'A tag across lines: <a href="test',
18 '<link>">hyperlinked text here</',
19 'a>',
20 'Caps flag: \^<q>in quotes</q>, nocaps: \v<a href=\'link',
21 '-<across>-lines\'>ALL CAPS</a>',
22 'BR with HEIGHT attributes... first, height=0<br height=0>\n'
23 + 'Now height=1<br height=1>'
24 + 'And height=2<br height=2>'
25 + 'And now a height=0 at the start of a line\n<br height=0>'
26 + 'And height=2 at start of line\n<br height=2>',
27 'Tabs:\none\ttwo\tthree\tfour\tfive\tsix\n'
28 + '\ta\tb\tc\td\n'
29 + 'hello\tgoodbye\tthat should be all'
30 ];
31
32 local st = new TadsObject();
33 foreach (local str in strs)
34 {
35 "Src:\ \ <<quoteAll(str)>><br>
36 Disp: <<str.htmlify()>><br>
37 s2h:\ \ <<quoteAll(str.specialsToHtml(st))>><br><br>";
38 }
39 }
40
41 quoteAll(str)
42 {
43 return str.htmlify().findReplace(
44 ['\n', '\b', '\t', ' ', '\ ', '\v', '\^'],
45 ['\\n', '\\b', '\\t', '\ ', '\\\ ', '\\v', '\\^']);
46 }