#!/bin/sh
# Symetrically balances the children of the root node in the given FreeMind mind map such that there are nearly equal number of children on the left and right sides of the root node.
# For example, the first child is placed to the right of the root node, the second child is placed to the left of the root node, the third child is placed to the right of the root node, and so on.
# Thus, every odd-numbered child is placed on the right side and every even-numbered child is placed on the left side of the root node.
# Copyright 2005 Suraj N. Kurapati
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
awk '/<[^>]*POSITION=/ { i++; sub("POSITION=\"[^\"]*\"", sprintf("POSITION=\"%s\"", (i%2 ? "right" : "left"))); } { print }' "$@"