Common Lisp Package: DOCUTILS.UTILITIES

Common utilities used by several docutils components

README:

FUNCTION

Public

COPY-STREAM (FROM TO &OPTIONAL COUNT)

Copy from input stream FROM into output stream TO upto COUNT bytes, or until end-of-file if COUNT is NIL

ESCAPE2NULL (STRING &KEY (START 0) (END (LENGTH STRING)))

Return a string with escape-backslashes converted to nulls.

FIND-FILE (PATHNAME &KEY (SEARCH-PATH *SEARCH-PATH*))

Return the first complete pathname for an existing file found by merging pathname with each item in a search path in turn. Returns nil if not found

INDENT-LEVEL (LINE &KEY (TAB-SIZE *TAB-SIZE*))

Returns the indentation level of the line, including tabs as expanded

INDENTED-BLOCK (LINES &KEY (START 0) UNTIL-BLANK (STRIP-INDENT T) BLOCK-INDENT FIRST-INDENT)

Extract and return a vector of indented lines of text. Collect all lines with indentation, determine the minimum indentation, remove the minimum indentation from all indented lines unless STRIP-INDENT is false, and return them. All lines up to but not including the first unindented line will be returned in a new vector. Keyword arguments: START: The index of the first line to examine. UNTIL-BLANK: Stop collecting at the first blank line if true. STRIP-INDENT: Strip common leading indent if true (default). BLOCK-INDENT: The indent of the entire block, if known. FIRST-INDENT: The indent of the first line, if known. Returns values: a new vector of the indented lines with minimum indent removed the amount of the indent a boolean: did the indented block finish with a blank line or EOF?

