Operator Type:
Operator Scope of Action:
Operator Purpose:
Operator First Added:
Operator Last Altered:
Operator Has Optional Arguments:
Function [other Function type actions]
Document [operators of similar scope]
Document configuration [other Document configuration operators]
Baseline
As at baseline
Syntax note: Operators without any defined mandatory arguments may omit their empty closing parentheses
document()
document
document() or document returns a dictionary of useful properties of the current document. The properties of the document are exposed this way (in this order in the dictionary):
- path: the POSIX file path of the current TBX file
- id: the TBX file's internal UUID.
- user-attributes: a list of all the user attributes currently defined in the document
- url: the local file:// URL of the current TBX file.
- name: the full name of the current TBX including the file extension
- link-types: a list of discrete link types currently defined in the document
Importantly, The document() Dictionary object is read-only.
The operator returns the document Dictionary object as a single string:
$Text = document();
Although trailing parentheses are not needed, when calling the 'bare' operator, add parentheses—i.e. document()— may help the user and parse not mistake the operator document for the literal string "document".
As reading the Dictionary data as a single string can be hard, a neater and more easily understood method is use the document.keys() method.
It is possible to address the document() Dictionary directly for a specific key value using the document[keyStr] method.
However, calling document()
with no other handling, returns the entire, unformatted Dictionary contents. To split the items onto separate lines as discrete key:value pairs:
$MyString = document.format("\n");
To get the three values (without their keys) on separate lines:
$MyString = document.format("\n").replace("\n[^:]+:","\n").replace("^[^:]+:","");