krautzource / sre-to-tree

MIT License
0 stars 0 forks source link

fix selection of "semantic root" #37

Closed pkra closed 1 year ago

pkra commented 1 year ago

Via https://github.com/Speech-Rule-Engine/speech-rule-engine/issues/729

It turns out, we are too naive in

https://github.com/krautzource/sre-to-tree/blob/f66d0f50c99b1fcc2c9398e83fbd0b1ec9717c60/lib.js#L124-L126

as SRE's "semantic root" might not be the first element with speech.

As discussed, we can either read the ID from the root's s-expression and look for the element or we can match SRE by doing, e.g., document.querySelector('[data-semantic-id]:not([data-semantic-parent])').

pkra commented 1 year ago

We shouldn't have to adjust our recursion otherwise since we already use a hash table to deal with MathJax's tables output.