IS-PREFIX-P (SUBSEQ SEQ &KEY (START 0) (TEST #'EQL))

Return true if subseq is a prefix in seq

IS-SUFFIX-P (SUBSEQ SEQ &KEY (TEST #'EQL))

Return true if subseq is a suffix in seq

LAST-CHAR (STREAM)

Return last character written to the stream

LINE-LENGTH (LINE)

Return length of line excluding trailing whitespace

MAKE-ID (STRING)

Make an ID from string that meets requirements of CSS and html 4.01

RSTRIP (STRING)

Remove trailing white space from string

SPLIT-LINES (STRING)

Return a vector of lines split from string

STRIP (STRING)

Remove prefixing and trailing white space from string

UNESCAPE (TEXT &KEY RESTORE-BACKSLASHES (START 0) END)

Return a string with nulls removed or restored to backslashes. Backslash-escaped spaces are also removed.

UNWRITE-CHAR (STREAM)

Removes last character from buffer and returns it if possible. If buffer was empty returns nil.

WHITESPACE-NORMALISE-NAME (NAME)

Return and whitespace-normalized name.

Undocumented

AUTHOR-SEPARATORS (&OPTIONAL (LANGUAGE *LANGUAGE*))

BABEL (&OPTIONAL (LANGUAGE *LANGUAGE*))

CANONICAL-TEXT (TEXT &OPTIONAL (LANGUAGE *LANGUAGE*))

CONVERT-LENGTH-UNIT (SIZE UNIT)

LATEX-DOUBLE-QUOTE-REPLACEMENT (&OPTIONAL (LANGUAGE *LANGUAGE*))

LATEX-QUOTES (&OPTIONAL (LANGUAGE *LANGUAGE*))

LENGTH-UNIT (UNIT)

LINE-BLANK-P (LINE)

LSTRIP (STRING)

MAKE-NAME (NAME &KEY (CHAR-TRANSFORM #'CHAR-DOWNCASE) (NAMESPACE *NAMESPACE*))

NORMALISE-NAME (NAME)

TRANSLATED-TEXT (TEXT &OPTIONAL (LANGUAGE *LANGUAGE*))

WSP-CHAR-P (C)

Private

JOIN-STRINGS (STRINGS &OPTIONAL (SEPARATOR ))

Return a new string by joining together the STRINGS, separating each string with a SEPARATOR character or string

LINES-LEFT-TRIM (LINES LENGTH &KEY (START 0) (END (LENGTH LINES)))

Trim `length` characters off the beginning of each line, from index `start` to `end`. No whitespace-checking is done on the trimmed text.

NSUBVECTOR (ARRAY START &OPTIONAL (END (LENGTH ARRAY)))

Returns a displaced array on array of element from start to end (default length array)

SPLIT-STRING (STRING &KEY COUNT (DELIMITER +WS+) REMOVE-EMPTY-SUBSEQS)

Split `string' along whitespace as defined by the sequence `ws'. Whitespace which causes a split is elided from the result. The whole string will be split, unless `max' is provided, in which case the string will be split into `max' tokens at most, the last one containing the whole rest of the given `string', if any.

TRANSLATION-CANONICAL (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TRANSLATION-TRANSLATED (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

COPY-TRANSLATION (INSTANCE)

GET-TRANSLATION (LANGUAGE)

MAKE-TRANSLATION (&KEY ((TRANSLATED DUM28) (MAKE-HASH-TABLE TEST #'EQUALP)) ((CANONICAL DUM29) (MAKE-HASH-TABLE TEST #'EQUALP)))

PARSE-TRANSLATIONS (ENTRIES)

STREAM-LINE-LENGTH (STREAM)

SETFTRANSLATION-CANONICAL (NEW-VALUE INSTANCE)

TRANSLATION-P (OBJECT)

SETFTRANSLATION-TRANSLATED (NEW-VALUE INSTANCE)

MACRO

Public

WHEN-BIND ((VAR EXPR) &BODY BODY)

Bind VAR to VALUE of expression, execute body if true

WHILE (TEST &BODY BODY)

Repeat body while test returns true

Undocumented

FOR ((VAR START STOP) &BODY BODY)

WITH-BLOCK-INDENTATION ((N OS) &BODY BODY)

Private

DO-VECTOR ((ELEMENT VECTOR &KEY (COUNTER (GENSYM)) (START 0) END) &BODY BODY)

Iterate over the elements of a vector. Aon each iteration element is bound to the current element and counter to the index of this element. start and end may be used to specify the range of indexes to be iterated over.

GENERIC-FUNCTION

Public

READ-LINES (ENTITY)

Read and return a vector of lines from an entity for subsequent parsing

Private

Undocumented

SETFINDENTATION-LEVEL (V STREAM)

SLOT-ACCESSOR

Public

NAMESPACE (ID)

Return the namespace component of an id or nil if none. Returns other id component as second value

Private

DOCUMENT (NODE)

The Return the document root of the tree containing this node

SETFDOCUMENT (DOCUMENT COMPONENT)

The Set the document to be processed and reset the component

INDENTATION-LEVEL (OBJECT)

Current indentation level

LINE (ELEMENT)

The The line number (1-based) of the beginning of this Node in `source`.

LINE-BREAK-TEST (OBJECT)

Function returns true if character can be used as line break

STREAM-OF (OBJECT)

Actual stream being written to - must be capable of writing characters using write-char

Undocumented

INDENTATION-CHARACTER (OBJECT)

LINE-BUFFER-OF (OBJECT)

VARIABLE

Public

*LANGUAGE*

Default language for processing

*LANGUAGE-DIRECTORY*

Directory in which translation data is held. Each language has a file containing an a-list mapping translated form to a cannonical form

*NAMESPACE*

Prefix namespace for ids

+WSP+

White space characters: Space, Tab, Return, Newline, Page, PageUp

Private

*LENGTH-UNITS*

Conversion from various units to inches

*NAMESPACE-DELIMITER*

Characters used as a delimiter for id namespace component

*SEARCH-PATH*

List of paths to search for dependencies in addition to those specified in settings

*TAB-SIZE*

The amount of space that a tab is equivalent to

*TRANSLATIONS*

Hash table mapping language name to languages

CLASS

Public

LINE-WRAP-STREAM

A simple line-wrapping stream filter

Private

DOCUMENT (NODE)

The main document root element

Undocumented

LINE (ELEMENT)

TRANSLATION