fixed lazy loading image bug and added some visual improvements ig?

This commit is contained in:
notkoutsie 2023-09-15 18:23:20 +03:00
parent 0c67fd746d
commit 1b9100866b

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# noter 1.1.2 - "fuck fever" - @k@layer8.space - mit # noter 1.1.5 - "tired tire tried" - @k@layer8.space - mit
nlog() { nlog() {
local ORANGE='\033[0;33m' local ORANGE='\033[0;33m'
@ -31,9 +31,15 @@ givefavicon() {
} }
generate_note_html() { generate_note_html() {
# NOTE TO SELF: Figure out parsing html blocks (ie: <code>) so that we can apply styles for whole
# elements instead of doing what we're doing right now...
local note_date="$(date -d "$(basename "$1" .txt)" +"%B %d, %Y")" local note_date="$(date -d "$(basename "$1" .txt)" +"%B %d, %Y")"
for img in $(grep -oP '(?<=<img src=").*?(?=")' "$1"); do for img in $(grep -oP '(?<=<img src=").*?(?=")' "$1"); do
# Check if the loading attribute already exists
if ! grep -q "src=\"$img\" loading=\"lazy\"" "$1"; then
# Add the loading attribute if it doesn't exist
sed -i "s|<img src=\"$img\"|<img src=\"$img\" loading=\"lazy\"|g" "$1" sed -i "s|<img src=\"$img\"|<img src=\"$img\" loading=\"lazy\"|g" "$1"
fi
done done
echo "<a name='$(basename "$1" .txt)'></a>" echo "<a name='$(basename "$1" .txt)'></a>"
echo "<div class='note'>" echo "<div class='note'>"
@ -107,6 +113,11 @@ echo "<!DOCTYPE html>
color: #fff; color: #fff;
white-space: pre-wrap; white-space: pre-wrap;
} }
code {
color: orange !important;
font-family: 'Courier New', monospace;
white-space: pre-wrap;
}
.back-to-top { .back-to-top {
text-align: right; text-align: right;
margin-top: 20px; margin-top: 20px;