Skip to content

Fix subscripts in SVG#9

Open
radiantBear wants to merge 1 commit intorosulek:masterfrom
radiantBear:master
Open

Fix subscripts in SVG#9
radiantBear wants to merge 1 commit intorosulek:masterfrom
radiantBear:master

Conversation

@radiantBear
Copy link

SVG <text> elements do not support HTML <sub> elements in their content. Vamonos.resolveSubscript uses <sub> tags to render subscripts, which works great for subscripts rendered in HTML (such as Gf in the following screenshot), but does not work for subscripts rendered in SVG (such as tf in the following screenshot). This means that graphs currently render with the <sub> tags printing in plaintext:
image

Instead of using <sub> elements in SVG, <tspan> can be used to style a subset of text within an SVG text block. Vamonos.resolveSvgSubscript uses this to style subscripts for SVG. These subscripts are styled:

  • With baseline-shift='sub' to render below the normal text line in the SVG way
  • With font-size='75%' to match Bootstrap's size difference for subscripts (applied to <sub> tags in HTML)

This fixes the subscripts in the graphs without breaking subscripts rendered in HTML:
image

Important

This also changes the graph's vertex labels to render as HTML instead of escaped text (escaping text was a second problem making the <sub> tags visible in the graph). Labels are already rendered as HTML outside the graph so that the <sub> tags work properly, so this seems like a reasonable choice here as well. However, if a user were to create a vertex label like "<a>", this would render as a (broken) anchor tag instead of the literal string "<a>".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant