Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
templateoption replaces the markup for each entity, butEntityRenderer.render_entsalways wraps the result inTPL_ENTS, so the outer<div class="entities">cannot be changed.EntityRenderernow reads an optionalents_templateand falls back toTPL_ENTSwhen it is unset. It is a format string with the same{content}and{dir}fields asTPL_ENTS. The name pairs withTPL_ENTSand followskb_url_template; happy to rename it. Related to #12267: this covers only the entity visualizer. The span renderer'sTPL_SPANScontainer is unchanged, so I have left the issue's closure to the maintainer.Without the option the output is unchanged. The new issue-marked test in
spacy/tests/test_displacy.pyrenders manual data with a custom container in both text directions and checks that the text is still escaped; it fails on master and passes with the change. The option gets one row in the entity visualizer table intop-level.mdx, including a note to double literal braces. All 28 tests intest_displacy.pypass on macOS, Python 3.11, using a 3.8.17 wheel with the patchedrender.pycopied in, since there was no local Cython build; that wheel's originalrender.pyis identical to master's. Changed-file mypy, Ruff formatting and import ordering pass.I used Codex (gpt-6.1-sol) to help write the patch and tests and to run the checks above, and Claude Opus 5.5 reviewed the change independently. I've read and verified the diff myself.
Types of change
New option for the entity visualizer, with a docs entry.
Checklist