Skip to content

Instantly share code, notes, and snippets.

@pieter
Created July 31, 2008 01:41
Show Gist options
  • Save pieter/3378 to your computer and use it in GitHub Desktop.
Save pieter/3378 to your computer and use it in GitHub Desktop.
From 494e856cc16b19c45fefbae1a3ffb4f22fb61232 Mon Sep 17 00:00:00 2001
From: Pieter de Bie <[email protected]>
Date: Thu, 31 Jul 2008 03:38:30 +0200
Subject: [PATCH] Simplify more code in the HTML parsing
---
script/html.rb | 14 +++-----------
1 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/script/html.rb b/script/html.rb
index 8b2b327..db90313 100644
--- a/script/html.rb
+++ b/script/html.rb
@@ -15,20 +15,12 @@ def do_replacements(html, type = :html)
# replace gitlinks
- html = html.gsub /linkgit:.*?\[\d\]/ do |code|
- if match = /linkgit:(.*?)\[/.match(code)
- code = "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/#{match[1]}.html\">#{match[1].gsub('git-', 'git ')}</a>"
- end
- code
+ html.gsub! /linkgit:(.*?)\[\d\]/ do |code, waa|
+ "<a href=\"http://www.kernel.org/pub/software/scm/git/docs/#{$1}.html\">#{$1.gsub('git-', 'git ')}</a>"
end
# replace figures
- html = html.gsub /\[fig:.*?\]/ do |code|
- if match = /\[fig:(.*?)\]/.match(code)
- code = "<div class=\"center\"><img src=\"images/figure/#{match[1]}.png\"></div>"
- end
- code
- end
+ html.gsub! /\[fig:(.*?)\]/, '<div class="center"><img src="images/figure/\1.png"></div>'
# fix images in pdf
html.gsub!('src="images', 'src="assets/images') if type == :pdf
--
1.6.0.rc1.163.gc85c5.dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment