tsformatter


Nametsformatter JSON
Version 0.2.2 PyPI version JSON
download
home_pageNone
SummaryHelper package to format TeamSpeak BBCode
upload_time2024-06-09 22:17:06
maintainerNone
docs_urlNone
authorjykob
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TSFormatter

Helper package to format TeamSpeak BBCode

## 📦 Installation

```shell
pip install tsformatter
```

## ✏️ Usage

importing the formatter

```python
import tsformatter
```

### Colors

```python
# Using HTML color name
>>> tsformatter.color("red", "This text is red")
'[COLOR=red]This text is red[/COLOR]'

>>> tsformatter.color("PaleTurquoise", "This text is turquoise")
'[COLOR=PaleTurquoise]This text is turquoise[/COLOR]'


# Using Hex Triplet
>>> tsformatter.color("#f00", "This text is red")
'[COLOR=f00]This text is red[/COLOR]'

>>> tsformatter.color("#AFEEEE", "This text is turquoise")
'[COLOR=#AFEEEE]This text is turquoise[/COLOR]'
```

### Horizontal line

```python
>>> tsformatter.hr
'[HR]'
```

### Images

```python
>>> tsformatter.img("https://i.imgur.com/ml09ccU.png")
'[IMG]https://i.imgur.com/ml09ccU.png[/IMG]'
```

### Links

```python
# Without specifying link text
>>> tsformatter.link("https://www.teamspeak.com/")
'[URL]https://www.teamspeak.com/[/URL]'

# With a link text
>>> tsformatter.link("https://www.teamspeak.com/", "TeamSpeak Website")
'[URL=https://www.teamspeak.com/]TeamSpeak Website[/URL]'
```

### Lists

```python
# Default style of the list is bullet list
>>> tsformatter.list_(f"List item #{x}" for x in range(1, 6))
'[LIST]\n[*]List item #1\n[*]List item #2\n[*]List item #3\n[*]List item #4\n[*]List item #5\n[/LIST]'


# You can specify the style of the list
>>> tsformatter.list_((f"List item #{x}" for x in range(1, 6)), style="1")
'[LIST=1]\n[*]List item #1\n[*]List item #2\n[*]List item #3\n[*]List item #4\n[*]List item #5\n[/LIST]'
```

#### List styles that work:

| Style   |                    "1"                    |                       "a"                        |                      "i"                      |                      "A"                      |                      "I"                      |
| ------- | :---------------------------------------: | :----------------------------------------------: | :-------------------------------------------: | :-------------------------------------------: | :-------------------------------------------: |
| Renders | ![numberic](.github/img/list_numeric.png) | ![alpha lower](.github/img/list_alpha_lower.png) | ![numberic](.github/img/list_roman_lower.png) | ![numberic](.github/img/list_alpha_upper.png) | ![numberic](.github/img/list_roman_upper.png) |

### Placement

```python
>>> tsformatter.left("Formatted to the left")
'[LEFT]Formatted to the left[/LEFT]'

>>> tsformatter.right("Formatted to the right")
'[RIGHT]Formatted to the right[/RIGHT]'

>>> tsformatter.center("Center of the space")
'[CENTER]Center of the space[/CENTER]'
```

### Size

```python
# Using absolute sizes
>>> tsformatter.size(24, "I am huge!")
'[SIZE=24]I am huge![/SIZE]'

# Relative sizes can be either positive or negative
>>> tsformatter.size('-4', "I am 4 units smaller than the rest")
'[SIZE=-2]I am 2 units smaller than the rest[/SIZE]'

>>> tsformatter.size('+2', "I am 2 units bigger than the rest")
'[SIZE=+2]I am 2 units bigger than the rest[/SIZE]'
```

### Styles

```python
>>> tsformatter.bold("Example text")
'[B]Example text[/B]'

>>> tsformatter.italic("Example text")
'[I]Example text[/I]'

>>> tsformatter.underline("Example text")
'[U]Example text[/U]'

>>> tsformatter.strike("Example text")
'[S]Example text[/S]'
```

### Tables

