Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ahendriksen opened this issue Nov 20, 2016 · 0 comments
Open

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

ahendriksen opened this issue Nov 20, 2016 · 0 comments

Comments

@ahendriksen
Copy link
Contributor

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant