Parser final class
Minn\Blocks\Parser · public/minn/src/Minn/Blocks/Parser.php · 114 lines
Parses block markup into a tree. The grammar is the delimiter comment: an opener with optional JSON attributes, a closer, or a self-closing void block; a name without a namespace is core/. Anything outside a block is a freeform block that renders as-is.
Constants and properties
| private | TOKEN = '/<!--\\s+(?P<closer>\\/)?wp:(?P<namespace>[a-z][a-z0-9_-]*\\/)?(?P<name>[a-z][a-z0-9_-]*)\\s+(?P<attrs>\\{(?:(?!\\}\\s+\\/?-->).)*+\\}\\s+)?(?P<void>\\/)?-->/s' |
Public
| static | parse(string $markup): array# | Block markup as a tree of blocks. @return list<Block> |
| static | token(string $markup, int $offset): ?array# | The first block delimiter at or after an offset: where it starts, its length, its name (core/ when it names no namespace), its attributes as written (null when it has none), and whether it closes a block or is a void one. Null when no delimiter follows. @return array{start: int, length: int, name: string, attrs: ?string, closer: bool, void: bool}|null |
| static | contains(string $content, string $name): bool# | Whether serialized content carries a block by name; a bare name means core/, and core blocks are also found by their short delimiter. |
Nothing matches.