Handle stupid 0x0D bytes because browsers are stupid.

This commit is contained in:
Tom Preston-Werner
2010-07-07 17:33:04 -07:00
parent 6c7fcf89c3
commit f3cbbb8652
3 changed files with 27 additions and 3 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ module Gollum
#
# Returns the placeholder'd String data.
def extract_code(data)
data.gsub(/^``` ?(.+)\n(.+)\n```$/m) do
data.gsub(/^``` ?(.+?)\r?\n(.+?)\r?\n```\r?$/m) do
id = Digest::SHA1.hexdigest($2)
@codemap[id] = { :lang => $1, :code => $2 }
id
+11 -2
View File
@@ -67,7 +67,7 @@ module Gollum
if pcommit = @repo.commit('master')
map = tree_map(pcommit.tree)
end
map[path] = data
map[path] = normalize(data)
index = tree_map_to_index(map)
parents = pcommit ? [pcommit] : []
@@ -90,7 +90,7 @@ module Gollum
pcommit = @repo.commit('master')
map = tree_map(pcommit.tree)
index = tree_map_to_index(map)
index.add(page.path, data)
index.add(page.path, normalize(data))
actor = Grit::Actor.new(commit[:name], commit[:email])
index.commit(commit[:message], [pcommit], actor)
@@ -160,6 +160,15 @@ module Gollum
# Returns the String path.
attr_reader :path
# Normalize the data.
#
# data - The String data to be normalized.
#
# Returns the normalized data String.
def normalize(data)
data.gsub(/\r/, '')
end
# Fill an array with a list of pages.
#
# tree - The Grit::Tree to start with.