yini-parser
Version:
Node.js parser for YINI — a clean, structured INI alternative with types, simple section nesting, comments, and strict mode.
32 lines (31 loc) • 1.61 kB
TypeScript
import { ErrorDataHandler } from '../core/ErrorDataHandler';
import { SectionContext } from '../grammar/YiniParser';
/**
* Check and identify the section header parts via tokenizing the parts and return them as strings.
* @param rawHeaderLine Raw line with the section header where the header
* marker will be identified. E.g. does the header start with '^^^' or '^3'
* and then some identifier.
*
* Below, copied from YINI Specification v1.0.0 Beta 7.
* Form 1: Identifier of Simple Form:
* - Keys must be non-empty.
* - Keys are case-sensitive (`Title` and `title` are different).
* - Can only contain letters (a-z or A-Z), digits (0-9) and underscores `_`.
* - Must begin with a letter or an underscore `_`.
* - Note: Cannot contain hyphens (`-`) or periods (`.`).
*
* Form 2: Backticked Identifier:
* - A phrase is a name wrapped in backticks ``` ` ```.
* - Backticked identifiers must be on a single line and must not contain tabs or new lines unless using escaping codes, except for ordinary spaces.
* - Special control characters (U+0000–U+001F) must be escaped.
*
* @note Returns the parts as strings; each part needs to be analyzed separately against the contraints in the specifications.
* @returns An object with the identified header parts: marker characters, parsed name, and parsed level string.
*/
declare const extractHeaderParts: (rawLine: string, errorHandler?: ErrorDataHandler | null, ctx?: SectionContext | null) => {
strMarkerChars: string;
strSectionName: string;
strNumberPart: string;
isBacktickedName: boolean;
};
export default extractHeaderParts;