28 lines
1019 B
Plaintext
28 lines
1019 B
Plaintext
if [[ ${globaldebug} == "true" ]]; then
|
|
local debug=true
|
|
else
|
|
local debug=false
|
|
fi
|
|
|
|
local content="${1}"
|
|
local modified_content=""
|
|
echo "${content}" | while IFS= read -r line; do
|
|
if [[ ${line} == *"#link"* ]]; then
|
|
if (${debug}) _msg debug "${0:t}_msg_1" " ${line}"
|
|
local url_full=$(echo "${line}" | awk -F'#link ' '{print $2}' | awk -F'¤' '{print $1 "¤" $2}')
|
|
local url_dest=$(echo "${url_full}" | awk -F'¤' '{print $1}')
|
|
local url_txt=$(echo "${url_full}" | awk -F'¤' '{print $2}')
|
|
|
|
if (${debug}) _msg debug "${0:t}_msg_2" " ${url_dest}"
|
|
if (${debug}) _msg debug "${0:t}_msg_3" " ${url_txt}"
|
|
local modified_link="<a href=\"${url_dest}\">${url_txt}"
|
|
if [[ ${url_dest} =~ ^https?:// ]]; then
|
|
modified_link+="<img class=\"exticon\" alt=\"External site icon\" src=\"/images/ext-black-top.svg\" width=\"12\" />"
|
|
fi
|
|
modified_link+="</a>"
|
|
line=${line//"#link ${url_full}"/${modified_link}}
|
|
fi
|
|
modified_content+="${line}\n"
|
|
done
|
|
echo -e "${modified_content}"
|