File perl-LaTeX-ToUnicode.spec of Package perl-LaTeX-ToUnicode

#
# spec file for package perl-LaTeX-ToUnicode
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define cpan_name LaTeX-ToUnicode
Name:           perl-LaTeX-ToUnicode
Version:        1.93
Release:        0
License:        Artistic-1.0 OR GPL-1.0-or-later
Summary:        Convert LaTeX commands to Unicode
URL:            https://metacpan.org/release/%{cpan_name}
Source0:        https://cpan.metacpan.org/authors/id/B/BO/BORISV/%{cpan_name}-%{version}.tar.gz
BuildArch:      noarch
BuildRequires:  perl
BuildRequires:  perl-macros
BuildRequires:  perl(ExtUtils::MakeMaker) >= 6.31
BuildRequires:  perl(Pod::LaTeX) >= 0.61
%{perl_requires}

%description
This module provides a method to convert LaTeX markups for accents etc.
into their Unicode equivalents. It translates some commands for special
characters or accents into their Unicode (or HTML) equivalents and removes
formatting commands. It is not at all bulletproof or complete.

This module is intended to convert fragments of LaTeX source, such as
bibliography entries and abstracts, into plain text (or, optionally,
simplistic HTML). It is not a document conversion system. Math, tables,
figures, sectioning, etc., are not handled in any way, and mostly left in
their TeX form in the output. The translations assume standard LaTeX
meanings for characters and control sequences; macros in the input are not
considered.

The aim for all the output is utter simplicity and minimalism, not faithful
translation. For example, although Unicode has a code point for a thin
space, the LaTeX '\thinspace' (etc.) command is translated to the empty
string; such spacing refinements desirable in the TeX output are, in our
experience, generally not desired in the HTML output from this tool.

As another example, TeX '%' comments are not removed, even on lines by
themselves, because they may be inside verbatim blocks, and we don't
attempt to keep any such context. In practice, TeX comments are rare in the
text fragments intended to be handled, so removing them in advance has not
been a great burden.

As another example, LaTeX ties, '~' characters, are replaced with normal
spaces (exception: unless they follow a '/' character or at the beginning
of a line, when they're assumed to be part of a url or a pathname), rather
than a no-break space character, because in our experience most ties
intended for the TeX output would just cause trouble in plain text or HTML.

Regarding normal whitespace: all leading and trailing horizontal whitespace
(that is, SPC and TAB) is removed. All internal horizontal whitespace
sequences are collapsed to a single space.

After the conversions, all brace characters ('{}') are simply removed from
the returned string. This turns out to be a significant convenience in
practice, since many LaTeX commands which take arguments don't need to do
anything for our purposes except output the argument.

On the other hand, backslashes are not removed. This is so the caller can
check for '\\' and thus discover untranslated commands. Of course there are
many other constructs that might not be translated, or translated wrongly.
There is no escaping the need to carefully look at the output.

Suggestions and bug reports are welcome for practical needs; we know full
well that there are hundreds of commands not handled that could be.
Virtually all the behavior mentioned here would be easily made
customizable, if there is a need to do so.

%prep
%autosetup  -n %{cpan_name}-%{version}

find . -type f ! -path "*/t/*" ! -name "*.pl" ! -path "*/bin/*" ! -path "*/script/*" ! -path "*/scripts/*" ! -name "configure" -print0 | xargs -0 chmod 644

%build
perl Makefile.PL INSTALLDIRS=vendor
%make_build

%check
make test

%install
%perl_make_install
%perl_process_packlist
%perl_gen_filelist

%files -f %{name}.files
%doc Changes head.ltx Makefile.TDS README
%license LICENSE

%changelog
openSUSE Build Service is sponsored by