Skip to content

When GIT variable is empty $imgpath can start with // #20

@ahendriksen

Description

@ahendriksen

Hi,

Happy user of gitdown here. I don't use for a github project though. I use it on gitlab.

When I insert a

[diagram]
---->
[/diagram/

block, I want the url to be as follows (I guess gitlab image inclusion uses different urls)

<img src="images/README_1.png" alt="1">

When I set branch and prebranch to empty

.set BRANCH=
.set PREBRANCH=

I get instead:

<img src="//images/README_1.png" alt="1">

I was able to fix it by removing any slashed in front of the final url as follows:

diff --git a/bin/gitdown b/bin/gitdown
index 653d092..9bbabd9 100755
--- a/bin/gitdown
+++ b/bin/gitdown
@@ -125,13 +125,14 @@ while ($line < @input) {
             $imgpath = $symbols{GIT}.'/';
             # allow double slash after : for url
             $imgpath =~ s|(?<!:)/+|/|g;
-
             my $subpath .= "$symbols{PREBRANCH}/$symbols{BRANCH}/$symbols{SUBDIR}/images/";
             # remove starting /
             $subpath =~ s|^/||;
             # remove double /
             $subpath =~ s|/+|/|g;
             $imgpath .= $subpath;
+            # remove starting /
+            $imgpath =~ s|^/+||;
         }
         elsif (/^\.toc(\s+([1-9]))?/) {
             #   Determine top level in text after .toc

I am sorry that this is not a 'pull request'. I am not well acquainted with github..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions