Skip to content

kantek/KanTeX

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

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

from kantex.md import *

doc = KanTeXDocument(
    Section('A Section',
            Italic('A italic Text'),
            Mention('Telegram', 777000)))
print(doc)

Result:

**A Section**
    __A italic Text__
    [Telegram](tg://user?id=777000)

from kantex.html import *

doc = KanTeXDocument(
    Section('A Section',
            Italic('A italic Text'),
            Mention('Telegram', 777000)))
print(doc)

Result:

<b>A Section</b>
    <i>A italic Text</i>
    <a href="tg://user?id=777000">Telegram</a>

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:

**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

from kantex import *

doc = KanTeXDocument(
    Section('Nested',
            SubSection('Sections',
                       Italic('work too'))))

print(doc)

Result:

**Nested**
    **Sections**
        __work too__

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages