23 lines
849 B
Bash
23 lines
849 B
Bash
#!/usr/bin/env bash
|
|
|
|
# Reads HTML file from stdin, prints its content to stdout
|
|
# $1 where to start ("text" or "entry")
|
|
# $2 where to stop ("text" or "entry")
|
|
# $3 "cut" to remove text from <hr /> to <!-- text end -->
|
|
# note that this does not remove <hr /> line itself,
|
|
# so you can see if text was cut or not
|
|
declare cut_line
|
|
declare cut_tags
|
|
declare template_tags_line_header
|
|
get_html_file_content() {
|
|
awk "/<!-- $1 begin -->/, /<!-- $2 end -->/{
|
|
if (!/<!-- $1 begin -->/ && !/<!-- $2 end -->/) print
|
|
if (\"$3\" == \"cut\" && /$cut_line/){
|
|
if (\"$2\" == \"text\") exit # no need to read further
|
|
while (getline > 0 && !/<!-- text end -->/) {
|
|
if (\"$cut_tags\" == \"no\" && /^<p>$template_tags_line_header/ ) print
|
|
}
|
|
}
|
|
}"
|
|
}
|