C.1 Common Modules

LaTeXML::Common::Object

Abstract base class for most LaTeXML objects.

Description

LaTeXML::Common::Object serves as an abstract base class for all other objects (both the data objects and control objects). It provides for common methods for stringification and comparison operations to simplify coding and to beautify error reporting.

Generic functions

$string = Stringify($object);

Returns a string identifying $object, for debugging. Works on any values and objects, but invokes the stringify method on blessed objects. More informative than the default perl conversion to a string.

$string = ToString($object);

Converts $object to string attempting, when possible, to generate straight text without TeX markup. This is most useful for converting Tokens or Boxes to document content or attribute values, or values to be used for pathnames, keywords, etc. Generally, however, it is not possible to convert Whatsits generated by Constructors into clean strings, without TeX markup. Works on any values and objects, but invokes the toString method on blessed objects.

$boolean = Equals($x,$y);

Compares the two objects for equality. Works on any values and objects, but invokes the equals method on blessed objects, which does a deep comparison of the two objects.

$tokens = Revert($object);

Returns a Tokens list containing the TeX that would create $object. Note that this is not necessarily the original TeX code; expansions or other substitutions may have taken place.

Methods

$string = $object->stringify;

Returns a readable representation of $object, useful for debugging.

$string = $object->toString;

Returns the string content of $object; most useful for extracting a clean, usable, Unicode string from tokens or boxes that might representing a filename or such. To the extent possible, this should provide a string that can be used as XML content, or attribute values, or for filenames or whatever. However, control sequences defined as Constructors may leave TeX code in the value.

$boole = $object->equals($other);

Returns whether $object and $other are equal. Should perform a deep comparision, but the default implementation just compares for object identity.

$boole = $object->isaToken;

Returns whether $object is an LaTeXML::Core::Token.

$boole = $object->isaBox;

Returns whether $object is an LaTeXML::Core::Box.

$boole = $object->isaDefinition;

Returns whether $object is an LaTeXML::Core::Definition.

$digested = $object->beDigested;

Does whatever is needed to digest the object, and return the digested representation. Tokens would be digested into boxes; Some objects, such as numbers can just return themselves.

$object->beAbsorbed($document);

Do whatever is needed to absorb the $object into the $document, typically by invoking appropriate methods on the $document.