diff --git a/doclib/dot b/doclib/dot
index d181567a5e0edbcc51086c5a5407274c953b85ef..4ec3c34a758ae5ebcd2d3d6a1c1687102c1c4e3c 100755
--- a/doclib/dot
+++ b/doclib/dot
@@ -1,8 +1,14 @@
 #!/bin/sh
 
 topdir="`dirname "$0"`"; topdir="`cd "$topdir/.."; pwd`"
+if head -4 "$1" | grep -q nomunge; then
+    dot "$@"
+    exit $?
+fi
 sed -i -e 's/rankdir=LR/rankdir=TB/' "$1"
 "$topdir/doclib/dot-munge.pl" "$1"
+unflatten -l3 -c3 -f -o "$1".unflat "$1"
+mv "$1".unflat "$1"
 
 case "$2" in
     -Tpng:gd)