]> pere.pagekite.me Git - text-madewithcc.git/commitdiff
Add code to copy picture and single link strings from src to dest.
authorPetter Reinholdtsen <pere@hungry.com>
Mon, 19 Feb 2018 07:14:19 +0000 (07:14 +0000)
committerPetter Reinholdtsen <pere@hungry.com>
Thu, 22 Feb 2018 18:12:09 +0000 (18:12 +0000)
fixup-migrate-gettext.rb

index 8a2f198492c35ed1a54b6ba32521e2eb69c4a248..506030d66b7300aea7a2dab1f3bc9478675e4e42 100755 (executable)
@@ -126,14 +126,14 @@ strings = File.open(file,'r').read.split(/\n\n/)[1..-1].map {|str| PoStr.new(str
 
 c = 0
 strings.each do |entry|
-  if entry.fuzzy?
-    # Ignore whitespace changes between prev and src
-    entry.prevclean = entry.prevstr().gsub(/ +/, ' ')
-    entry.srcclean = entry.srcstr().gsub(/ +/, ' ')
+  # 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"
+      #print "clear fuzzy (space)\n"
       c = c + 1
       next
     end
@@ -177,6 +177,15 @@ strings.each do |entry|
       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 "# Would clear %d fuzzy\n" % [c]
+print "# Cleared %d fuzzy strings\n" % [c]