API / Minn\Content / Excerpt

Excerpt final class

Minn\Content\Excerpt · public/minn/src/Minn/Content/Excerpt.php · 90 lines

The reference's generated excerpt, as captured from probe posts:

- Only text-bearing blocks contribute. Containers (group, columns, column, media-text) pass their allowed children through; anything not on the list vanishes with everything inside it (code, details, buttons, images, galleries, covers, dynamic blocks, and the nested list-item, so a modern list contributes nothing while a classic one does). - The text stops at the first <!--more--> (in a feed it runs on). - Block-level tags read as spaces; inline tags (and <br>) read as nothing. - Whitespace collapses, 55 words, an ellipsis when cut, wrapped in <p>, texturized (a feed texturizes first, so its inline code stays raw). A hand-written excerpt skips the block filter.

Constants and properties

privateALLOWED = array ( 0 => 'core/paragraph', 1 => 'core/heading', 2 => 'core/list', 3 => 'core/quote', 4 => 'core/pullquote', 5 => 'core/verse', 6 => 'core/preformatted', 7 => 'core/table', 8 => 'core/group', 9 => 'core/columns', 10 => 'core/column', 11 => 'core/media-text', 12 => 'core/html', 13 => 'core/more', 14 => 'core/freeform', )
privateINLINE = array ( 0 => 'a', 1 => 'abbr', 2 => 'b', 3 => 'bdi', 4 => 'bdo', 5 => 'br', 6 => 'cite', 7 => 'code', 8 => 'data', 9 => 'dfn', 10 => 'em', 11 => 'i', 12 => 'kbd', 13 => 'mark', 14 => 'q', 15 => 's', 16 => 'samp', 17 => 'small', 18 => 'span', 19 => 'strong', 20 => 'sub', 21 => 'sup', 22 => 'time', 23 => 'u', 24 => 'var', 25 => 'wbr', 26 => 'del', 27 => 'ins', )

Public

staticrender(Minn\Content\PostRecord $post): string#

The more tag ends a listing's excerpt but not a feed's, and a feed texturizes before the tags go (so inline code keeps straight quotes) where a listing texturizes the finished text.

Internals 4

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatesource(Minn\Content\PostRecord $post): string#

The stored excerpt, or the content's allowed markup.

privatewords(string $source): string#

The first 55 words with tags gone, an ellipsis when cut, empty for none.

privaterecordRendered(array $blocks): void#

A generated excerpt drops the disallowed blocks first and renders the rest before trimming, so the allowed blocks count as rendered on the page: the stylesheet prints their block styles even when nothing of theirs survives the trim.

$blockslist<Block>
privateallowedMarkup(array $blocks): string#