Mercurial > urweb
comparison src/demo.sml @ 382:aa2edbd47041
Generating fontified source files
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 19 Oct 2008 14:51:12 -0400 |
parents | 1fe85b58c9ba |
children | 49c95753bf3b |
comparison
equal
deleted
inserted
replaced
381:1fe85b58c9ba | 382:aa2edbd47041 |
---|---|
138 (TextIO.output (out, "<html><head>\n<title>"); | 138 (TextIO.output (out, "<html><head>\n<title>"); |
139 TextIO.output (out, name); | 139 TextIO.output (out, name); |
140 TextIO.output (out, "</title>\n</head><body>\n\n<h1>"); | 140 TextIO.output (out, "</title>\n</head><body>\n\n<h1>"); |
141 TextIO.output (out, name); | 141 TextIO.output (out, name); |
142 TextIO.output (out, "</h1>\n\n<center>[ <a target=\"showcase\" href=\""); | 142 TextIO.output (out, "</h1>\n\n<center>[ <a target=\"showcase\" href=\""); |
143 TextIO.output (out, prefix); | |
144 TextIO.output (out, "/"); | |
145 TextIO.output (out, name); | |
146 TextIO.output (out, "/main\">Application</a>"); | |
147 TextIO.output (out, " | <a target=\"showcase\" href=\""); | |
143 TextIO.output (out, urp); | 148 TextIO.output (out, urp); |
144 TextIO.output (out, ".html\"><tt>"); | 149 TextIO.output (out, ".html\"><tt>"); |
145 TextIO.output (out, urp); | 150 TextIO.output (out, urp); |
146 TextIO.output (out, "</tt></a>"); | 151 TextIO.output (out, "</tt></a>"); |
147 app (fn file => | 152 app (fn file => |
238 | SOME file => | 243 | SOME file => |
239 let | 244 let |
240 fun doit f = | 245 fun doit f = |
241 f (OS.Path.joinDirFile {dir = dirname, | 246 f (OS.Path.joinDirFile {dir = dirname, |
242 file = file}, | 247 file = file}, |
243 OS.Path.joinDirFile {dir = outDir, | 248 OS.Path.mkAbsolute |
244 file = OS.Path.joinBaseExt {base = file, | 249 {relativeTo = OS.FileSys.getDir (), |
245 ext = SOME "html"}}) | 250 path = OS.Path.joinDirFile {dir = outDir, |
251 file = OS.Path.joinBaseExt {base = file, | |
252 ext = SOME "html"}}}) | |
253 | |
254 fun highlight () = | |
255 doit (fn (src, html) => | |
256 let | |
257 val cmd = "emacs --eval \"(progn " | |
258 ^ "(global-font-lock-mode t) " | |
259 ^ "(add-to-list 'load-path \\\"" | |
260 ^ Config.sitelisp | |
261 ^ "/\\\") " | |
262 ^ "(load \\\"urweb-mode-startup\\\") " | |
263 ^ "(urweb-mode) " | |
264 ^ "(find-file \\\"" | |
265 ^ src | |
266 ^ "\\\") " | |
267 ^ "(switch-to-buffer (htmlize-buffer)) " | |
268 ^ "(write-file \\\"" | |
269 ^ html | |
270 ^ "\\\") " | |
271 ^ "(kill-emacs))\"" | |
272 in | |
273 print (">>> " ^ cmd ^ "\n"); | |
274 ignore (OS.Process.system cmd) | |
275 end) | |
246 in | 276 in |
247 case OS.Path.ext file of | 277 case OS.Path.ext file of |
248 SOME "urp" => | 278 SOME "urp" => |
249 doit (fn (src, html) => | 279 doit (fn (src, html) => |
250 let | 280 let |
266 TextIO.output (out, "</pre>\n\n</body></html>"); | 296 TextIO.output (out, "</pre>\n\n</body></html>"); |
267 | 297 |
268 TextIO.closeIn inf; | 298 TextIO.closeIn inf; |
269 TextIO.closeOut out | 299 TextIO.closeOut out |
270 end) | 300 end) |
301 | SOME "urs" => highlight () | |
302 | SOME "ur" => highlight () | |
271 | _ => (); | 303 | _ => (); |
272 loop () | 304 loop () |
273 end | 305 end |
274 in | 306 in |
275 loop () | 307 loop () |