From 1043b4de70653e7cef1f29e93488e1b884b67042 Mon Sep 17 00:00:00 2001 From: Corey Donohoe Date: Wed, 16 May 2012 12:48:16 -0700 Subject: [PATCH] Revert "Merge pull request #338 from jroes/resize-sha1s" This reverts commit 4bc5e7b8ffc79abfca7b7045c3ab67988341dd1d, reversing changes made to 423b5205bf4e57ffda7e92fd165ded8958060447. --- .travis.yml | 2 -- lib/gollum/markup.rb | 36 ++++++------------------------------ test/test_markup.rb | 30 ------------------------------ 3 files changed, 6 insertions(+), 62 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef1b651e..fc72739e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,3 @@ notifications: disabled: true before_install: - sudo apt-get install -y asciidoc - - sudo easy_install docutils - \ No newline at end of file diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 31e19cd6..3bac70d1 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -80,41 +80,17 @@ module Gollum def extract_tex(data) data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do tag = CGI.escapeHTML($1) - id = generate_placeholder(tag, $&.length) + id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:block, tag] id end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do tag = CGI.escapeHTML($1) - id = generate_placeholder(tag, $&.length) + id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:inline, tag] id end end - # Fit `id` into `len` by adding trailing spaces or truncating. - # - # id - The String identifier to be fit. - # len - The Integer target length. - # - # Returns the newly-fit String. - def fit_width(id, len) - if id.length < len - id.ljust(len) - else - id[0...len] - end - end - - # Generate a placeholder of a particular length. - # - # tag - The original String tag to be processed later. - # length - The Integer length the placeholder should be. - # - # Returns the new placeholder String. - def generate_placeholder(tag, length) - fit_width(Digest::SHA1.hexdigest(tag), length) - end - # Process all TeX from the texmap and replace the placeholders with the # final markup. # @@ -155,14 +131,14 @@ module Gollum parts = $2.split('][') parts[0][0..4] = "" link = "#{parts[1]}|#{parts[0].sub(/\.org/,'')}" - id = generate_placeholder(link, $&.length) + id = Digest::SHA1.hexdigest(link) @tagmap[id] = link "#{pre}#{id}#{post}" else $& end else - id = generate_placeholder($2, $2.length+4) + id = Digest::SHA1.hexdigest($2) @tagmap[id] = $2 "#{$1}#{id}#{$3}" end @@ -409,7 +385,7 @@ module Gollum # Returns the placeholder'd String data. def extract_code(data) data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```\r?$/m) do - id = generate_placeholder("#{$2}.#{$3}", [$2, $3].join.length) + id = Digest::SHA1.hexdigest("#{$2}.#{$3}") cached = check_cache(:code, id) @codemap[id] = cached ? { :output => cached } : @@ -491,7 +467,7 @@ module Gollum # Returns the placeholder'd String data. def extract_wsd(data) data.gsub(/^\{\{\{ ?(.+?)\r?\n(.+?)\r?\n\}\}\}\r?$/m) do - id = generate_placeholder($2, $&.length) + id = Digest::SHA1.hexdigest($2) @wsdmap[id] = { :style => $1, :code => $2 } id end diff --git a/test/test_markup.rb b/test/test_markup.rb index 7be6d915..b14e597e 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -195,36 +195,6 @@ context "Markup" do assert_equal "

make a link [[home|sweet home]]

", page.formatted_data end - test "table with links" do - table = < - ---- - - - - - - -
Proposal | Mentor
-Ray-Bans | technoweenie
- -EOT - @wiki.write_page("Potato", :rest, table, commit_details) - page = @wiki.page("Potato") - assert_equal expected_table.chomp, page.formatted_data - end - ######################################################################### # # Images