Project

General

Profile

Download (733 Bytes) Statistics
| Branch: | Tag: | Revision:

haketilo / process_html_file.sh @ 90896bcf

1
#!/bin/sh
2

    
3
# Copyright (C) 2021 Wojtek Kosior
4
# Redistribution terms are gathered in the `copyright' file.
5

    
6
# Call like:
7
#     ./process_html_file.sh html/options.html
8

    
9
. ./shell_utils.sh
10

    
11
FILE="$1"
12
FILEKEY=$(sanitize "$FILE")
13

    
14
if [ "x$(map_get HTML_FILENAMES $FILEKEY)" = "xyes" ]; then
15
    errcho "import loop on $FILE"
16
    exit 1
17
fi
18

    
19
map_set_export HTML_FILENAMES $FILEKEY yes
20

    
21
awk '\
22
!/^[\t\r ]*<IMPORT[\t\r ]+([^\t\r ]+)[\t\r ]+\/>[\t\r ]*$/{
23
	print $0;
24
}
25
/^[\t\r ]*<IMPORT[\t\r ]+([^\t\r ]+)[\t\r ]+\/>[\t\r ]*$/{
26
    indent = substr($0, 1, index($0, "<") - 1);
27
    command = "./process_html_file.sh " $2;
28
    while (command | getline) {
29
        print indent $0;
30
    }
31
    if (close(command) != 0)
32
        exit 1;
33
}' < "$FILE"
(6-6/8)