@wordpress/blocks
Version:
Block API for WordPress.
43 lines • 1.83 kB
TypeScript
import type { Block, RawBlock, ParseOptions } from '../../types';
/**
* Normalize the raw block by applying the fallback block name if none given,
* sanitize the parsed HTML...
*
* @param rawBlock The raw block object.
* @param options Extra options for handling block parsing.
*
* @return The normalized block object.
*/
export declare function normalizeRawBlock(rawBlock: RawBlock, options?: ParseOptions): RawBlock;
/**
* Given a raw block returned by grammar parsing, returns a fully parsed block.
*
* @param rawBlock The raw block object.
* @param options Extra options for handling block parsing.
*
* @return Fully parsed block.
*/
export declare function parseRawBlock(rawBlock: RawBlock, options?: ParseOptions): Block | undefined;
/**
* Utilizes an optimized token-driven parser based on the Gutenberg grammar spec
* defined through a parsing expression grammar to take advantage of the regular
* cadence provided by block delimiters -- composed syntactically through HTML
* comments -- which, given a general HTML document as an input, returns a block
* list array representation.
*
* This is a recursive-descent parser that scans linearly once through the input
* document. Instead of directly recursing it utilizes a trampoline mechanism to
* prevent stack overflow. This initial pass is mainly interested in separating
* and isolating the blocks serialized in the document and manifestly not in the
* content within the blocks.
*
* @see
* https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/
*
* @param content The post content.
* @param options Extra options for handling block parsing.
*
* @return Block list.
*/
export default function parse(content: string, options?: ParseOptions): Block[];
//# sourceMappingURL=index.d.ts.map