From 90b6000da74eea6081e1baea6c4df03c7f321d62 Mon Sep 17 00:00:00 2001 From: X Code Date: Sat, 22 Jan 2022 15:23:58 -0800 Subject: [PATCH] Override Leaf toString method --- lib/src/models/documents/attribute.dart | 1 + lib/src/models/documents/nodes/leaf.dart | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/src/models/documents/attribute.dart b/lib/src/models/documents/attribute.dart index ecf05e26..dc782098 100644 --- a/lib/src/models/documents/attribute.dart +++ b/lib/src/models/documents/attribute.dart @@ -12,6 +12,7 @@ enum AttributeScope { class Attribute { Attribute(this.key, this.scope, this.value); + /// Unique key of this attribute. final String key; final AttributeScope scope; final T value; diff --git a/lib/src/models/documents/nodes/leaf.dart b/lib/src/models/documents/nodes/leaf.dart index f2ccf75c..1fc29b5e 100644 --- a/lib/src/models/documents/nodes/leaf.dart +++ b/lib/src/models/documents/nodes/leaf.dart @@ -101,6 +101,13 @@ abstract class Leaf extends Node { } } + @override + String toString() { + final keys = style.keys.toList(growable: false)..sort(); + final styleKeys = keys.join(); + return '⟨$value⟩$styleKeys'; + } + /// Adjust this text node by merging it with adjacent nodes if they share /// the same style. @override