comparison src/tutorial.sml @ 1497:0b639858200b

Tutorial tweaks
author Adam Chlipala <adam@chlipala.net>
date Fri, 15 Jul 2011 18:45:03 -0400
parents 3010472edf44
children 8c32c7191bf0
comparison
equal deleted inserted replaced
1496:3010472edf44 1497:0b639858200b
52 let 52 let
53 val (befor, after) = Substring.splitl (fn ch => ch <> #"&") source 53 val (befor, after) = Substring.splitl (fn ch => ch <> #"&") source
54 in 54 in
55 if Substring.isEmpty after then 55 if Substring.isEmpty after then
56 TextIO.outputSubstr (outf, source) 56 TextIO.outputSubstr (outf, source)
57 else if Substring.size after >= 8 andalso Substring.string (Substring.slice (after, 1, SOME 7)) = "amp;lt;" then 57 else if Substring.size after >= 4 andalso Substring.string (Substring.slice (after, 1, SOME 3)) = "lt;" then
58 (TextIO.outputSubstr (outf, befor); 58 (TextIO.outputSubstr (outf, befor);
59 TextIO.output (outf, "<"); 59 TextIO.output (outf, "<");
60 proseLoop (Substring.slice (after, 8, NONE))) 60 proseLoop (Substring.slice (after, 4, NONE)))
61 else if Substring.size after >= 4 andalso Substring.string (Substring.slice (after, 1, SOME 3)) = "gt;" then 61 else if Substring.size after >= 4 andalso Substring.string (Substring.slice (after, 1, SOME 3)) = "gt;" then
62 (TextIO.outputSubstr (outf, befor); 62 (TextIO.outputSubstr (outf, befor);
63 TextIO.output (outf, ">"); 63 TextIO.output (outf, ">");
64 proseLoop (Substring.slice (after, 4, NONE))) 64 proseLoop (Substring.slice (after, 4, NONE)))
65 else if Substring.size after >= 5 andalso Substring.string (Substring.slice (after, 1, SOME 4)) = "amp;" then 65 else if Substring.size after >= 5 andalso Substring.string (Substring.slice (after, 1, SOME 4)) = "amp;" then
73 fun loop source = 73 fun loop source =
74 let 74 let
75 val (befor, after) = Substring.position "<span class=\"comment-delimiter\">(* </span><span class=\"comment\">" source 75 val (befor, after) = Substring.position "<span class=\"comment-delimiter\">(* </span><span class=\"comment\">" source
76 in 76 in
77 if Substring.isEmpty after then 77 if Substring.isEmpty after then
78 let 78 TextIO.outputSubstr (outf, source)
79 val (befor, after) = Substring.position "<span class=\"comment-delimiter\">(** </span><span class=\"comment\">" source
80 in
81 if Substring.isEmpty after then
82 TextIO.outputSubstr (outf, source)
83 else
84 let
85 val (befor', after) = Substring.position " </span><span class=\"comment-delimiter\">*)</span>"
86 (Substring.slice (after, 65, NONE))
87 in
88 if Substring.isEmpty after then
89 TextIO.outputSubstr (outf, source)
90 else
91 (TextIO.outputSubstr (outf, befor);
92 TextIO.output (outf, "<h2>");
93 proseLoop befor';
94 TextIO.output (outf, "</h2>");
95 loop (Substring.slice (after, 49, NONE)))
96 end
97 end
98 else 79 else
99 let 80 let
100 val (befor', after) = Substring.position " </span><span class=\"comment-delimiter\">*)</span>" 81 val (befor', after) = Substring.position " </span><span class=\"comment-delimiter\">*)</span>"
101 (Substring.slice (after, 64, NONE)) 82 (Substring.slice (after, 64, NONE))
102 in 83 in
103 if Substring.isEmpty after then 84 if Substring.isEmpty after then
104 TextIO.outputSubstr (outf, source) 85 TextIO.outputSubstr (outf, source)
105 else 86 else
106 (TextIO.outputSubstr (outf, befor); 87 (TextIO.outputSubstr (outf, befor);
107 TextIO.output (outf, "<div class=\"prose\">"); 88 TextIO.output (outf, "</pre>");
108 proseLoop befor'; 89 if Substring.size befor' >= 1 andalso Substring.sub (befor', 0) = #"*" then
109 TextIO.output (outf, "</div>"); 90 (TextIO.output (outf, "<h2>");
91 proseLoop (Substring.slice (befor', 2, NONE));
92 TextIO.output (outf, "</h2>"))
93 else
94 (TextIO.output (outf, "<div class=\"prose\">");
95 proseLoop befor';
96 TextIO.output (outf, "</div>"));
97 TextIO.output (outf, "<pre>");
110 loop (Substring.slice (after, 49, NONE))) 98 loop (Substring.slice (after, 49, NONE)))
111 end 99 end
112 end 100 end
113 in 101 in
114 if Substring.isEmpty after then 102 if Substring.isEmpty after then
127 TextIO.output (outf, "\th2 {\n"); 115 TextIO.output (outf, "\th2 {\n");
128 TextIO.output (outf, "\t\tfont-family: Arial;\n"); 116 TextIO.output (outf, "\t\tfont-family: Arial;\n");
129 TextIO.output (outf, "\t\tfont-size: 20pt;\n"); 117 TextIO.output (outf, "\t\tfont-size: 20pt;\n");
130 TextIO.output (outf, "\t\tbackground-color: #99FF99;\n"); 118 TextIO.output (outf, "\t\tbackground-color: #99FF99;\n");
131 TextIO.output (outf, "\t\tpadding: 5px;\n"); 119 TextIO.output (outf, "\t\tpadding: 5px;\n");
120 TextIO.output (outf, "\t}\n");
121 TextIO.output (outf, "\ta:link {\n");
122 TextIO.output (outf, "\t\ttext-decoration: underline;\n");
123 TextIO.output (outf, "\t\tcolor: blue;\n");
124 TextIO.output (outf, "\t}\n");
125 TextIO.output (outf, "\ta:visited {\n");
126 TextIO.output (outf, "\t\ttext-decoration: underline;\n");
127 TextIO.output (outf, "\t\tcolor: red;\n");
132 TextIO.output (outf, "\t}\n"); 128 TextIO.output (outf, "\t}\n");
133 TextIO.output (outf, "-->\n"); 129 TextIO.output (outf, "-->\n");
134 TextIO.output (outf, "</style>\n"); 130 TextIO.output (outf, "</style>\n");
135 TextIO.output (outf, "<title>"); 131 TextIO.output (outf, "<title>");
136 TextIO.output (outf, title); 132 TextIO.output (outf, title);
285 ^ "(add-to-list 'load-path \\\"" 281 ^ "(add-to-list 'load-path \\\""
286 ^ Config.sitelisp 282 ^ Config.sitelisp
287 ^ "/\\\") " 283 ^ "/\\\") "
288 ^ "(load \\\"urweb-mode-startup\\\") " 284 ^ "(load \\\"urweb-mode-startup\\\") "
289 ^ "(urweb-mode) " 285 ^ "(urweb-mode) "
290 ^ "(find-file \\\"/tmp/final.ur\\\") " 286 ^ "(find-file \\\"/tmp/final2.ur\\\") "
291 ^ "(switch-to-buffer (htmlize-buffer)) " 287 ^ "(switch-to-buffer (htmlize-buffer)) "
292 ^ "(write-file \\\"/tmp/final.html\\\") " 288 ^ "(write-file \\\"/tmp/final.html\\\") "
293 ^ "(kill-emacs))\"" 289 ^ "(kill-emacs))\""
294 in 290 in
295 eatNls befor; 291 eatNls befor;
296 TextIO.closeOut outf; 292 TextIO.closeOut outf;
293 ignore (OS.Process.system "sed -e 's/&lt;/</g;s/&amp;/\\&/g' </tmp/final.ur >/tmp/final2.ur");
297 ignore (OS.Process.system cmd); 294 ignore (OS.Process.system cmd);
298 fixupFile (fname, title) 295 fixupFile (fname, title)
299 end 296 end
300 end 297 end
301 end 298 end