summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-05-25 20:08:41 +0300
committerPaul Buetow <paul@buetow.org>2023-05-25 20:08:41 +0300
commit3eae6a19aafd77ef5c928d60621529b58797b2f6 (patch)
tree3af8d524a9da1129260a765c1f5598c3203134da
parentf4e43219ae107b7ddbd8fbb1c7238d03530a8b11 (diff)
parent92b8b8721700cd47d7fef2ba64f166f45c797ca2 (diff)
Merge branch 'develop' of codeberg.org:snonux/gemtexter into develop
-rw-r--r--lib/atomfeed.source.sh2
-rw-r--r--lib/generate.source.sh8
-rw-r--r--lib/html.source.sh7
3 files changed, 13 insertions, 4 deletions
diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh
index cc810d1..079c2fb 100644
--- a/lib/atomfeed.source.sh
+++ b/lib/atomfeed.source.sh
@@ -74,7 +74,7 @@ ATOMHEADER
while read -r gmi_file; do
atomfeed::_entry "$gemfeed_dir" "$gmi_file" "$atom_file.tmp"
- done < <(gemfeed::get_posts | head -n $ATOM_MAX_ENTRIES)
+ done < <(gemfeed::get_posts | head -n "$ATOM_MAX_ENTRIES")
cat <<ATOMFOOTER >> "$atom_file.tmp"
</feed>
diff --git a/lib/generate.source.sh b/lib/generate.source.sh
index f56f22d..8cc3329 100644
--- a/lib/generate.source.sh
+++ b/lib/generate.source.sh
@@ -69,9 +69,13 @@ generate::convert_gmi_atom_to_html_atom () {
log INFO 'Converting Gemtext Atom feed to HTML Atom feed'
+ if [ ! -d "$CONTENT_BASE_DIR/html/gemfeed" ]; then
+ mkdir -p "$CONTENT_BASE_DIR/html/gemfeed"
+ fi
+
$SED 's|.gmi |.html |g; s|.gmi"|.html"|g; s|.gmi</id>|.html</id>|g; s|gemini://|https://|g' \
- < $CONTENT_BASE_DIR/gemtext/gemfeed/atom.xml \
- > $CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp
+ < "$CONTENT_BASE_DIR/gemtext/gemfeed/atom.xml" \
+ > "$CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp"
atomfeed::xmllint "$CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp" &&
mv "$CONTENT_BASE_DIR/html/gemfeed/atom.xml.tmp" "$CONTENT_BASE_DIR/html/gemfeed/atom.xml"
diff --git a/lib/html.source.sh b/lib/html.source.sh
index 7056f24..b60ac75 100644
--- a/lib/html.source.sh
+++ b/lib/html.source.sh
@@ -4,6 +4,7 @@ html::encode () {
s|\&|\&amp;|g;
s|<|\&lt;|g;
s|>|\&gt;|g;
+ s|'\''|\&#39;|g;
' <<< "$@"
}
@@ -70,7 +71,7 @@ html::make_link () {
descr="$link"
fi
- echo "<a class='textlink' href='$link'>$descr</a><br />"
+ echo "<a class='textlink' href='$(html::encode "$link")'>$descr</a><br />"
}
html::process_inline () {
@@ -214,6 +215,10 @@ html::test::default () {
assert::equals "$(generate::make_link html "$line")" \
"<a class='textlink' href='https://example.org'>https://example.org</a><br />"
+ line="=> https://example.org/foo'bar"
+ assert::equals "$(generate::make_link html "$line")" \
+ "<a class='textlink' href='https://example.org/foo&#39;bar'>https://example.org/foo'bar</a><br />"
+
line='=> index.html'
assert::equals "$(generate::make_link html "$line")" \
"<a class='textlink' href='index.html'>index.html</a><br />"