Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 353f57e

Browse files
apoorvapendsetimabbott
authored andcommitted
copy: Style KaTeX annotations to be included in copy HTML.
We've for a while been finding that copy/paste of LaTeX only worked if we had a more JS-heavy copy handler that directly copies the HTML/text using events, rather than just allowing the browser's native copying logic to do its thing. We've discovered the bug was that the `<annotation>` tag in MathML is not rendered in some browsers which results in default copy behavior of the browser breaking KaTeX copy-pasting and quoting by omitting the `<annotation>` in the copied HTML as Chrome and possibly other browsers select only what is visible. From https://www.w3.org/TR/selection-api/ > Chrome 16 dev behaves as you'd expect given its Selection implementation. It refuses to select anything that's not visible, so it's almost always wrong. Opera 11.50 just does nothing in all my tests, as usual. This can be observed in the `paste_html` fixtures present in #33993 (comment). We fix this by simply overriding the `display:none` property from the <annotation> tag in the user agent stylesheet, which lets the browser select and ultimately copy it which results in the annotation being present in the `paste_html` and restore the working of KaTeX quoting/copy-pasting. This appears to have no visible impact, since browsers don't actually have a way to display the annotations.
1 parent a4fff91 commit 353f57e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

web/styles/rendered_markdown.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@
280280
overflow: auto hidden;
281281
}
282282

283+
.katex-mathml annotation {
284+
/* Because annotations are never displayable, browser user-agent
285+
stylesheets mark them as not displayable, which has the
286+
side effect of having them not be included in the HTML
287+
version of copying the content. Override this, so KaTeX can
288+
be copy/pasted within Zulip. */
289+
user-select: all;
290+
display: inline;
291+
}
292+
283293
.tex-error {
284294
color: hsl(0deg 0% 50%);
285295
}

0 commit comments

Comments
 (0)