]> Sergey Matveev's repositories - zk.git/commitdiff
img and raw links
authorSergey Matveev <stargrave@stargrave.org>
Wed, 7 May 2025 14:49:50 +0000 (17:49 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 7 May 2025 14:49:50 +0000 (17:49 +0300)
zk

diff --git a/zk b/zk
index 964eabc633e09ccc831d7fafdbcb6d4383753556..4420ba97aad2ca7218408681e5e121c2bfabb685 100755 (executable)
--- a/zk
+++ b/zk
@@ -63,6 +63,14 @@ navigate among existing notes.
 Ordinary C<grep>, C<git-jump> or similar tools can be used to search and
 quickly open results in the editor.
 
+=item *
+
+C<[img|src|alt]> can be used to create link to images in HTML output.
+
+=item *
+
+C<[raw|url|text]> can be used to create arbitrary link in HTML output.
+
 =back
 
 The only thing Vim lacks there is ability to tell who backlinks
@@ -226,7 +234,14 @@ sub genHTML {
                 $e =~ s/&/\&amp;/g;
                 $w = "<a href=\"$w\">$e</a>";
             } else {
-                if ($w =~ m/^\[.+\]$/) {
+                if ($w =~ /^\[img\|(.*)\|(.+)\]$/) {
+                    $w = "<img src=\"$1\" alt=\"$2\" />";
+                } elsif ($w =~ /^\[raw\|(.*)\|(.+)\]$/) {
+                    $w = "<a href=\"$1\">$2</a>";
+                } elsif ($w =~ /\[.+\]/) {
+                    $w =~ s/&/\&amp;/g;
+                    $w =~ s/</\&lt;/g;
+                    $w =~ s/>/\&gt;/g;
                     while (my ($i, $l) = each @lnks) {
                         $w =~ s/\[$l\]/<a href="$rels[$i].html">[$l]<\/a>/g;
                     }