Mercurial > urweb
changeset 1495:af0d4d11c5d7
Allow HTML in tutorial comments
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 15 Jul 2011 17:25:09 -0400 |
parents | 9ef6dd0df7a0 |
children | 3010472edf44 |
files | doc/intro.ur src/tutorial.sml |
diffstat | 2 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/intro.ur Fri Jul 15 17:16:39 2011 -0400 +++ b/doc/intro.ur Fri Jul 15 17:25:09 2011 -0400 @@ -1,5 +1,7 @@ (* Introduction *) +(* This work is licensed under a <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License</a>. *) + (* Test evaluation.... *) fun f [a] (x : a) : a = x
--- a/src/tutorial.sml Fri Jul 15 17:16:39 2011 -0400 +++ b/src/tutorial.sml Fri Jul 15 17:25:09 2011 -0400 @@ -48,6 +48,28 @@ val (befor, after) = Substring.position "<title>" source + fun proseLoop source = + let + val (befor, after) = Substring.splitl (fn ch => ch <> #"&") source + in + if Substring.isEmpty after then + TextIO.outputSubstr (outf, source) + else if Substring.size after >= 8 andalso Substring.string (Substring.slice (after, 1, SOME 7)) = "amp;lt;" then + (TextIO.outputSubstr (outf, befor); + TextIO.output (outf, "<"); + proseLoop (Substring.slice (after, 8, NONE))) + else if Substring.size after >= 4 andalso Substring.string (Substring.slice (after, 1, SOME 3)) = "gt;" then + (TextIO.outputSubstr (outf, befor); + TextIO.output (outf, ">"); + proseLoop (Substring.slice (after, 4, NONE))) + else if Substring.size after >= 5 andalso Substring.string (Substring.slice (after, 1, SOME 4)) = "amp;" then + (TextIO.outputSubstr (outf, befor); + TextIO.output (outf, "&"); + proseLoop (Substring.slice (after, 5, NONE))) + else + raise Fail "Unsupported HTML escape" + end + fun loop source = let val (befor, after) = Substring.position "<span class=\"comment-delimiter\">(* </span><span class=\"comment\">" source @@ -64,7 +86,7 @@ else (TextIO.outputSubstr (outf, befor); TextIO.output (outf, "<div class=\"prose\">"); - TextIO.outputSubstr (outf, befor'); + proseLoop befor'; TextIO.output (outf, "</div>"); loop (Substring.slice (after, 49, NONE))) end