lsg

Lumidify Site Generator
git clone git://lumidify.org/lsg.git (fast, but not encrypted)
git clone https://lumidify.org/git/lsg.git (encrypted, but very slow)
Log | Files | Refs | README | LICENSE

commit 08e852bdb6ef237f195a0c8dca677bc85c7ba9bf
parent aea853add7fcc78754ca720e986b30b3551de189
Author: lumidify <nobody@lumidify.org>
Date:   Wed,  7 Apr 2021 13:25:40 +0200

Add hacky support for HTML5 download attribute

Diffstat:
MLSG/Markdown.pm | 11++++++++++-
Mlsg.pl | 5++++-
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/LSG/Markdown.pm b/LSG/Markdown.pm @@ -48,6 +48,12 @@ sub handle_lnk { my $url = ""; my $char_one = substr($lnk, 0, 1); + my $download = ""; + if ($char_one eq "=") { + $download = " download"; + $lnk = substr($lnk, 1); + } + $char_one = substr($lnk, 0, 1); if ($char_one eq "@") { $lnk_file = $config->{"metadata"}->{$pageid}->{"basename"} . substr($lnk, 1); $lnk_path = catfile("site", "static", $lnk_file); @@ -68,7 +74,10 @@ sub handle_lnk { if ($lnk_path && !(-f $lnk_path)) { die "ERROR: $file: linked file $lnk_path does not exist:\n$line\n"; } - return "[$txt]($url)"; + # Note: This is a huge hack and will probably break something. + # This should actually return markdown, but it has to return HTML + # directly, so it's really weird and inconsistent. + return "<a href=\"$url\"$download>$txt</a>"; } sub handle_img { diff --git a/lsg.pl b/lsg.pl @@ -6,7 +6,6 @@ # lsg.pl - Lumidify Site Generator # Written by lumidify <nobody@lumidify.org> -# Last updated: 2021-03-14 # # To the extent possible under law, the author has dedicated # all copyright and related and neighboring rights to this @@ -200,6 +199,10 @@ B<Links:> [Whatever]($page.en) -> [Whatever](relative/path/to/en/page.html) +If a link starts with "=", the HTML5 "download" attribute is added to the +link so the file is downloaded directly in browsers that support it. +This is a hack. + B<Images:> ![Whatever](@.png)-> [Whatever](relative/path/to/static/$name_of_page.png)