Problem/Motivation
When Content First renders an entity, the output can include navigational and administrative HTML elements that are noise for downstream consumers such as LLMs or documentation tools. Elements like <nav class="pager"> or <ul class="contextual-links"> have no content value and pollute the generated markdown.
There is currently no way to exclude specific elements from processing without patching the module.
Proposed resolution
Add an ignored_selectors configuration key that holds a list of CSS selectors. Before any tag stripping or markdown transformation, elements matching those selectors are removed from the rendered HTML — including their children.
A new static utility class HtmlSelectorRemover handles the removal using Drupal\Component\Utility\Html and Symfony\Component\CssSelector\CssSelectorConverter, following the same pattern as HtmlTagTransformer.
The settings form exposes a textarea (one selector per line) so site administrators can manage the list without deploying code.
Default selectors shipped with the module:
nav.pager— pagination navigationul.contextual-links— Drupal inline admin edit links
Remaining tasks
- Review and commit
User interface changes
A Ignored selectors textarea is added to the Content First settings form at /admin/config/content/content-first. Each line is treated as one CSS selector. The field ships pre-populated via config (not hardcoded in PHP).
API changes
New class Drupal\content_first\HtmlSelectorRemover with a single public static method:
HtmlSelectorRemover::remove(string $html, array $selectors): stringData model changes
A new key ignored_selectors (sequence of strings) is added to content_first.settings. Existing sites are migrated via content_first_update_20003(), which sets the default value of ['nav.pager', 'ul.contextual-links'] if the key is not already present.
Issue fork content_first-3588927
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
gedur commented