imscJS icon indicating copy to clipboard operation
imscJS copied to clipboard

adjacent tts:textCombine spans are combined into a single span

Open btsimonh opened this issue 3 years ago • 3 comments
trafficstars

When there are two adjacent spans with tts:textCombine=all, they are combined into a single span containing the text from both. when debugging, it seems that _isd_element is undefined on both spans (not sure why), and so are equal.

It would seem prudent to replace (in html.js):

        if (first.tagName === "SPAN" &&
            second.tagName === "SPAN" &&
            first._isd_element === second._isd_element) {

with

        if (first.tagName === "SPAN" &&
            second.tagName === "SPAN" &&
            first._isd_element &&
            first._isd_element === second._isd_element) {

this may mean there are other times when spans are combined when they should not be?

btsimonh avatar Jul 14 '22 14:07 btsimonh

an alternative or additional fix would be

            if (imscStyles.byName.textCombine.qname in isd_element.styleAttrs &&
                    isd_element.styleAttrs[imscStyles.byName.textCombine.qname] === "all") {

                /* ignore tate-chu-yoku since line break cannot happen within */
                e.textContent = isd_element.text;
                e._isd_element = isd_element;

btsimonh avatar Jul 14 '22 15:07 btsimonh

Interesting. I'm fairly certain that I didn't test what would happen with textCombine when we submitted this code. Thanks for catching this. On first glance we should only need the second fix, and the first fix masks the problem. Will comment on the pull request. Wonder what @palemieux thinks about this?

nigelmegitt avatar Oct 10 '22 08:10 nigelmegitt

if (first.tagName === "SPAN" &&
            second.tagName === "SPAN" &&
            first._isd_element &&
            first._isd_element === second._isd_element) {

This feels most natural since _isd_element is described as enabling span merging, and we do not want tts:textCombine to be span-merged.

palemieux avatar Oct 11 '22 16:10 palemieux