96f5e5d82a63f2a557b97f6268c00bc420254588
commit 96f5e5d82a63f2a557b97f6268c00bc420254588
Author: spesk1 <spesk@pm.me>
Date: Thu Jul 4 14:18:38 2019 +0000

Changed link parsing to use MD standard syntax

diff --git a/README.md b/README.md
index 99d4225..0eaa7f6 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# git-site-gen AKA gsg #
-* Tool used to generate a bare bones, pure HTML static website from information availble in a git project dir. See: https://spwbk.site/git.
+* Tool used to generate a bare bones, pure HTML static website from information availble in a git project dir. See: <https://spwbk.site/git>.
* Inspired by the much better/full-featured cgit.
-* See gsgd for git hooks based calls to gsgd: https://spwbk.site/git/projects/gsgd.git/index.html
+* See gsgd for git hooks based calls to gsgd: <https://spwbk.site/git/projects/gsgd.git/index.html>
* Not sure if this will be widely useful, mostly written for learning purposes.

## Design Goals ##
@@ -37,7 +37,7 @@ TODO:

## Deps/Compatibility ##
* Linux only (will probably work on BSD?)
-* Shellex.pm ( https://spwbk.site/git/projects/perl-shellex.git/index.html )
+* Shellex.pm ( <https://spwbk.site/git/projects/perl-shellex.git/index.html> )
* git
* Perl Log4Perl (packaged by most Linux distros)
* Perl GetOpt (packaged by most Linux distros)
diff --git a/lib/Gsg/Html.pm b/lib/Gsg/Html.pm
index 1cd1021..e9ecd72 100644
--- a/lib/Gsg/Html.pm
+++ b/lib/Gsg/Html.pm
@@ -40,16 +40,16 @@ sub write_root_index($$$$) {
my $logger = shift;
write_file("", $index);
append_file("<html><body><b>Git Projects</b><br><head><META NAME=\"ROBOTS\" CONTENT=\"NOINDEX, NOFOLLOW\"></head>\n",$index);
- append_file("<small><i>Statically generated web root for browsing this git server</i></small><br><hr/>",$index);
+ append_file("<small><i>Statically generated web root for browsing this git server</i></small><br><hr/>\n",$index);

my $mkdirCmd = findBin("mkdir",$logger);
foreach my $project ( @$project_dirs_ref ) {
my $indexPath = $project . "index.html";
- append_file("<table><div id=\"cotent\"><table id=\"index\"><tbody>",$index);
- append_file("<tr><td><a href=\"projects/$indexPath\">$project</a></td>",$index);
+ append_file("<table><div id=\"cotent\"><table id=\"index\"><tbody>\n",$index);
+ append_file("<tr><td><a href=\"projects/$indexPath\">$project</a></td>\n",$index);
shellex("$mkdirCmd -p $web_projects_dir_path$project",$logger);
}
- append_file("</tr></tbody></table></div></body></html>",$index);
+ append_file("</tr></tbody></table></div></body></html>\n",$index);
$logger->info("Wrote root index at $index");

}
@@ -94,17 +94,17 @@ sub gen_line_nums($$$) {
# Might be a better way to do this? TODO
open my $fh, '>>', \$html_file or die "Can't open variable: $!";

- print $fh "<!DOCTYPE html><html><b>$filename</b><hr/><div id=\"content\"><pre id=\"blob\">";
+ print $fh "<!DOCTYPE html><html><b>$filename</b><hr/><div id=\"content\"><pre id=\"blob\">\n";
my $line_counter = 1;
foreach my $line ( split("\n", $raw_file) ) {
if ( $line ne "" ) {
$line = check_for_html($line);
}
- print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a>\t$line<br>";
+ print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a>\t$line<br>\n";
$line_counter++;
}

- print $fh "</pre></div><html>";
+ print $fh "</pre></div><html>\n";
close $fh;

$logger->info("Generated line numbers for $filename");
diff --git a/lib/Gsg/MdParse.pm b/lib/Gsg/MdParse.pm
index 35dfcf1..70cc3da 100644
--- a/lib/Gsg/MdParse.pm
+++ b/lib/Gsg/MdParse.pm
@@ -8,8 +8,9 @@ our @EXPORT_OK = qw(render_readme);
sub link_line($) {

my $line = shift;
- if ( $line =~ m/(http.*)/ ) {
- my $link = $1;
+ if ( $line =~ m/(<(http.*)>)/ ) {
+ my $markup_link = $1;
+ my $link = $2;
my $link_replace = "<a href=\"$link\">$link</a>";
$line =~ s/\Q$1\E/$link_replace/g;
return $line;