Project

General

Profile

Download (1.1 KB) Statistics
| Branch: | Revision:

hachette / process_html_file.sh @ master

1
#!/bin/sh
2

    
3
# This file is part of Haketilo
4
#
5
# Copyright (C) 2021, Wojtek Kosior
6
#
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the CC0 1.0 Universal License as published by
9
# the Creative Commons Corporation.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# CC0 1.0 Universal License for more details.
15

    
16
# Call like:
17
#     ./process_html_file.sh html/options.html
18

    
19
. ./shell_utils.sh
20

    
21
FILE="$1"
22
FILEKEY=$(sanitize "$FILE")
23

    
24
if [ "x$(map_get HTML_FILENAMES $FILEKEY)" = "xyes" ]; then
25
    errcho "import loop on $FILE"
26
    exit 1
27
fi
28

    
29
map_set_export HTML_FILENAMES $FILEKEY yes
30

    
31
awk '\
32
!/^[\t\r ]*<IMPORT[\t\r ]+([^\t\r ]+)[\t\r ]+\/>[\t\r ]*$/{
33
	print $0;
34
}
35
/^[\t\r ]*<IMPORT[\t\r ]+([^\t\r ]+)[\t\r ]+\/>[\t\r ]*$/{
36
    indent = substr($0, 1, index($0, "<") - 1);
37
    command = "./process_html_file.sh " $2;
38
    while (command | getline) {
39
        print indent $0;
40
    }
41
    if (close(command) != 0)
42
        exit 1;
43
}' < "$FILE"
(9-9/13)