Closed neapel closed 10 years ago
This is expected behavior. Seqs are shorthand for [:span ...]
to support laziness in document construction. The fully-realized non-lazy pretty document trees never actually exist because shorthands such as seqs->spans are expanded during the serialization traversal. This lets you pretty print a massive document without having to realize the entire document in memory all at once.
However, if there was a hypothetical "expand" function in which all the shorthands were resolved, your second example would become:
[:span [:text "foo {"] [:span [:align] [:text "bar"] [:line " "] [:text "baz"]] [:text "}"]]
This should make it clear why the alignment is ignored: It has no children. The reason for the :key
-> [:key]
rule is to enable the use of nullary :line
.
ok, thanks for the explanation
I was generating a tree of mixed persistent lists and vectors and noticed because of this case that they don't produce the same output.
(pprint-document [:span "foo {" [:align "bar" :line "baz"] "}"] {:width 500})
produces the indended alignment(pprint-document [:span "foo {" '(:align "bar" :line "baz") "}"] {:width 500})
ignores the alignmentIs there a reason why
seq?
andvector?
are different cases?