Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kantek/KanTeX
https://github.com/kantek/KanTeX
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kantek/KanTeX
- Owner: kantek
- License: lgpl-3.0
- Created: 2020-08-15T19:45:41.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-15T21:48:58.000Z (almost 4 years ago)
- Last Synced: 2024-06-09T21:38:09.926Z (21 days ago)
- Language: Python
- Size: 14.6 KB
- Stars: 11
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-stars - kantek/KanTeX - (Python)
- awesome-stars - KanTeX
README
# KanTeX
KanTeX is a library that allow you to layout and format text using python. It is mainly intended to be used with Telegram Userbots and Bots.
KanTeX defaults to markdown but can be switched to using html by using `from kantex.html import *`. To be explicit about using Markdown, `from kantex.md import *` can be used.
## Examples
```python
from kantex.md import *doc = KanTeXDocument(
Section('A Section',
Italic('A italic Text'),
Mention('Telegram', 777000)))
print(doc)
```Result:
```markdown
**A Section**
__A italic Text__
[Telegram](tg://user?id=777000)
```---
```python
from kantex.html import *doc = KanTeXDocument(
Section('A Section',
Italic('A italic Text'),
Mention('Telegram', 777000)))
print(doc)
```Result:
```html
A Section
A italic Text
Telegram
```---
```python
from kantex.md import *doc = KanTeXDocument()
for i in range(5):
sec = Section(f'Section {i}')
for n in range(2):
sec.append(KeyValueItem(i, n))
doc.append(sec)print(doc)
```Result:
```markdown
**Section 0**
0: 0
0: 1**Section 1**
1: 0
1: 1**Section 2**
2: 0
2: 1**Section 3**
3: 0
3: 1**Section 4**
4: 0
4: 1
```---
```python
from kantex import *doc = KanTeXDocument(
Section('Nested',
SubSection('Sections',
Italic('work too'))))print(doc)
```Result:
```markdown
**Nested**
**Sections**
__work too__
```