docutils-ts
Version:
Port of the Python Docutils library to TypeScript
70 lines (69 loc) • 2.9 kB
TypeScript
import { Settings } from "./settings.js";
import { Document, NodeInterface } from "./types.js";
declare function findCombiningChars(text: string): number[];
export declare function getTrimFootnoteRefSpace(settings: Settings): boolean;
declare function columnWidth(text: string): number;
/**
* @deprecated
* @param obj
*/
export declare function isIterable(obj?: {}): boolean;
export declare const punctuation_chars: {
openers: string;
closers: string;
};
declare function escape2null(text: string): string;
/**
* Split `text` on escaped whitespace (null+space or null+newline).
* Return a list of strings.
*/
declare function splitEscapedWhitespace(text: string): string[];
/**
* Indices of Unicode string `text` when skipping combining characters.
*
* >>> from docutils.utils import column_indices
* >>> column_indices(u'A t ab le ')
* [0, 1, 2, 4, 5, 7, 8]
*/
declare function columnIndicies(text: string): number[];
export declare function escapeRegExp(strVal: string): string;
export declare function stripCombiningChars(text: string): string;
export declare function pySplit(text: string, max?: number): string[];
export declare function checkDocumentArg(document: Document): boolean | never;
export declare function relativePath(source: string, target: string): string;
/**
* Return a list of normalized combinations for a `BCP 47` language tag.
*
* Example:
*
* >>> from docutils.utils import normalize_language_tag
* >>> normalize_language_tag('de_AT-1901')
* ['de-at-1901', 'de-at', 'de-1901', 'de']
* >>> normalize_language_tag('de-CH-x_altquot')
* ['de-ch-x-altquot', 'de-ch', 'de-x-altquot', 'de']
*/
declare function normalizedLanguageTag(tag: string): string[];
/**
* Return a dictionary mapping extension option names to converted values.
*
* :Parameters:
* - `field_list`: A flat field list without field arguments, where each
* field body consists of a single paragraph only.
* - `options_spec`: Dictionary mapping known option names to a
* conversion function such as `int` or `float`.
*
* :Exceptions:
* - `KeyError` for unknown option names.
* - `ValueError` for invalid option values (raised by the conversion
* function).
* - `TypeError` for invalid option value types (raised by conversion
* function).
* - `DuplicateOptionError` for duplicate options.
* - `BadOptionError` for invalid fields.
* - `BadOptionDataError` for invalid option data (missing name,
* missing data, bad quotes, etc.).
*/
export declare function extractExtensionOptions(fieldList: NodeInterface, optionsSpec: {}): {} | undefined;
export declare function fromRoman(roman: string, accept: boolean): number;
export declare function _getCallerFileAndLine(): [string | null | undefined, number | null | undefined];
export { findCombiningChars, columnWidth, escape2null, splitEscapedWhitespace, columnIndicies, normalizedLanguageTag };