TeX::Encode(3pm)
π TeX::Encode π
okay bestie, welcome to TeX::Encode β a little Perl module (a 3pm man page, if we're being precise) from the User Contributed Perl Documentation crew. Its whole thing? Encode/decode Perl utf-8 strings into TeX. Let's get into it. π
β¨ NAME β¨
TeX::Encode β Encode/decode Perl utf-8 strings into TeX. That's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
use TeX::Encode;
use Encode;
$tex = encode('latex', "This will encode an e-acute (".chr(0xe9).") as \'e");
$str = decode('latex', $tex); # Will decode the \'e too!
likeβ¦ you encode, you decode, you go about your day. iconic. β¨
π¦ DESCRIPTION π¦
So this module gives you encoding to LaTeX escapes from utf8, using mapping tables. And here's the tea: it only covers a subset of the Unicode character table, so bestie, undef warnings WILL occur for non-mapped chars. Not a bug, just a boundary. π
This module is intentionally vague about what it will handle β peep the Caveats below if you wanna know more. π«Ά
Decoding? Mileage will vary, ngl. Because TeX is in essence a programming language, and this module does not implement TeX. So likeβ¦ manage your expectations, queen. π
Not me using this module to encode author names in BibTeX and to do a rough job at presenting LaTeX abstracts in HTML. It's giving "good enough." Using decode, instead of seeing $\sqrt{\Omega^2\zeta_n}$ you get something that looks like the formula. Which is lowkey the dream, fr fr. π§
The next logical step for this module is to integrate some level of TeX grammar to improve the decoding β in particular to handle fractions and font changes (which should probably be dropped). Main character roadmap energy, honestly. π
π METHODS π
TeX::Encode::encode STRING [, CHECK]β Encodes a utf8 string into TeX.CHECKisn't implemented. (yes, it's literally just there in the signature. it does nothing. we love a placeholder. π)TeX::Encode::decode STRING [, CHECK]β Decodes a TeX string into utf8.CHECKisn't implemented either, same situation, same energy. πTeX::Encode::perlio_okβ Returns0. PerlIO isn't implemented. Short answer, no notes. π
π CAVEATS π
bestie, read this part. it's the "know before you go" section. π
Proper Encode checking is not implemented.
LaTeX comments (% ...) are ignored, because chopping a lot of text may not be what you actually want. (they're being polite about it but the reasoning is sound, ngl.) πΈ
π encode()
Converts non-ASCII Unicode characters to their equivalent TeX symbols. Heads up: unTeXable characters will result in undef warnings. you've been warned, bestie. β
π decode()
Attempts to convert TeX symbols (e.g. \ae) to Unicode characters. As an experimental feature, this also handles Math-mode TeX by inserting HTML into the resulting string β so you end up with an HTML approximation of the maths. NOT MathML. no cap, HTML. π
π₯ SEE ALSO π₯
Encode::EncodingPod::LaTeXEncode
go read those too, iykyk. πβ¨
π AUTHOR π
- Timothy D Brody,
<tdb01r@ecs.soton.ac.uk> - Ahmad Fatoum
"<athreef@cpan.org>",<http://a3f.at>
legends, both of them. π«Ά
π COPYRIGHT AND LICENSE π
Copyright (C) 2005-2007 by Timothy D Brody
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.
and that's the whole page, bestie! π this one's from perl v5.36.0, dated 2022-10-13 β so when you cite it, cite it cute. mwah, go encode something. π πβ¨
π¦ where this page comes from
- ubuntu noble: libtex-encode-perl 2.010-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtex-encode-perl 2.010-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtex-encode-perl 2.010-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms