lib/github/mandoc.rb
def fix_anchors
				map = {}

				# Normalise IDs
				@doc.css("[id]").each do |el|
					old = el["id"]
					id = fix_anchor(old)
					id.sub!(/\d*$/) { |suffix| (suffix || "1").to_i + 1 } while map.value? id
					map[old] = el["id"] = id
				end

				# Update hrefs
				@doc.css("[href]").each do |el|
					href = el["href"]
					if href.match(/#([^#]+)$/) && map.key?(hash = Regexp.last_match(1))
						el["href"] = href.gsub(/[^#]+$/, map[hash])
					end
				end
			end
# Force lowercase, dash-separated anchor names
Force lowercase, dash-separated anchor names
Force lowercase dash - separated anchor names
def fix_anchors
				map = {}
				@doc.css("[id]").each do |el|
					old = el["id"]
					id = fix_anchor(old)
					id.sub!(/\d*$/) { |suffix| (suffix || "1").to_i + 1 } while map.value? id
					map[old] = el["id"] = id
				end
				@doc.css("[href]").each do |el|
					href = el["href"]
					if href.match(/#([^#]+)$/) && map.key?(hash = Regexp.last_match(1))
						el["href"] = href.gsub(/[^#]+$/, map[hash])
					end
				end
			end
def fix_anchors map = { } @doc . css ( "[id]" ) . each do | el | old = el [ "id" ] id = fix_anchor ( old ) id . sub! ( / \d *$ / ) { | suffix | ( suffix || "1" ) . to_i + 1 } while map . value? id map [ old ] = el [ "id" ] = id end @doc . css ( "[href]" ) . each do | el | href = el [ "href" ] if href . match ( / #([^#]+)$ / ) && map . key? ( hash = Regexp . last_match ( 1 ) ) el [ "href" ] = href . gsub ( / [^#]+$ / , map [ hash ] ) end end end
Force lowercase, dash-separated anchor names
Force lowercase dash - separated anchor names
# Normalise IDs # Update hrefs