NAME

LaTeXML::Common::Locator - represents a reference to a point or range in the source file.

DESCRIPTION

LaTeXML::Common::Locator contains a reference to a point or range within a source file. This data structure is intended to be used both programtically (for "source references") and to display error messages to the user.

It extends LaTeXML::Common::Object.

Locator Creation

$locator = LaTeXML::Common::Locator->new($source, $fromLine, $fromCol, $toLine, $toCol);

Creates a new locator. $source should be a string containing the full path of the source file, an empty string in case of a literal string, or undef in case of an anonymous string. $fromLine and $fromCol should be integers containing the line and column numbers of the start of the range in the source file, or undef if unknown. $toLine and $toCol should be the integers containing the line and column numbers of the end of the range, or undef if a point is being refered to.

$locator = LaTeXML::Common::Locator->newRange($from, $to);

Creates a new locator, starting at the locator $from and ending at the locator $to. Either locator may be undef, in which case the other one is returned.

Methods

$str = $locator->toString;

Turns this locator into a short string for output in user messages.

$str = $locator->stringify;

Turns this locator into a long string, including the full filename of the input.

$attr = $locator->toAttribute;

Turns this locator into an XPointer expression, for usage within an XML attribute.

$isRange = $locator->isRange;

Checks if this locator points to a range or a point.

$source = $locator->getShortSource($stringSource);

Gets a short string refering to the source of this locator. $stringSource will be used if the source refers to an anonymous or literal string input.

$from = $locator->getFromLocator;

Gets a locator pointing to the first point in the range of this locator. Works for both point and range locators.

$from = $locator->getToLocator;

Gets a locator pointing to the last point in the range of this locator. Does not work for point locators.

AUTHOR

Bruce Miller <bruce.miller@nist.gov> Tom Wiesing <tom.wiesing@gmail.com>

COPYRIGHT

Public domain software, produced as part of work done by the United States Government & not subject to copyright in the US.