Skip to content

Commit

Permalink
📖 Docs: Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yym68686 committed Nov 14, 2024
1 parent f76bdb3 commit a82c920
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 33 deletions.
73 changes: 41 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

md2tgmd is a Markdown to [Telegram-specific-markdown](https://core.telegram.org/bots/api#formatting-options) converter.

## Feature

- Supports most of the specific Markdown syntax for Telegram, including: headings, bold, italic, strikethrough, code blocks, links, and quotes.
- Support the conversion of LaTeX formulas in Markdown to Unicode characters to improve the readability of mathematical formulas in Telegram.
- Support syntax highlighting for code blocks in Markdown.

## Install

```bash
Expand All @@ -13,47 +19,49 @@ pip install md2tgmd
## Usage

~~~python
from md2tgmd import escape
From md2tgmd import escape

text = '''
# title
# Title
\[ \\varphi(35) = 35 \\left(1 - \\frac{1}{5}\\right) \\left(1 - \\frac{1}{7}\\right) \]
**bold**
**Bold**
```
# comment
# Comment
print(qwer) # ferfe
ni1
```
# bn
# b
# Header
## Subheader
# Title
## Subtitle
[1.0.0](http://version.com)
![1.0.0](http://version.com)
- item 1 -
- item 1 -
- item 1 -
* item 2 #
* item 3 ~
- Item 1 -
- Item 1 -
- Item 1 -
* Item 2 #
* Item 3 ~
1. item 1
2. item 2
1. Item 1
2. Item 2
sudo apt install mesa-utils # 安装
sudo apt install mesa-utils # Install
```python
# comment
# Comment
print("1.1\n")_
\subsubsection{1.1}
```
\subsubsection{1.1}
And simple text `with-ten` `with+ten` + some - **symbols**. # `with-ten`里面的`-`不会被转义
And simple text `with-ten` `with+ten` + some - **symbols**. # `-` inside `with-ten` will not be escaped
```
Expand All @@ -74,51 +82,53 @@ print(escape(text))


'''
▎*title*
▎*Title*
*bold*
ϕ(35) = 35(1 - ⅕)(1 - 1/7)
*Bold*
```
\# comment
\# Comment
print\(qwer\) \# ferfe
ni1
```
▎*bn*
▎*b*
▎*Header*
▎*Subheader*
▎*Title*
▎*Subtitle*
[1\.0\.0](http://version\.com)
[1\.0\.0](http://version\.com)
item 1 \-
Item 1 \-
item 1 \-
Item 1 \-
item 1 \-
Item 1 \-
item 2 \#
Item 2 \#
item 3 \~
Item 3 \~
1\. item 1
1\. Item 1
2\. item 2
2\. Item 2
sudo apt install mesa\-utils \# 安装
sudo apt install mesa\-utils \# Install
```python
\# comment
\# Comment
print\("1\.1\\n"\)\_
\\subsubsection\{1\.1\}
```
\\subsubsection\{1\.1\}
And simple text `with-ten` `with+ten` \+ some \- *symbols*\. \# `with-ten`里面的`-`不会被转义
And simple text `with-ten` `with+ten` \+ some \- *symbols*\. \# `-` inside `with-ten` will not be escaped
```
Expand All @@ -134,7 +144,6 @@ Cxy \= abs \(Pxy\)\*\*2/ \(Pxx\*Pyy\)
▎*pattern*
w`-a----`ccccc`-n-`bbbb\`\`a
'''

~~~

## Reference
Expand Down
10 changes: 10 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

md2tgmd 是一个将 Markdown 转换为 [Telegram 特定 Markdown](https://core.telegram.org/bots/api#formatting-options) 的转换器。

## 特性

- 支持 Telegram 特定 Markdown 大部分语法,包括:标题、加粗、斜体、删除线、代码块、链接、引用。
- 支持 Markdown 中 LaTeX 公式转换为 Unicode 字符,提高数学公式在 Telegram 中显示的可读性
- 支持 Markdown 中代码块的语法高亮。

## 安装

```bash
Expand All @@ -18,6 +24,8 @@ pip install md2tgmd
文本 = '''
# 标题
\[ \\varphi(35) = 35 \\left(1 - \\frac{1}{5}\\right) \\left(1 - \\frac{1}{7}\\right) \]
**加粗**
```
# 注释
Expand Down Expand Up @@ -76,6 +84,8 @@ print(escape(文本))
'''
▎*标题*
ϕ(35) = 35(1 - ⅕)(1 - 1/7)
*加粗*
```
\# 注释
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="md2tgmd",
version="0.3.8",
version="0.3.9",
description="md2tgmd is a Markdown to Telegram-specific-markdown converter.",
long_description=Path("README.md").open(encoding="utf-8").read(),
long_description_content_type="text/markdown",
Expand Down

0 comments on commit a82c920

Please sign in to comment.