From fc1bb54c399abd1f991be097495ca8fbbf892dc2 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 14 Dec 2020 22:14:21 +0000 Subject: bibtexperllibs (14dec20) git-svn-id: svn://tug.org/texlive/trunk@57137 c570f23f-e606-0410-a88d-b1316a301751 --- .../scripts/bibtexperllibs/LaTeX/ToUnicode.pm | 124 ++- .../bibtexperllibs/LaTeX/ToUnicode/Tables.pm | 880 +++++++++++---------- 2 files changed, 545 insertions(+), 459 deletions(-) (limited to 'Master/texmf-dist/scripts/bibtexperllibs/LaTeX') diff --git a/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode.pm b/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode.pm index cf62cf5a29d..50ae29399a8 100644 --- a/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode.pm +++ b/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode.pm @@ -2,9 +2,9 @@ use strict; use warnings; package LaTeX::ToUnicode; BEGIN { - $LaTeX::ToUnicode::VERSION = '0.05'; + $LaTeX::ToUnicode::VERSION = '0.11'; } -#ABSTRACT: Convert LaTeX commands to Unicode +#ABSTRACT: Convert LaTeX commands to Unicode (simplistically) require Exporter; @@ -22,29 +22,12 @@ sub convert { $string = _convert_german( $string ) if $options{german}; $string = _convert_symbols( $string ); $string = _convert_specials( $string ); + $string = _convert_ligatures( $string ); $string = _convert_markups( $string ); $string =~ s/{(\w*)}/$1/g; $string; } -sub _convert_accents { - my $string = shift; - $string =~ s/(\{\\(.)\{(\\?\w{1,2})\}\})/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # {\"{a}} - $string =~ s/(\{\\(.)(\\?\w{1,2})\})/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # {\"a} - $string =~ s/(\\(.)(\\?\w{1,2}))/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # \"a - $string =~ s/(\\(.)\{(\\?\w{1,2})\})/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # \"{a} - $string; -} - -sub _convert_specials { - my $string = shift; - my $specials = join( '|', @LaTeX::ToUnicode::Tables::SPECIALS ); - my $pattern = qr/\\($specials)/o; - $string =~ s/$pattern/$1/g; - $string =~ s/\\\$/\$/g; - $string; -} - sub _convert_commands { my $string = shift; @@ -56,6 +39,15 @@ sub _convert_commands { $string; } +sub _convert_accents { + my $string = shift; + $string =~ s/(\{\\(.)\{(\\?\w{1,2})\}\})/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # {\"{a}} + $string =~ s/(\{\\(.)(\\?\w{1,2})\})/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # {\"a} + $string =~ s/(\\(.)(\\?\w{1,2}))/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # \"a + $string =~ s/(\\(.)\{(\\?\w{1,2})\})/$LaTeX::ToUnicode::Tables::ACCENTS{$2}{$3} || $1/eg; # \"{a} + $string; +} + sub _convert_german { my $string = shift; @@ -75,18 +67,55 @@ sub _convert_symbols { $string; } -sub _convert_markups { +# Replace \ with . +sub _convert_specials { + my $string = shift; + my $specials = join( '|', @LaTeX::ToUnicode::Tables::SPECIALS ); + my $pattern = qr/\\($specials)/o; + $string =~ s/$pattern/$1/g; + $string =~ s/\\\$/\$/g; + $string; +} + +sub _convert_ligatures { my $string = shift; + # have to convert these in order specified. + my @ligs = @LaTeX::ToUnicode::Tables::LIGATURES; + for (my $i = 0; $i < @ligs; $i+=2) { + my $in = $ligs[$i]; + my $out = $ligs[$i+1]; + $string =~ s/\Q$in\E/$out/g; + } + $string; +} + +# +sub _convert_markups { + my $string = shift; + my $orig_string = $string; + my $markups = join( '|', @LaTeX::ToUnicode::Tables::MARKUPS ); - $string =~ s/(\{[^{}]+)\\(?:$markups)\s+([^{}]+\})/$1$2/g; # { ... \command ... } - my $pattern = qr/\{\\(?:$markups)\s+([^{}]*)\}/o; - $string =~ s/$pattern/$1/g; + + # Remove \textMARKUP{...}, leaving just the {...} + $string =~ s/\\text($markups)\b\s*//g; + + # Remove braces and \command in: {... \command ...} + $string =~ s/(\{[^{}]+)\\(?:$markups)\s+([^{}]+\})/$1$2/g; + # + # Remove braces and \command in: {\command ...} + $string =~ s/\{\\(?:$markups)\s+([^{}]*)\}/$1/g; + # + # Remove: {\command + # Although this will leave unmatched } chars behind, there's no + # alternative without full parsing, since the bib entry will often + # look like: {\em {The TeX{}book}}. Also might, in principle, be + # at the end of a line. + $string =~ s/\{\\(?:$markups)\b\s*//g; + + # Ultimately we remove all braces in ltx2crossrefxml SanitizeText fns, + # so the unmatched braces don't matter ... that code should be moved here. - $string =~ s/``/“/g; - $string =~ s/`/”/g; - $string =~ s/''/‘/g; - $string =~ s/'/’/g; $string; } @@ -103,7 +132,7 @@ LaTeX::ToUnicode - Convert LaTeX commands to Unicode =head1 VERSION -version 0.05 +version 0.11 =head1 SYNOPSIS @@ -111,49 +140,60 @@ version 0.05 convert( '{\"a}' ) eq 'ä'; # true convert( '"a', german => 1 ) eq 'ä'; # true, `german' package syntax - convert( '"a', ) eq '"a'; # not enabled by default + convert( '"a', ) eq '"a'; # not enabled by default + + # more generally: + my $latexstr; + my $unistr = convert($latexstr); =head1 DESCRIPTION This module provides a method to convert LaTeX-style markups for accents etc. into their Unicode equivalents. It translates commands for special characters or accents into their Unicode equivalents and removes formatting commands. +It is not at all bulletproof or complete. -I use this module to convert values from BibTeX files into plain text, if your +This module converts values from BibTeX files into plain text. If your use case is different, YMMV. -In contrast to L, this module does not create HTML of any kind. +In contrast to L, this module does not create HTML of any +kind, including for HTML/XML metacharacters such as E, E, C<&>, +which can appear literally in the output. Entities are other handling +for these has to happen at another level, if need be. =head1 FUNCTIONS -=head2 convert( $string, %options ) +=head2 convert( $latex_string, %options ) -Convert the text in C<$string> that contains LaTeX into a plain(er) Unicode -string. All escape sequences for special characters (e.g. \i, \"a, ...) are -converted, formatting commands (e.g. {\it ...}) are removed. +Convert the text in C<$string> that contains LaTeX into a plain(er) +Unicode string. All escape sequences for accented and special characters +(e.g., \i, \"a, ...) are converted. Basic formatting commands (e.g. {\it +...}) are removed. -C<%options> allows you to enable additional translations. This values are +C<%options> allows you to enable additional translations. These keys are recognized: =over =item C -If true, the commands introduced by the package `german' (e.g. C<"a> eq C<ä>, -note the missing backslash) are also handled. +If this option is set, the commands introduced by the package `german' +(e.g. C<"a> eq C<ä>, note the missing backslash) are also +handled. =back =head1 AUTHOR -Gerhard Gossen and Boris Veytsman +Gerhard Gossen and +Boris Veytsman +L =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 2010-2015 by Gerhard Gossen and Boris Veytsman +This software is copyright (c) 2010-2020 by Gerhard Gossen and Boris Veytsman This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut - diff --git a/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode/Tables.pm b/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode/Tables.pm index 446c46e2158..a9aef548344 100644 --- a/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode/Tables.pm +++ b/Master/texmf-dist/scripts/bibtexperllibs/LaTeX/ToUnicode/Tables.pm @@ -1,6 +1,6 @@ package LaTeX::ToUnicode::Tables; BEGIN { - $LaTeX::ToUnicode::Tables::VERSION = '0.05'; + $LaTeX::ToUnicode::Tables::VERSION = '0.11'; } use strict; use warnings; @@ -9,442 +9,477 @@ use warnings; use utf8; -our %COMMANDS = ( - 'LaTeX' => 'LaTeX', - 'TeX' => 'TEX', - '-' => '', # hypenation - '/' => '', # italic correction - 'log' => 'log', +# Technically not all of these are ligatures, but close enough. +# Order is important, so has to be a list, not a hash. +our @LIGATURES = ( + "---" => "\x{2014}", # em dash + "--" => "\x{2013}", # en dash + "!`" => "\x{00A1}", # inverted exclam + "?`" => "\x{00A1}", # inverted question + "``" => "\x{201c}", # left double + "''" => "\x{201d}", # right double + "`" => "\x{2018}", # left single + "'" => "\x{2019}", # right single ); +# test text: em---dash, en---dash, exc!`am, quest?`ion, ``ld, rd'', `ls, rs'. + +# additions supported in T1 encoding, but we won't (from tex-text.map): +# U+002C U+002C <> U+201E ; ,, -> DOUBLE LOW-9 QUOTATION MARK +# U+003C U+003C <> U+00AB ; << -> LEFT POINTING GUILLEMET +# U+003E U+003E <> U+00BB ; >> -> RIGHT POINTING GUILLEMET our @SPECIALS = ( qw( $ % & _ { } ), '#' ); +our %COMMANDS = ( + 'LaTeX' => 'LaTeX', + 'TeX' => 'TeX', + ' ' => ' ', # control space + '-' => '', # hyphenation + '/' => '', # italic correction + 'dag' => "\x{2020}", + 'ddag' => "\x{2021}", + 'bullet' => "\x{2022}", + 'dots' => "\x{2026}", + 'ldots' => "\x{2026}", + 'epsilon' => "\x{03F5}", + 'varepsilon' => "\x{03B5}", + 'Omega' => "\x{03A9}", + 'omega' => "\x{03C9}", + 'hookrightarrow' => "\x{2194}", + 'log' => 'log', +); + -our %SYMBOLS = ( # Table 3.2 in Lamport - 'aa' => 'å', - 'AA' => 'Å', - 'ae' => 'æ', - 'AE' => 'Æ', - 'dh' => 'ð', - 'DH' => 'Ð', - 'dj' => 'đ', - 'DJ' => 'Ð', - 'i' => chr(0x131), # small dotless i - 'l' => 'ł', - 'L' => 'Ł', - 'ng' => 'ŋ', - 'NG' => 'Ŋ', - 'oe' => 'œ', - 'OE' => 'Œ', - 'o' => 'ø', - 'O' => 'Ø', - 'ss' => 'ß', - 'SS' => 'SS', - 'th' => 'þ', - 'TH' => 'Þ', - 'TM' => chr(0x2122), +our %SYMBOLS = ( # Table 3.2 in Lamport, plus more + 'AA' => "\x{00C5}", # A with ring + 'aa' => "\x{00E5}", + 'AE' => "\x{00C6}", # AE + 'ae' => "\x{00E6}", + 'DH' => "\x{00D0}", # ETH + 'dh' => "\x{00F0}", + 'DJ' => "\x{0110}", # D with stroke + 'dj' => "\x{0111}", + 'i' => "\x{0131}", # small dotless i + 'L' => "\x{0141}", # L with stroke + 'l' => "\x{0142}", + 'NG' => "\x{014A}", # ENG + 'ng' => "\x{014B}", + 'OE' => "\x{0152}", # OE + 'oe' => "\x{0153}", + 'O' => "\x{00D8}", # O with stroke + 'o' => "\x{00F8}", + 'SS' => 'SS', # lately also U+1E9E, but SS seems good enough + 'ss' => "\x{00DF}", + 'TH' => "\x{00DE}", # THORN + 'th' => "\x{00FE}", + 'TM' => "\x{2122}", # trade mark sign ); our %ACCENTS = ( - "\"" => { - A => "\304", - E => "\313", - H => "\x{1e26}", - I => "\317", - O => "\326", - U => "\334", - W => "\x{1e84}", - X => "\x{1e8c}", - Y => "\x{178}", - "\\I" => "\317", - "\\i" => "\357", - a => "\344", - e => "\353", - h => "\x{1e27}", - i => "\357", - o => "\366", - t => "\x{1e97}", - u => "\374", - w => "\x{1e85}", - x => "\x{1e8d}", - y => "\377" + "\"" => { # with diaresis + A => "\x{00C4}", + E => "\x{00CB}", + H => "\x{1E26}", + I => "\x{00CF}", + O => "\x{00D6}", + U => "\x{00DC}", + W => "\x{1E84}", + X => "\x{1E8c}", + Y => "\x{0178}", + "\\I" => "\x{00CF}", + "\\i" => "\x{00EF}", + a => "\x{00E4}", + e => "\x{00EB}", + h => "\x{1E27}", + i => "\x{00EF}", + o => "\x{00F6}", + t => "\x{1E97}", + u => "\x{00FC}", + w => "\x{1E85}", + x => "\x{1E8d}", + y => "\x{00FF}", }, - "'" => { - A => "\301", - AE => "\x{1fc}", - C => "\x{106}", - E => "\311", - G => "\x{1f4}", - I => "\315", - K => "\x{1e30}", - L => "\x{139}", - M => "\x{1e3e}", - N => "\x{143}", - O => "\323", - P => "\x{1e54}", - R => "\x{154}", - S => "\x{15a}", - U => "\332", - W => "\x{1e82}", - Y => "\335", - Z => "\x{179}", - "\\I" => "\315", - "\\i" => "\355", - a => "\341", - ae => "\x{1fd}", - c => "\x{107}", - e => "\351", - g => "\x{1f5}", - i => "\355", - k => "\x{1e31}", - l => "\x{13a}", - m => "\x{1e3f}", - n => "\x{144}", - o => "\363", - p => "\x{1e55}", - r => "\x{155}", - s => "\x{15b}", - u => "\372", - w => "\x{1e83}", - y => "\375", - z => "\x{17a}" + "'" => { # with acute + A => "\x{00C1}", + AE => "\x{01FC}", + C => "\x{0106}", + E => "\x{00C9}", + G => "\x{01F4}", + I => "\x{00CD}", + K => "\x{1E30}", + L => "\x{0139}", + M => "\x{1E3E}", + N => "\x{0143}", + O => "\x{00D3}", + P => "\x{1E54}", + R => "\x{0154}", + S => "\x{015A}", + U => "\x{00DA}", + W => "\x{1E82}", + Y => "\x{00DD}", + Z => "\x{0179}", + "\\I" => "\x{00CD}", + "\\i" => "\x{00ED}", + a => "\x{00E1}", + ae => "\x{01FD}", + c => "\x{0107}", + e => "\x{00E9}", + g => "\x{01F5}", + i => "\x{00ED}", + k => "\x{1E31}", + l => "\x{013A}", + m => "\x{1E3f}", + n => "\x{0144}", + o => "\x{00F3}", + p => "\x{1E55}", + r => "\x{0155}", + s => "\x{015B}", + u => "\x{00FA}", + w => "\x{1E83}", + y => "\x{00FD}", + z => "\x{017A}", }, - "." => { - A => "\x{226}", - B => "\x{1e02}", - C => "\x{10a}", - D => "\x{1e0a}", - E => "\x{116}", - F => "\x{1e1e}", - G => "\x{120}", - H => "\x{1e22}", - I => "\x{130}", - M => "\x{1e40}", - N => "\x{1e44}", - O => "\x{22e}", - P => "\x{1e56}", - R => "\x{1e58}", - S => "\x{1e60}", - T => "\x{1e6a}", - W => "\x{1e86}", - X => "\x{1e8a}", - Y => "\x{1e8e}", - Z => "\x{17b}", - "\\I" => "\x{130}", - a => "\x{227}", - b => "\x{1e03}", - c => "\x{10b}", - d => "\x{1e0b}", - e => "\x{117}", + "." => { # with dot above + A => "\x{0226}", + B => "\x{1E02}", + C => "\x{010A}", + D => "\x{1E0A}", + E => "\x{0116}", + F => "\x{1E1E}", + G => "\x{0120}", + H => "\x{1E22}", + I => "\x{0130}", + M => "\x{1E40}", + N => "\x{1E44}", + O => "\x{022E}", + P => "\x{1E56}", + R => "\x{1E58}", + S => "\x{1E60}", + T => "\x{1E6a}", + W => "\x{1E86}", + X => "\x{1E8A}", + Y => "\x{1E8E}", + Z => "\x{017B}", + "\\I" => "\x{0130}", + a => "\x{0227}", + b => "\x{1E03}", + c => "\x{010B}", + d => "\x{1E0B}", + e => "\x{0117}", f => "\x{1e1f}", - g => "\x{121}", - h => "\x{1e23}", - m => "\x{1e41}", - n => "\x{1e45}", - o => "\x{22f}", - p => "\x{1e57}", - r => "\x{1e59}", - s => "\x{1e61}", - t => "\x{1e6b}", - w => "\x{1e87}", - x => "\x{1e8b}", - y => "\x{1e8f}", - z => "\x{17c}" + g => "\x{0121}", + h => "\x{1E23}", + m => "\x{1E41}", + n => "\x{1E45}", + o => "\x{022F}", + p => "\x{1E57}", + r => "\x{1E59}", + s => "\x{1E61}", + t => "\x{1E6b}", + w => "\x{1E87}", + x => "\x{1E8b}", + y => "\x{1E8f}", + z => "\x{017C}", + }, + '=' => { # with macron + A => "\x{0100}", + AE => "\x{01E2}", + E => "\x{0112}", + G => "\x{1E20}", + I => "\x{012A}", + O => "\x{014C}", + U => "\x{016A}", + Y => "\x{0232}", + "\\I" => "\x{012A}", + "\\i" => "\x{012B}", + a => "\x{0101}", + ae => "\x{01E3}", + e => "\x{0113}", + g => "\x{1E21}", + i => "\x{012B}", + o => "\x{014D}", + u => "\x{016B}", + y => "\x{0233}", }, - '=' => { - A => "\x{100}", - AE => "\x{1e2}", - E => "\x{112}", - G => "\x{1e20}", - I => "\x{12a}", - O => "\x{14c}", - U => "\x{16a}", - Y => "\x{232}", - "\\I" => "\x{12a}", - "\\i" => "\x{12b}", - a => "\x{101}", - ae => "\x{1e3}", - e => "\x{113}", - g => "\x{1e21}", - i => "\x{12b}", - o => "\x{14d}", - u => "\x{16b}", - y => "\x{233}" + "H" => { # with double acute + O => "\x{0150}", + U => "\x{0170}", + o => "\x{0151}", + u => "\x{0171}", }, - H => { - O => "\x{150}", - U => "\x{170}", - o => "\x{151}", - u => "\x{171}" + "^" => { # with circumflex + A => "\x{00C2}", + C => "\x{0108}", + E => "\x{00CA}", + G => "\x{011C}", + H => "\x{0124}", + I => "\x{00CE}", + J => "\x{0134}", + O => "\x{00D4}", + S => "\x{015C}", + U => "\x{00DB}", + W => "\x{0174}", + Y => "\x{0176}", + Z => "\x{1E90}", + "\\I" => "\x{00CE}", + "\\J" => "\x{0134}", + "\\i" => "\x{00EE}", + "\\j" => "\x{0135}", + a => "\x{00E2}", + c => "\x{0109}", + e => "\x{00EA}", + g => "\x{011D}", + h => "\x{0125}", + i => "\x{00EE}", + j => "\x{0135}", + o => "\x{00F4}", + s => "\x{015D}", + u => "\x{00FB}", + w => "\x{0175}", + y => "\x{0177}", + z => "\x{1E91}", }, - "^" => { - A => "\302", - C => "\x{108}", - E => "\312", - G => "\x{11c}", - H => "\x{124}", - I => "\316", - J => "\x{134}", - O => "\324", - S => "\x{15c}", - U => "\333", - W => "\x{174}", - Y => "\x{176}", - Z => "\x{1e90}", - "\\I" => "\316", - "\\i" => "\356", - a => "\342", - c => "\x{109}", - e => "\352", - g => "\x{11d}", - h => "\x{125}", - i => "\356", - j => "\x{135}", - o => "\364", - s => "\x{15d}", - u => "\373", - w => "\x{175}", - y => "\x{177}", - z => "\x{1e91}" + "`" => { # with grave + A => "\x{00C0}", + E => "\x{00C8}", + I => "\x{00CC}", + N => "\x{01F8}", + O => "\x{00D2}", + U => "\x{00D9}", + W => "\x{1E80}", + Y => "\x{1Ef2}", + "\\I" => "\x{00CC}", + "\\i" => "\x{00EC}", + a => "\x{00E0}", + e => "\x{00E8}", + i => "\x{00EC}", + n => "\x{01F9}", + o => "\x{00F2}", + u => "\x{00F9}", + w => "\x{1E81}", + y => "\x{1EF3}", }, - "`" => { - A => "\300", - E => "\310", - I => "\314", - N => "\x{1f8}", - O => "\322", - U => "\331", - W => "\x{1e80}", - Y => "\x{1ef2}", - "\\I" => "\314", - "\\i" => "\354", - a => "\340", - e => "\350", - i => "\354", - n => "\x{1f9}", - o => "\362", - u => "\371", - w => "\x{1e81}", - y => "\x{1ef3}" + "c" => { # with cedilla + C => "\x{00C7}", + D => "\x{1E10}", + E => "\x{0228}", + G => "\x{0122}", + H => "\x{1E28}", + K => "\x{0136}", + L => "\x{013B}", + N => "\x{0145}", + R => "\x{0156}", + S => "\x{015E}", + T => "\x{0162}", + c => "\x{00E7}", + d => "\x{1E11}", + e => "\x{0229}", + g => "\x{0123}", + h => "\x{1E29}", + k => "\x{0137}", + l => "\x{013C}", + n => "\x{0146}", + r => "\x{0157}", + s => "\x{015F}", + t => "\x{0163}", }, - c => { - C => "\307", - D => "\x{1e10}", - E => "\x{228}", - G => "\x{122}", - H => "\x{1e28}", - K => "\x{136}", - L => "\x{13b}", - N => "\x{145}", - R => "\x{156}", - S => "\x{15e}", - T => "\x{162}", - c => "\347", - d => "\x{1e11}", - e => "\x{229}", - g => "\x{123}", - h => "\x{1e29}", - k => "\x{137}", - l => "\x{13c}", - n => "\x{146}", - r => "\x{157}", - s => "\x{15f}", - t => "\x{163}" + "d" => { # with dot below + A => "\x{1EA0}", + B => "\x{1E04}", + D => "\x{1E0C}", + E => "\x{1EB8}", + H => "\x{1E24}", + I => "\x{1ECA}", + K => "\x{1E32}", + L => "\x{1E36}", + M => "\x{1E42}", + N => "\x{1E46}", + O => "\x{1ECC}", + R => "\x{1E5A}", + S => "\x{1E62}", + T => "\x{1E6C}", + U => "\x{1EE4}", + V => "\x{1E7E}", + W => "\x{1E88}", + Y => "\x{1Ef4}", + Z => "\x{1E92}", + "\\I" => "\x{1ECA}", + "\\i" => "\x{1ECB}", + a => "\x{1EA1}", + b => "\x{1E05}", + d => "\x{1E0D}", + e => "\x{1EB9}", + h => "\x{1E25}", + i => "\x{1ECB}", + k => "\x{1E33}", + l => "\x{1E37}", + m => "\x{1E43}", + n => "\x{1E47}", + o => "\x{1ECD}", + r => "\x{1E5b}", + s => "\x{1E63}", + t => "\x{1E6D}", + u => "\x{1EE5}", + v => "\x{1E7F}", + w => "\x{1E89}", + y => "\x{1EF5}", + z => "\x{1E93}", }, - d => { - A => "\x{1ea0}", - B => "\x{1e04}", - D => "\x{1e0c}", - E => "\x{1eb8}", - H => "\x{1e24}", - I => "\x{1eca}", - K => "\x{1e32}", - L => "\x{1e36}", - M => "\x{1e42}", - N => "\x{1e46}", - O => "\x{1ecc}", - R => "\x{1e5a}", - S => "\x{1e62}", - T => "\x{1e6c}", - U => "\x{1ee4}", - V => "\x{1e7e}", - W => "\x{1e88}", - Y => "\x{1ef4}", - Z => "\x{1e92}", - "\\I" => "\x{1eca}", - "\\i" => "\x{1ecb}", - a => "\x{1ea1}", - b => "\x{1e05}", - d => "\x{1e0d}", - e => "\x{1eb9}", - h => "\x{1e25}", - i => "\x{1ecb}", - k => "\x{1e33}", - l => "\x{1e37}", - m => "\x{1e43}", - n => "\x{1e47}", - o => "\x{1ecd}", - r => "\x{1e5b}", - s => "\x{1e63}", - t => "\x{1e6d}", - u => "\x{1ee5}", - v => "\x{1e7f}", - w => "\x{1e89}", - y => "\x{1ef5}", - z => "\x{1e93}" + "h" => { # with hook above + A => "\x{1EA2}", + E => "\x{1EBA}", + I => "\x{1EC8}", + O => "\x{1ECe}", + U => "\x{1EE6}", + Y => "\x{1EF6}", + "\\I" => "\x{1EC8}", + "\\i" => "\x{1EC9}", + a => "\x{1EA3}", + e => "\x{1EBB}", + i => "\x{1EC9}", + o => "\x{1ECF}", + u => "\x{1EE7}", + y => "\x{1EF7}", }, - h => { - A => "\x{1ea2}", - E => "\x{1eba}", - I => "\x{1ec8}", - O => "\x{1ece}", - U => "\x{1ee6}", - Y => "\x{1ef6}", - "\\I" => "\x{1ec8}", - "\\i" => "\x{1ec9}", - a => "\x{1ea3}", - e => "\x{1ebb}", - i => "\x{1ec9}", - o => "\x{1ecf}", - u => "\x{1ee7}", - y => "\x{1ef7}" + "k" => { # with ogonek + A => "\x{0104}", + E => "\x{0118}", + I => "\x{012E}", + O => "\x{01EA}", + U => "\x{0172}", + "\\I" => "\x{012E}", + "\\i" => "\x{012F}", + a => "\x{0105}", + e => "\x{0119}", + i => "\x{012F}", + o => "\x{01EB}", + u => "\x{0173}", }, - k => { - A => "\x{104}", - E => "\x{118}", - I => "\x{12e}", - O => "\x{1ea}", - U => "\x{172}", - "\\I" => "\x{12e}", - "\\i" => "\x{12f}", - a => "\x{105}", - e => "\x{119}", - i => "\x{12f}", - o => "\x{1eb}", - u => "\x{173}" + "r" => { # with ring above + A => "\x{00C5}", + U => "\x{016E}", + a => "\x{00E5}", + u => "\x{016F}", + w => "\x{1E98}", + y => "\x{1E99}", }, - r => { - A => "\305", - U => "\x{16e}", - a => "\345", - u => "\x{16f}", - w => "\x{1e98}", - y => "\x{1e99}" + "u" => { # with breve + A => "\x{0102}", + E => "\x{0114}", + G => "\x{011E}", + I => "\x{012C}", + O => "\x{014E}", + U => "\x{016C}", + "\\I" => "\x{012C}", + "\\i" => "\x{012D}", + a => "\x{0103}", + e => "\x{0115}", + g => "\x{011F}", + i => "\x{012D}", + o => "\x{014F}", + u => "\x{016D}", }, - u => { - A => "\x{102}", - E => "\x{114}", - G => "\x{11e}", - I => "\x{12c}", - O => "\x{14e}", - U => "\x{16c}", - "\\I" => "\x{12c}", - "\\i" => "\x{12d}", - a => "\x{103}", - e => "\x{115}", - g => "\x{11f}", - i => "\x{12d}", - o => "\x{14f}", - u => "\x{16d}" + "v" => { # with caron + A => "\x{01CD}", + C => "\x{010C}", + D => "\x{010E}", + DZ => "\x{01C4}", + E => "\x{011A}", + G => "\x{01E6}", + H => "\x{021E}", + I => "\x{01CF}", + K => "\x{01E8}", + L => "\x{013D}", + N => "\x{0147}", + O => "\x{01D1}", + R => "\x{0158}", + S => "\x{0160}", + T => "\x{0164}", + U => "\x{01D3}", + Z => "\x{017D}", + "\\I" => "\x{01CF}", + "\\i" => "\x{01D0}", + "\\j" => "\x{01F0}", + a => "\x{01CE}", + c => "\x{010D}", + d => "\x{010F}", + dz => "\x{01C6}", + e => "\x{011B}", + g => "\x{01E7}", + h => "\x{021F}", + i => "\x{01D0}", + j => "\x{01F0}", + k => "\x{01E9}", + l => "\x{013E}", + n => "\x{0148}", + o => "\x{01D2}", + r => "\x{0159}", + s => "\x{0161}", + t => "\x{0165}", + u => "\x{01D4}", + z => "\x{017E}", }, - v => { - A => "\x{1cd}", - C => "\x{10c}", - D => "\x{10e}", - DZ => "\x{1c4}", - E => "\x{11a}", - G => "\x{1e6}", - H => "\x{21e}", - I => "\x{1cf}", - K => "\x{1e8}", - L => "\x{13d}", - N => "\x{147}", - O => "\x{1d1}", - R => "\x{158}", - S => "\x{160}", - T => "\x{164}", - U => "\x{1d3}", - Z => "\x{17d}", - "\\I" => "\x{1cf}", - "\\i" => "\x{1d0}", - a => "\x{1ce}", - c => "\x{10d}", - d => "\x{10f}", - dz => "\x{1c6}", - e => "\x{11b}", - g => "\x{1e7}", - h => "\x{21f}", - i => "\x{1d0}", - j => "\x{1f0}", - k => "\x{1e9}", - l => "\x{13e}", - n => "\x{148}", - o => "\x{1d2}", - r => "\x{159}", - s => "\x{161}", - t => "\x{165}", - u => "\x{1d4}", - z => "\x{17e}" + "~" => { # with tilde + A => "\x{00C3}", + E => "\x{1EBC}", + I => "\x{0128}", + N => "\x{00D1}", + O => "\x{00D5}", + U => "\x{0168}", + V => "\x{1E7C}", + Y => "\x{1EF8}", + "\\I" => "\x{0128}", + "\\i" => "\x{0129}", + a => "\x{00E3}", + e => "\x{1EBD}", + i => "\x{0129}", + n => "\x{00F1}", + o => "\x{00F5}", + u => "\x{0169}", + v => "\x{1E7D}", + y => "\x{1EF9}", }, - "~" => { - A => "\303", - E => "\x{1ebc}", - I => "\x{128}", - N => "\321", - O => "\325", - U => "\x{168}", - V => "\x{1e7c}", - Y => "\x{1ef8}", - "\\I" => "\x{128}", - "\\i" => "\x{129}", - a => "\343", - e => "\x{1ebd}", - i => "\x{129}", - n => "\361", - o => "\365", - u => "\x{169}", - v => "\x{1e7d}", - y => "\x{1ef9}" - } ); our %GERMAN = ( # for package `german'/`ngerman' - '"a' => 'ä', - '"A' => 'Ä', - '"e' => 'ë', - '"E' => 'Ë', - '"i' => 'ï', - '"I' => 'Ï', - '"o' => 'ö', - '"O' => 'Ö', - '"u' => 'ü', - '"U' => 'Ü', - '"s' => 'ß', - '"S' => 'SS', - '"z' => 'ß', - '"Z' => 'SZ', - '"ck' => 'ck', # old spelling: ck -> k-k - '"ff' => 'ff', # old spelling: ff -> ff-f - '"`' => '„', - "\"'" => '“', - '"<' => '«', - '">' => '»', - '"-' => "\x{AD}", # soft hyphen - '""' => "\x{200B}", # zero width space - '"~' => "\x{2011}", # non-breaking hyphen - '"=' => '-', - '\glq' => '‚', # left german single quote - '\grq' => '‘', # right german single quote - '\flqq' => '«', - '\frqq' => '»', - '\dq' => '"', + '"a' => 'ä', + '"A' => 'Ä', + '"e' => 'ë', + '"E' => 'Ë', + '"i' => 'ï', + '"I' => 'Ï', + '"o' => 'ö', + '"O' => 'Ö', + '"u' => 'ü', + '"U' => 'Ü', + '"s' => 'ß', + '"S' => 'SS', + '"z' => 'ß', + '"Z' => 'SZ', + '"ck' => 'ck', # old spelling: ck -> k-k + '"ff' => 'ff', # old spelling: ff -> ff-f + '"`' => '„', + "\"'" => '“', + '"<' => '«', + '">' => '»', + '"-' => "\x{AD}", # soft hyphen + '""' => "\x{200B}", # zero width space + '"~' => "\x{2011}", # non-breaking hyphen + '"=' => '-', + '\glq' => '‚', # left german single quote + '\grq' => '‘', # right german single quote + '\flqq' => '«', + '\frqq' => '»', + '\dq' => '"', ); -our @MARKUPS = ( qw( em tt small sl bf sc rm it cal ) ); +# for {\MARKUP ...} and \textMARKUP{...} +our @MARKUPS = ( qw( bf cal em it rm sc sl small tt ) ); + 1; @@ -459,18 +494,27 @@ LaTeX::ToUnicode::Tables - Character tables for LaTeX::ToUnicode =head1 VERSION -version 0.05 +version 0.11 =head1 CONSTANTS -=head2 %COMMANDS +=head2 @LIGATURES -Names of argument-less commands like C<\LaTeX> as keys. -Values are the replacements. +Standard TeX character sequences (not \commands) which need to be +replaced: C<---> with U+2014 (em dash), etc. Includes: em dash, en +dash, inverted exclamation, inverted question, left double quote, right +double quote, left single quote, right single quote. =head2 @SPECIALS -TeX's metacharacters that need to be escaped in TeX documents +Most of TeX's metacharacters, i.e., those for which C<\I> typesets +I: C<$ % & _ { } #>. TeX has other special characters which are not +included here, for instance: C<\ ^ ~>. + +=head2 %COMMANDS + +Names of argument-less commands like C<\LaTeX> as keys. +Values are the replacements. =head2 %SYMBOLS @@ -485,19 +529,22 @@ the decoded characters. As an example, C<< $ACCENTS{'`'}->{a} eq 'à' >>. =head2 %GERMAN -Escape sequences as defined by the package `german'/`ngerman', e.g. -C<"a> (a with umlaut), C<"s> (german sharp s) or C<"`"> (german left quote). -Note the missing backslash. +Character sequences (not necessarily commands) as defined by the package +`german'/`ngerman', e.g. C<"a> (a with umlaut), C<"s> (german sharp s) +or C<"`"> (german left quote). Note the missing backslash. -The keys of this hash are the literal escape sequences. +The keys of this hash are the literal character sequences. =head2 @MARKUPS -Command names of formatting commands like C<\tt> +Command names of formatting commands like C<\tt>, namely: +C. =head1 AUTHOR -Gerhard Gossen and Boris Veytsman +Gerhard Gossen and +Boris Veytsman +L =head1 COPYRIGHT AND LICENSE @@ -507,4 +554,3 @@ This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut - -- cgit v1.2.3