Fix /usr/bin/env shebang
[project-aon.git] / common / scripts / xmlize.pl
index 349d37d..d78bd94 100755 (executable)
@@ -8,6 +8,7 @@ use strict;
 use warnings;
 use utf8;
 use open ':encoding(UTF-8)';
+use open ':std', ':encoding(UTF-8)';
 
 my $FILE_EXTENSION = 'txt';
 my $BASE_INDENT = '     ';
@@ -121,6 +122,10 @@ print << "(End of XML footer)";
 sub xmlize {
     my( $inline, $infile ) = @_;
 
+    if(!defined $inline || $inline eq "") {
+        return "";
+    }
+
     $inline =~ tr/\t/ /;
     $inline =~ s/[[:space:]]{2,}/ /g;
     $inline =~ s/[[:space:]]+$//;
@@ -130,6 +135,7 @@ sub xmlize {
     $inline =~ s/\&(?=[[:space:]])/<ch.ampersand\/>/g;
     $inline =~ tr/\"\`/\'/;
     $inline =~ s/[\N{U+2018}\N{U+201C}]/<quote>/g;
+    $inline =~ s|[\N{U+2019}\N{U+201D}]([[:alpha:]])|<ch.apos/>$1|g;
     $inline =~ s/[\N{U+2019}\N{U+201D}]/<\/quote>/g;
     $inline =~ s/[\N{U+2014}]/<ch.endash\/>/g;
     $inline =~ s/[\N{U+2014}]/<ch.emdash\/>/g;