PieterCK 6c1818fa46 slack_regex: Avoid replacing all identical matches.
In `convert_markdown_syntax`, `re.finditer` is used to iterate over each
`match` found in the `text`. In each iteration, we create the Zulip
formatting equivalent of the current `match` and do a `text.replace()`
to replace all strings in `text` that matches the current `match`.

Since we're planning to add the `re.MULTILINE` flag to `re.finditer`, it
would be problematic if the first and last capture group of `match` are
zero-width characters (newlines). This is because
`convert_markdown_syntax` would reformat all identical strike-through
and bold formatted strings as many time as there are identical `match`es
of them.

Consider the following:
---
 original text: "*foo*\n*foo*"

 1. <re.Match object; span=(0, 5), match='*foo*'>
    1st replace -> "**foo**\n**foo**"

 2. <re.Match object; span=(6, 11), match='*foo*'>
    2nd replace -> "***foo***\n***foo***"
---

This commit uses `re.sub` instead of `re.finditer`, which does replace
operation only on the specific piece of the original text the `match` is
from.
2025-04-28 20:49:10 -07:00
2024-12-10 10:00:45 -08:00
2025-04-11 12:13:07 -07:00
2025-04-25 11:49:17 -07:00
2025-02-24 22:29:24 -08:00
2024-11-13 09:18:56 -08:00

Zulip overview

Zulip is an open-source team collaboration tool with unique topic-based threading that combines the best of email and chat to make remote work productive and delightful. Fortune 500 companies, leading open source projects, and thousands of other organizations use Zulip every day. Zulip is the only modern team chat app that is designed for both live and asynchronous conversations.

Zulip is built by a distributed community of developers from all around the world, with 74+ people who have each contributed 100+ commits. With over 1000 contributors merging over 500 commits a month, Zulip is the largest and fastest growing open source team chat project.

Come find us on the development community chat!

GitHub Actions build status coverage status Mypy coverage Ruff code style: prettier GitHub release docs Zulip chat Twitter GitHub Sponsors

Getting started

You may also be interested in reading our blog, and following us on Twitter and LinkedIn.

Zulip is distributed under the Apache 2.0 license.

Description
Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
Readme Apache-2.0 867 MiB
Languages
Python 58.5%
TypeScript 18.1%
JavaScript 9.1%
CSS 3.9%
HTML 3.6%
Other 6.6%