openlibhums / openlibhums/janeway
Prevent unwanted line breaks between inline MathJax and punctuation/suffixes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 238
- Forks
- 97
- Avg merge
- 9d 1h
- Merged PRs (30d)
- 8
Description
Is your feature request related to a problem? Please describe.
It appears that in rendered article HTML, an implicit word break is always inserted after an <inline-formula>. This means that depending on font/screen/browser size, line wrapping can insert a line break between the inline MathJax and the punctuation or suffix that immediately follows (period, comma, "s", "'s", "-ing", footnote callout, etc.). This results in those characters being awkwardly displayed at the start a new line, separated from the MathJax that they're meant to be "attached" to.
Alternatives
The latest author to report these unwanted line breaks suggested using the Word Joiner character () after the </inline-formula>, but that didn't fix the problem.
I tried moving the suffix/character within the <inline-formula> tag (e.g., <inline-formula><mml:math>...</mml:math>,</inline-formula>) and wrapping both the <inline-formula> tag and the suffix/character in a single <span> tag (e.g., <span><inline-formula><mml:math>...</mml:math></inline-formula>,</span>). Neither of these seemed to have any effect on the problem.
It seems like the only real workaround right now is to tag the punctuation/suffix characters as MathML text, but this isn't ideal because it causes those characters to display in math-mode font rather than regular text. It also doesn't offer a solution for a functional linked footnote callout.
Describe the solution you'd like
I found a Stack Overflow conversation about this problem: https://stackoverflow.com/questions/50633461/unwanted-word-breaks-after-inline-mathjax-formulae
One user suggested to "add a post-processing heuristic somewhere in your toolchain that wraps equations surrounded by non-whitespace in an element whose styling includes white-space: nowrap;; this will ensure that no breaks appear within."
Contributor guide
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.
Research direction
No files or tests are named. Start by tracing how is produced in rendered article HTML and where post-processing occurs, then reproduce wrapping with punctuation, suffixes, and footnote callouts at narrow widths. Done means adjacent text stays with inline MathJax without changing normal text styling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100