Skip to content
Snippets Groups Projects
Commit 9a0dfe83 authored by Lukáš Krupčík's avatar Lukáš Krupčík
Browse files

Update html_md.sh

parent 9e6c4e47
No related branches found
No related tags found
No related merge requests found
......@@ -84,12 +84,12 @@ if [ "$1" = "-c" ]; then
echo "$i";
printf "\t\tfiltering html files...\n";
HEAD=$(cat "$i" | grep -n -m1 '<h1' |cut -f1 -d: | tr --delete '\n')
END=$(cat "$i" | grep -n -m1 '<!-- <div tal:content=' |cut -f1 -d: | tr --delete '\n')
LAST=$(cat "$i" | wc -l | tr --delete '\n')
HEAD=$(grep -n -m1 '<h1' "$i" |cut -f1 -d: | tr --delete '\n')
END=$(grep -n -m1 '<!-- <div tal:content=' "$i" |cut -f1 -d: | tr --delete '\n')
LAST=$(wc -l "$i" | cut -f1 -d' ')
DOWN=$((LAST-END+2))
cat "$i" | sed '1,'"$((HEAD-1))"'d' | sed -n -e :a -e '1,'"$DOWN"'!{P;N;D;};N;ba' > "${i%.*}TMP.html"
sed '1,'"$((HEAD-1))"'d' "$i" | sed -n -e :a -e '1,'"$DOWN"'!{P;N;D;};N;ba' > "${i%.*}TMP.html"
# converted .html to .md
printf "\t\t.html -> .md\n"
......@@ -100,36 +100,33 @@ if [ "$1" = "-c" ]; then
echo "${i%.*}" >> ./info/files_md.txt;
# create filter_auto
cat "${i%.*}.md" | grep -o -P '(?<={).*(?=})' | sort -u | sed '/{/d' | sed '/\$/d' >> filter_auto;
grep -o -P '(?<={).*(?=})' "${i%.*}.md" | sort -u | sed '/{/d' | sed '/\$/d' >> filter_auto;
sort -u filter_auto -o filter_auto;
# exceptions filter_auto
cat exceptions_filter_auto |
while read y;
(while read y;
do
# search and delete according with filter_auto
cat filter_auto | sed -e 's/'"$y"'//g' > filter_autoTMP;
sed -e 's/'"$y"'//g' filter_auto > filter_autoTMP;
cat filter_autoTMP > filter_auto;
done
done) < exceptions_filter_auto
# text filtering of html, css, ...
printf "\t\tautomatic filter...\n"
cat filter_auto |
while read y;
(while read y;
do
# search and delete according with filter_auto
cat "${i%.*}.md" | sed -e 's/{'"$y"'}//g' | sed -e 's/\\//g' | sed -e 's/^Q//g' | sed -e 's/: //g' | sed -e 's/<\/div>//g' | sed '/^<div/d' | awk -v RS='\n\n\n\n\n' 1 > "${i%.*}TMP.md";
sed -e 's/{'"$y"'}//g' "${i%.*}.md" | sed -e 's/\\//g' | sed -e 's/^Q//g' | sed -e 's/: //g' | sed -e 's/<\/div>//g' | sed '/^<div/d' | awk -v RS='\n\n\n\n\n' 1 > "${i%.*}TMP.md";
cat "${i%.*}TMP.md" > "${i%.*}.md";
done
done) < filter_auto
printf "\t\tother filter...\n"
cat filter_other |
while read a;
(while read a;
do
# search and delete according with filter_other
cat "${i%.*}.md" | sed -e 's/'"$a"'//g' > "${i%.*}TMP.md";
sed -e 's/'"$a"'//g' "${i%.*}.md" > "${i%.*}TMP.md";
cat "${i%.*}TMP.md" > "${i%.*}.md";
done
done) < filter_other
# delete temporary files
rm "${i%.*}TMP.md";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment