You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deftest_span_escaping(en_vocab) ->None:
"""Test that displaCy's span visualizer escapes annotated HTML tags correctly."""# Create a doc containing an annotated word and an unannotated HTML tagdoc=Doc(en_vocab, words=["test", "<TEST>"])
doc.spans["sc"] = [Span(doc, 0, 1, label="test")]
# Verify that the HTML tag is escaped when unannotatedhtml=displacy.render(doc, style="span")
assert"<TEST>"inhtml# Annotate the HTML tagdoc.spans["sc"].append(Span(doc, 1, 2, label="test"))
# Verify that the HTML tag is still escapedhtml=displacy.render(doc, style="span")
assert"<TEST>"inhtml
The test currently fails on the last line, since the annotated HTML tag is not escaped by the displaCy renderer. Adding a call to escape_html here fixes the issue:
I ran into this issue when trying to visualize some annotated code documents with <span> in some of the documents. This resulted in the documents and span underlines rendering on top of each other at the beginning of the visualization. Adding escape_html as described above fixed the rendering issues.
I have a PR ready to fix this that I'll post as soon as I update the test <-> issue links in the code! Posted! 😄
Your Environment
spaCy version: 3.6.0
Platform: macOS-13.4.1-arm64-arm-64bit
Python version: 3.11.2
The text was updated successfully, but these errors were encountered:
How to reproduce the behaviour
Here's a test that currently fails:
The test currently fails on the last line, since the annotated HTML tag is not escaped by the displaCy renderer. Adding a call to
escape_html
here fixes the issue:spaCy/spacy/displacy/render.py
Line 221 in ddffd09
I ran into this issue when trying to visualize some annotated code documents with
<span>
in some of the documents. This resulted in the documents and span underlines rendering on top of each other at the beginning of the visualization. Addingescape_html
as described above fixed the rendering issues.I have a PR ready to fix this that I'll post as soon as I update the test <-> issue links in the code!Posted! 😄Your Environment
The text was updated successfully, but these errors were encountered: