Safe html in widget title

Is there away to prevent String.escape() in Widget title?
For example, I used:

Slider(title="Δ x", value=0,...)

with the hope of getting:

<div class="bk bk-slider-title">
    &Delta; x: <span class="bk bk-slider-value">0</span>
</div>

instead I get:

<div class="bk bk-slider-title">
    &amp;Delta; x: <span class="bk bk-slider-value">0</span>
</div>

I am thinking of adding a custom class to the widget then use JavaScript that replaces the html text of the element after document loading, is there another way?

I don’t believe there is (cc @mateusz) the only workaround I can think of offhand is to omit the widget title entirely and put a Div (which can have un-escaped HTML content) right above it in a column.

I added the following to the custom script in the page, not ideal, but works for me:

$('.bk-slider-title').each( function(e){ 
    $(this).text($(this).text().replace("Delta ", unescape("%u0394")));
})

after change the title to title="Delta x".

1 Like

BTW note that there is ongoing work to add “mathtext” to Bokeh but initial work is focusing on plot elements, I am not sure when things like widget titles will be prioritized.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.