From d09181d42365614ea5861f02624eddfcb1954cb1 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Fri, 9 Feb 2018 11:47:43 +0000 Subject: [PATCH] Make sure URLs into links in markdown. --- fixup.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fixup.rb b/fixup.rb index b60ebb8..3a9c820 100644 --- a/fixup.rb +++ b/fixup.rb @@ -323,5 +323,9 @@ log 0, 'add figure titles required by Docbook for referable figures' data[at].gsub!(/!\[\]\(Pictures/, '![%s](Pictures' % fig[1]) end +log 0, 'adding http:// to all URLs and turn them into links' +data.map {|lin| lin.gsub!(/(^|\s+)([-a-z0-9\\.]+\.(cc|com|edu|eu|io|is|it|kr|net|nl|nz|org|se))/, '\\1http://\\2')} +data.map {|lin| lin.gsub!(/\b(https?:\/\/[-a-z0-9\\.]+)(\/[-\\.\/a-zA-Z0-9#_\?&=,]+[-\/a-zA-Z0-9#_\?&=,])?/, '[](\\1\\2)')} + log 0, 'Writing processed file' File.open(dstfile, 'w') {|f| f.puts data.join("\n")} -- 2.47.2