question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

displacy.render produces invalid svg by not escaping "<"

See original GitHub issue

How to reproduce the behaviour

import spacy
from spacy import displacy
nlp = spacy.load('de_core_news_sm')

doc = nlp('eins < zwei')
print(displacy.render(doc))

In the resulting svg code you can see that the “<” is not escaped:

...
<text class="displacy-token" fill="currentColor" text-anchor="middle" y="134.5">
    <tspan class="displacy-word" fill="currentColor" x="225"><</tspan>
    <tspan class="displacy-tag" dy="2em" fill="currentColor" x="225">CONJ</tspan>
</text>
...

My Environment

  • Operating System: Mac OS 10.12.6
  • Python Version Used: 3.5.1
  • spaCy Version Used: 2.0.11

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ansgar-tcommented, May 27, 2018

and here’s the separate issue for the failed tests: #2379

0reactions
lock[bot]commented, Jun 27, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Save SpaCy render file as SVG using DisplaCy - Stack Overflow
I think that you have 2 errors there. First you should fix your path - add "." from: output_path = Path("/images/dependency_plot.svg").
Read more >
Visualizers · spaCy Usage Documentation
Visualize dependencies and entities in your browser or in a notebook.
Read more >
Document Structure — SVG 2
An SVG document fragment can range from an empty fragment (i.e., no content ... are not rendered directly; the display value for the...
Read more >
Probably Don't Base64 SVG | CSS-Tricks
For a raster image like a PNG, the data of that image needs to be in base64 format. I'm not a huge expert...
Read more >
SVG Elements and Attributes - O'Reilly Design System
Default is usually 0, which usually disables rendering of the element. Negative values are an error. SVG 2 makes it a geometry property...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found