[interop] Text fragments + MathML
@bkardell is already working on this.
Since Aug 25, 2025.
- Dominant language
- HTML
- Stars
- 56
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
The URL Fragment Text Directives effort defines an algorithm "find a range from a text directive" which is applicable over <math> nodes. I find the following quote to be a great summary:
The basic premise of this algorithm is to walk all searchable text nodes within a block, collecting them into a list. The list is then concatenated into a single string in which we can search, using the node list to determine offsets with a node so we can return a range.
I am opening this issue to discuss if "a block" is a concept that needs to be extended/refined when that algorithm is executed inside a <math> context.
This could be a very useful refinement, as linking to math-rich fragments is often appropriate when discussing scientific materials.
If there is interest, we can open a mirror issue in the WICG/scroll-to-text-fragment repository. I have checked all repositories for related issues - as far as I am aware this question not been discussed before.
Examples
Successful
Text fragments are available in chromium browsers, where they also match text nodes inside MathML. I will add 3 examples with screenshots.
-
Link to token element, first instance of
<mi>ℝ</mi>- fragment used is
#:~:text=ℝ - https://ar5iv.labs.arxiv.org/html/2106.11285#:~:text=%E2%84%9D
- fragment used is
-
Link to a textual fragment inside
<mtext>- fragment used is
#:~:text=Hodge%20Riemann%20property - https://ar5iv.labs.arxiv.org/html/2106.11285#:~:text=Hodge%20Riemann%20property
- fragment used is
-
Link to a range, starting at the first
<mi>det</mi>determinant, and upto the end of the closing)for its matrix.- fragment used is
#:~:text=det,) - https://ar5iv.labs.arxiv.org/html/2106.11285#:~:text=det,%29
- fragment used is
Unsuccessful
-
Link to text nodes in adjacent token elements (grandchildren in the same
<mrow>), fails.- fragment used is
#:~:text=𝑑−2 - https://ar5iv.labs.arxiv.org/html/2106.11285#:~:text=%F0%9D%91%91%E2%88%922
- A range is hard to construct here as a 3-part directive isn't a valid range (which I mistakenly tried), i.e.
text=𝑑,−,2is not a range. - A regular range, such as
d,−ord,2could succeed, but it would not match the desired expression. Example:- fragment used is
#:~:text=𝑑,2 - https://ar5iv.labs.arxiv.org/html/2106.11285#:~:text=%F0%9D%91%91,2
- fragment used is
- fragment used is
-
Link to adjacent HTML text node and adjacent inline math
<mi>, fails- fragment used is
#:~:text=partition of 𝑑 - https://ar5iv.labs.arxiv.org/html/2106.11285#:~:text=partition%20of%20%F0%9D%91%91
- using a range instead succeeds,
#:~:text=partition of,𝑑
- fragment used is
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.