```python

>>> header = ("Place", "City", "Date")
>>> data1 = ("Statue of Liberty", "New York City", "October 28, 1886")
>>> data2 = ("Eiffel Tower", "Paris", "31 March, 1889")
>>> data3 = ("Big Ben", "London", "31 May, 1859")

>>> tsformatter.table(
        tsformatter.table_header_row(header),
        tsformatter.table_row(data1),
        tsformatter.table_row(data2),
        tsformatter.table_row(data3)
    )
'[TABLE]\n[TR][TH]Place[/TH][TH]City[/TH][TH]Date[/TH][/TR]\n[TR][TD]Statue of Liberty[/TD][TD]New York City[/TD][TD]October 28, 1886[/TD][/TR]\n[TR][TD]Eiffel Tower[/TD][TD]Paris[/TD][TD]31 March, 1889[/TD][/TR]\n[TR][TD]Big Ben[/TD][TD]London[/TD][TD]31 May, 1859[/TD][/TR]\n[/TABLE]'
```

#### Results when rendered by TeamSpeak client:

![table example](.github/img/table.png)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tsformatter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "jykob",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fc/e8/46c9d4d0f80fa286e1083d986c891c3d9f0ea95f7bdb6d001a75ea448e04/tsformatter-0.2.2.tar.gz",
    "platform": null,
    "description": "# TSFormatter\n\nHelper package to format TeamSpeak BBCode\n\n## \ud83d\udce6 Installation\n\n```shell\npip install tsformatter\n```\n\n## \u270f\ufe0f Usage\n\nimporting the formatter\n\n```python\nimport tsformatter\n```\n\n### Colors\n\n```python\n# Using HTML color name\n>>> tsformatter.color(\"red\", \"This text is red\")\n'[COLOR=red]This text is red[/COLOR]'\n\n>>> tsformatter.color(\"PaleTurquoise\", \"This text is turquoise\")\n'[COLOR=PaleTurquoise]This text is turquoise[/COLOR]'\n\n\n# Using Hex Triplet\n>>> tsformatter.color(\"#f00\", \"This text is red\")\n'[COLOR=f00]This text is red[/COLOR]'\n\n>>> tsformatter.color(\"#AFEEEE\", \"This text is turquoise\")\n'[COLOR=#AFEEEE]This text is turquoise[/COLOR]'\n```\n\n### Horizontal line\n\n```python\n>>> tsformatter.hr\n'[HR]'\n```\n\n### Images\n\n```python\n>>> tsformatter.img(\"https://i.imgur.com/ml09ccU.png\")\n'[IMG]https://i.imgur.com/ml09ccU.png[/IMG]'\n```\n\n### Links\n\n```python\n# Without specifying link text\n>>> tsformatter.link(\"https://www.teamspeak.com/\")\n'[URL]https://www.teamspeak.com/[/URL]'\n\n# With a link text\n>>> tsformatter.link(\"https://www.teamspeak.com/\", \"TeamSpeak Website\")\n'[URL=https://www.teamspeak.com/]TeamSpeak Website[/URL]'\n```\n\n### Lists\n\n```python\n# Default style of the list is bullet list\n>>> tsformatter.list_(f\"List item #{x}\" for x in range(1, 6))\n'[LIST]\\n[*]List item #1\\n[*]List item #2\\n[*]List item #3\\n[*]List item #4\\n[*]List item #5\\n[/LIST]'\n\n\n# You can specify the style of the list\n>>> tsformatter.list_((f\"List item #{x}\" for x in range(1, 6)), style=\"1\")\n'[LIST=1]\\n[*]List item #1\\n[*]List item #2\\n[*]List item #3\\n[*]List item #4\\n[*]List item #5\\n[/LIST]'\n```\n\n#### List styles that work:\n\n| Style   |                    \"1\"                    |                       \"a\"                        |                      \"i\"                      |                      \"A\"                      |                      \"I\"                      |\n| ------- | :---------------------------------------: | :----------------------------------------------: | :-------------------------------------------: | :-------------------------------------------: | :-------------------------------------------: |\n| Renders | ![numberic](.github/img/list_numeric.png) | ![alpha lower](.github/img/list_alpha_lower.png) | ![numberic](.github/img/list_roman_lower.png) | ![numberic](.github/img/list_alpha_upper.png) | ![numberic](.github/img/list_roman_upper.png) |\n\n### Placement\n\n```python\n>>> tsformatter.left(\"Formatted to the left\")\n'[LEFT]Formatted to the left[/LEFT]'\n\n>>> tsformatter.right(\"Formatted to the right\")\n'[RIGHT]Formatted to the right[/RIGHT]'\n\n>>> tsformatter.center(\"Center of the space\")\n'[CENTER]Center of the space[/CENTER]'\n```\n\n### Size\n\n```python\n# Using absolute sizes\n>>> tsformatter.size(24, \"I am huge!\")\n'[SIZE=24]I am huge![/SIZE]'\n\n# Relative sizes can be either positive or negative\n>>> tsformatter.size('-4', \"I am 4 units smaller than the rest\")\n'[SIZE=-2]I am 2 units smaller than the rest[/SIZE]'\n\n>>> tsformatter.size('+2', \"I am 2 units bigger than the rest\")\n'[SIZE=+2]I am 2 units bigger than the rest[/SIZE]'\n```\n\n### Styles\n\n```python\n>>> tsformatter.bold(\"Example text\")\n'[B]Example text[/B]'\n\n>>> tsformatter.italic(\"Example text\")\n'[I]Example text[/I]'\n\n>>> tsformatter.underline(\"Example text\")\n'[U]Example text[/U]'\n\n>>> tsformatter.strike(\"Example text\")\n'[S]Example text[/S]'\n```\n\n### Tables\n\n```python\n\n>>> header = (\"Place\", \"City\", \"Date\")\n>>> data1 = (\"Statue of Liberty\", \"New York City\", \"October 28, 1886\")\n>>> data2 = (\"Eiffel Tower\", \"Paris\", \"31 March, 1889\")\n>>> data3 = (\"Big Ben\", \"London\", \"31 May, 1859\")\n\n>>> tsformatter.table(\n        tsformatter.table_header_row(header),\n        tsformatter.table_row(data1),\n        tsformatter.table_row(data2),\n        tsformatter.table_row(data3)\n    )\n'[TABLE]\\n[TR][TH]Place[/TH][TH]City[/TH][TH]Date[/TH][/TR]\\n[TR][TD]Statue of Liberty[/TD][TD]New York City[/TD][TD]October 28, 1886[/TD][/TR]\\n[TR][TD]Eiffel Tower[/TD][TD]Paris[/TD][TD]31 March, 1889[/TD][/TR]\\n[TR][TD]Big Ben[/TD][TD]London[/TD][TD]31 May, 1859[/TD][/TR]\\n[/TABLE]'\n```\n\n#### Results when rendered by TeamSpeak client:\n\n![table example](.github/img/table.png)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Helper package to format TeamSpeak BBCode",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/jykob/tsformatter"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a8a9b0e8c135a25862a1bd600bd09550232e0d44ed64e1086e71caac16dbc63",
                "md5": "700427f3ac7f16d0188aed34de4866b9",
                "sha256": "54d065d6c11ec345f2fcd189e62cdb26444c3c4912d3509b7e11b498ea10a400"
            },
            "downloads": -1,
            "filename": "tsformatter-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "700427f3ac7f16d0188aed34de4866b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 4659,
            "upload_time": "2024-06-09T22:17:05",
            "upload_time_iso_8601": "2024-06-09T22:17:05.261781Z",
            "url": "https://files.pythonhosted.org/packages/8a/8a/9b0e8c135a25862a1bd600bd09550232e0d44ed64e1086e71caac16dbc63/tsformatter-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fce846c9d4d0f80fa286e1083d986c891c3d9f0ea95f7bdb6d001a75ea448e04",
                "md5": "d377d134e622ffc77205a9443a25e32a",
                "sha256": "f8fed419eda336f8602a5ada8ba1e337520d43f801046a7c8533902f5c6eb99f"
            },
            "downloads": -1,
            "filename": "tsformatter-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d377d134e622ffc77205a9443a25e32a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5454,
            "upload_time": "2024-06-09T22:17:06",
            "upload_time_iso_8601": "2024-06-09T22:17:06.599716Z",
            "url": "https://files.pythonhosted.org/packages/fc/e8/46c9d4d0f80fa286e1083d986c891c3d9f0ea95f7bdb6d001a75ea448e04/tsformatter-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-09 22:17:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jykob",
    "github_project": "tsformatter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tsformatter"
}
        
Elapsed time: 0.26086s