-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-pretty
executable file
·37 lines (29 loc) · 910 Bytes
/
make-pretty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Prerequisites: xmlformat (tested with PERL version)
# Usage: ./make-pretty FILE
# Example: ./make-pretty A\ béke\ napja\ közel.xml
# Exit immediately if a command exits with a non-zero status.
set -e
# Params
########
if [ -z "$1" ]; then
echo "Usage: ./make-pretty FILE"
exit 1
fi
if [ ! -f "$1" ]; then
echo "\"$1\" doesn't exist. Enter a valid XML file."
exit 1
fi
# Variables
###########
file=$1
# Running
#########
echo -n "Formatting XML... $file... "
# xmlformat
xmlformat --in-place --config-file=tools/xmlformat.conf "$file"
# xmlformat does not format well the <br/>. Puts it on new line. I want to leave it on the line
# ending. We must fromat it by hand.
# Remark:I think <br/> is alian OpenLyrics and we should return to <line></line> instead of <br/>
sed --in-place --regexp-extended ':a;N;$!ba;s/\r{0,1}\n\s+<br\s*\/*>/<br\/>/g' "$file"
echo "done"