+
+#print strings
+
+c = 0
+strings.each do |entry|
+ # Ignore whitespace changes between prev and src
+ entry.prevclean = entry.prevstr().gsub(/ +/, ' ')
+ entry.srcclean = entry.srcstr().gsub(/ +/, ' ')
+
+ if entry.fuzzy?
+ if entry.prevclean == entry.srcclean
+ entry.status = ''
+ #print "# clear fuzzy (space)\n"
+ c = c + 1
+ entry.output
+ next
+ end
+
+ # Rewrite title strings, which lost '#' at the front
+ if entry.prevclean.gsub(/^#+ +/, '') == entry.srcclean
+ # FIXME Not safe to clear fuzzy flag, might have bogus translation
+ entry.status = ''
+ if entry.dest[0].gsub!(/^#+ +/, '') ||
+ ('' == entry.dest[0] && entry.dest[1].gsub!(/^#+ +/, ''))
+ #print "cleared fuzzy (title)\n"
+ c = c + 1
+ end
+ end
+
+ # Rewrite footnotes to use "<placeholder type=\"footnote\" id=\"0\"/>"
+ if entry.srcclean =~ /<placeholder type=\\"footnote\\" id=\\"0\\"\/>/
+ #print "found footnote\n"
+ p = entry.prevclean
+ p.sub!(/([a-z]\.["”]?)(\d+)(\s)/, "\\1<placeholder type=\\\"footnote\\\" id=\\\"0\\\"\/>\\3")
+ p.sub!(/([a-z]\.["”]?)(\d+)$/, "\\1<placeholder type=\\\"footnote\\\" id=\\\"0\\\"\/>")
+ #print p, "\n"
+ #print entry.src, "\n"
+ if p == entry.srcclean
+ replaced = false
+ entry.dest.each do |part|
+ if part.sub!(/([a-z]\.["”»]?)(\d+)(\s)/, "\\1<placeholder type=\\\"footnote\\\" id=\\\"0\\\"\/>\\3")
+ replaced = true
+ end
+ end
+ entry.dest.each do |part|
+ if part.sub!(/([a-z]\.["”»]?)(\d+)$/, "\\1<placeholder type=\\\"footnote\\\" id=\\\"0\\\"\/>")
+ replaced = true
+ end
+ end
+ if replaced
+ #print "cleared fuzzy (footnote)\n"
+ entry.status = ''
+ c = c + 1
+ end
+ end
+ end
+ end
+
+ # Copy image references and single URLs unchanged, even for non-fuzzies
+ if entry.prevclean =~ /!\[\]\(Pictures\// ||
+ entry.srcclean =~ /^<ulink url=\\\".+\\\"\/>$/
+ entry.dest = entry.src.clone()
+ entry.status = ''
+ c = c + 1
+ end
+
+ entry.output
+end
+print "# Cleared %d fuzzy strings\n" % [c]