summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-09-26 12:45:19 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-09-26 12:45:19 -0400
commit9a7c15c058f6bafef3fee702382197815f335ee9 (patch)
treec51cf1438d3cbb7637a2d95f47b19d5953a9817c /src
parenta2ab1cb6d782e13944ba21fd0368528e5a27ee9e (diff)
Whitelisting tags that may be self-closed
Diffstat (limited to 'src')
-rw-r--r--src/monoize.sml25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/monoize.sml b/src/monoize.sml
index e9f1588e..c3d91074 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -36,6 +36,19 @@ structure L' = Mono
structure IM = IntBinaryMap
structure IS = IntBinarySet
+structure SS = BinarySetFn(struct
+ type ord_key = string
+ val compare = String.compare
+ end)
+
+val singletons = SS.addList (SS.empty,
+ ["link",
+ "br",
+ "p",
+ "hr",
+ "input",
+ "button"])
+
val dummyTyp = (L'.TDatatype (0, ref (L'.Enum, [])), E.dummySpan)
structure U = MonoUtil
@@ -2603,6 +2616,16 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
loc),
fm)
end
+
+ fun isSingleton () =
+ let
+ val (bef, aft) = Substring.splitl (not o Char.isSpace) (Substring.full tag)
+ in
+ SS.member (singletons, if Substring.isEmpty aft then
+ tag
+ else
+ Substring.string bef)
+ end
in
case xml of
(L.EApp ((L.ECApp (
@@ -2610,7 +2633,7 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
_), _),
_), _),
(L.EPrim (Prim.String s), _)), _) =>
- if CharVector.all Char.isSpace s then
+ if CharVector.all Char.isSpace s andalso isSingleton () then
((L'.EStrcat (tagStart, (L'.EPrim (Prim.String " />"), loc)), loc), fm)
else
normal ()