Commit Graph

7 Commits

Author SHA1 Message Date
apoorvapendse
ac8614caf8 copy_and_paste: Fix regression caused by quoting math.
We now do a more precise check to decide whether
to perform the span conversion for intermediate
text nodes.

Fixes: https://chat.zulip.org/#narrow/channel/9-issues/topic/HTML.20paragraphs.20misconverted.20by.20copy.20and.20paste.
2025-02-04 16:10:49 -08:00
Tim Abbott
42bc59b802 hash_util: Parse with operators for copy/paste. 2025-02-02 11:46:05 -08:00
Prakhar Pratyush
53dc5198c6 copy_and_paste: Fix missing empty string topic in message_link syntax.
Earlier, pasting a message_link for a message in empty string topic in
the compose area resulted in #**channel_name@100** syntax instead of the
correct #**channel_name>@100** syntax.

This commit fixes that bug.
2025-01-31 14:23:15 -08:00
apoorvapendse
3fd5673bbd compose: Support to convert math html to markdown.
This commit tries to address the problem of not getting the
latex markdown on selecting and quoting a message which
contains normal text as well katex html elements.

It works by grabbing the parent of all the katex elements,
display (mathblocks) as well as inline expressions
and iterating over each immediate child to convert the
elements into markdown based on certain conditions.

Support has also been added to convert inline expressions to an
approximate markdown representation.

To facilitate selection of inline math expressions along with
text nodes, which are intermediate pieces of text sandwiched
between two katex spans, we transform the paste_html to
have spans instead of text nodes, so that they can be
processed by turndown js, since its filter function only
iterates through Elements and not TEXT_NODE.

The new tests have been added in katex_test_cases.json to
prevent cluttering the node tests in copy_and_paste.test.cjs.
These tests are looped over in the node tests.

Fixes #31608.
2025-01-30 11:08:56 -08:00
evykassirer
10d7da81a0 copy_and_paste: Don't add code syntax if backtick is already present. 2025-01-27 15:30:15 -08:00
apoorvapendse
6586d9078e copy_and_paste: Paste Excel copied content as image and text.
This ensures that using `^V` pastes the content from excel as
an image.
To get normal text in a formatted manner one can use
`^⇧V`.

The earlier conditions in `is_single_image` caused
the classification to fail in case of Excel pasted
content, which is why we check for the for the XML
namespaces associated with Microsoft in the pasted
HTML.

Fixes #32968.
2025-01-24 11:10:38 -08:00
Anders Kaseorg
687f1b1651 tests: Rename the Node tests to *.cjs.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00