summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-02-15 22:07:53 +0000
committerKarl Berry <karl@freefriends.org>2016-02-15 22:07:53 +0000
commit73b1c209e75875c789db1f73464f5e118590ed9e (patch)
tree521e07c677e52390cea9d2ccbeeef4cbbbcad7e6 /Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl
parentf2d240e3af96300dd96067cd653bc34a08c47e26 (diff)
crossrefware (15feb16)
git-svn-id: svn://tug.org/texlive/trunk@39727 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl')
-rwxr-xr-xMaster/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl69
1 files changed, 29 insertions, 40 deletions
diff --git a/Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl b/Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl
index 5824511cdbf..f9585399cfa 100755
--- a/Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl
+++ b/Master/texmf-dist/scripts/crossrefware/ltx2crossrefxml.pl
@@ -56,7 +56,7 @@ Boris Veytsman
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2012-2015 Boris Veytsman
+Copyright (C) 2012-2016 Boris Veytsman
This is free software. You may redistribute copies of it under the
terms of the GNU General Public License
@@ -67,18 +67,22 @@ extent permitted by law.
=cut
use strict;
+
+ BEGIN {
+ # find files relative to our installed location within TeX Live
+ chomp(my $TLMaster = `kpsewhich -var-value=SELFAUTOPARENT`); # TL root
+ if (length($TLMaster)) {
+ unshift @INC, "$TLMaster/texmf-dist/scripts/bibtexperllibs";
+ }
+ }
use POSIX qw(strftime);
- use Text::BibTeX;
- use Text::BibTeX::Name;
- use TeX::Encode;
- use Encode;
- use HTML::Entities;
- use XML::Entities;
+ use BibTeX::Parser::Author;
+ use LaTeX::ToUnicode qw (convert);
use File::Basename;
use File::Spec;
my $USAGE="USAGE: $0 [-c config] [-o output] file1 file2 ...\n";
my $VERSION = <<END;
-ltx2crossrefxml v1.0
+ltx2crossrefxml v2.0
This is free software. You may redistribute copies of it under the
terms of the GNU General Public License
http://www.gnu.org/licenses/gpl.html. There is NO WARRANTY, to the
@@ -88,6 +92,8 @@ END
use Getopt::Std;
my %opts;
getopts('c:o:hV',\%opts) or die $USAGE;
+ use utf8;
+ binmode(STDOUT, ":utf8");
if ($opts{h} || $opts{V}){
print $VERSION;
@@ -102,6 +108,7 @@ if ($opts{h} || $opts{V}){
if (defined($opts{o})) {
open (OUT, ">$opts{o}") or die "Cannot open file $opts{o} for writing\n";
+ binmode(OUT, ":utf8")
}
@@ -292,7 +299,7 @@ END
###############################################################
sub PrintPaper {
my $paper = shift;
- my $title=SanitizeText($paper->{title});
+ my $title=convert($paper->{title});
my $url=GetURL($paper);
print OUT <<END;
<journal_article publication_type="full_text">
@@ -358,9 +365,7 @@ END
###############################################################
sub SanitizeText {
my $string = shift;
- # There is a bug in the decode function, which we need to work
- # around: it adds space to constructions like \o x
- $string =~ s/(\\[a-zA-Z])\s+/$1/g;
+ $string = convert($string);
$string =~ s/\\newblock//g;
$string =~ s/\\bgroup//g;
$string =~ s/\\egroup//g;
@@ -373,27 +378,9 @@ sub SanitizeText {
$string =~ s/\\doi/DOI: /g;
$string =~ s/\\\\/ /g;
$string =~ s/\$//g;
- # Another bug in decode: it does not understan macrons
- $string =~ s/\\=(A|\{A\})/##SANITIZE#MACRON##256;/g;
- $string =~ s/\\=(a|\{a\})/##SANITIZE#MACRON##257;/g;
- $string =~ s/\\=(E|\{E\})/##SANITIZE#MACRON##274;/g;
- $string =~ s/\\=(e|\{e\})/##SANITIZE#MACRON##275;/g;
- $string =~ s/\\=(I|\{I\})/##SANITIZE#MACRON##298;/g;
- $string =~ s/\\=(i|\{i\})/##SANITIZE#MACRON##299;/g;
- $string =~ s/\\=(O|\{O\})/##SANITIZE#MACRON##332;/g;
- $string =~ s/\\=(o|\{o\})/##SANITIZE#MACRON##333;/g;
- $string =~ s/\\=(U|\{U\})/##SANITIZE#MACRON##362;/g;
- $string =~ s/\\=(u|\{u\})/##SANITIZE#MACRON##363;/g;
- $string = decode('latex', $string);
- $string =~ s/\\[a-zA-Z]+/ /g;
- $string =~ s/\\\\/ /g;
- $string =~ s/[\[\{\}\]]/ /g;
- $string = encode_entities($string);
- $string = XML::Entities::numify('all', $string);
- $string =~ s/amp;//g;
+ $string =~ s/\\checkcomma/,/g;
$string =~ s/~/ /g;
- $string =~ s/\s*([\.;,])/$1/g;
- $string =~ s/##SANITIZE#MACRON##(\d+);/&#$1;/g;
+ $string =~ s/[\{\}]//g;
return $string;
}
@@ -403,11 +390,10 @@ sub SanitizeText {
sub PrintAuthor {
my $author=shift;
- my $person=new Text::BibTeX::Name ($author);
+ my $person=new BibTeX::Parser::Author ($author);
- if ($person->part('first')) {
- my @tokens = $person->part('first');
- my $line = join(" ", @tokens);
+ if ($person->first) {
+ my $line = $person->first;
$line = SanitizeText($line);
print OUT <<END;
<given_name>$line</given_name>
@@ -415,16 +401,19 @@ END
}
- if ($person->part('last')) {
- my $line = SanitizeText($person->part('last'));
+ if ($person->last) {
+ my $line = SanitizeText($person->last);
+ if ($person->von) {
+ $line = SanitizeText($person->von)." $line";
+ }
print OUT <<END;
<surname>$line</surname>
END
}
- if ($person->part('jr')) {
- my $line = SanitizeText($person->part('jr'));
+ if ($person->jr) {
+ my $line = SanitizeText($person->jr);
print OUT <<END;
<suffix>$line</suffix>
END