more robust pretty printing of broken YXML, e.g. single "\^E";
--- a/src/Pure/ML/ml_syntax.ML Mon Feb 17 20:49:47 2020 +0100
+++ b/src/Pure/ML/ml_syntax.ML Tue Feb 18 15:40:37 2020 +0100
@@ -128,8 +128,9 @@
fun pretty_string max_len str =
let
val body =
- maps (fn XML.Elem _ => ["<markup>"] | XML.Text s => Symbol.explode s) (YXML.parse_body str)
- handle Fail _ => Symbol.explode str;
+ if YXML.is_wellformed str then
+ maps (fn XML.Elem _ => ["<markup>"] | XML.Text s => Symbol.explode s) (YXML.parse_body str)
+ else Symbol.explode str;
val body' =
if length body <= max_len then body
else take (Int.max (max_len, 0)) body @ ["..."];
--- a/src/Pure/PIDE/yxml.ML Mon Feb 17 20:49:47 2020 +0100
+++ b/src/Pure/PIDE/yxml.ML Tue Feb 18 15:40:37 2020 +0100
@@ -29,6 +29,7 @@
val parse_body: string -> XML.body
val parse: string -> XML.tree
val content_of: string -> string
+ val is_wellformed: string -> bool
end;
structure YXML: YXML =
@@ -158,5 +159,7 @@
val content_of = parse_body #> XML.content_of;
+fun is_wellformed s = string_of_body (parse_body s) = s
+ handle Fail _ => false;
+
end;
-