Skip to content

Commit

Permalink
Add numerical digits superscript conversion (#201)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <[email protected]>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent a0c0200 commit 87e7f73
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/tinytext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@

__all__ = ["__version__"]

tiny_letters: dict[int, str] = {
tiny_characters: dict[int, str] = {
ord("0"): "⁰",
ord("1"): "¹",
ord("2"): "²",
ord("3"): "³",
ord("4"): "⁴",
ord("5"): "⁵",
ord("6"): "⁶",
ord("7"): "⁷",
ord("8"): "⁸",
ord("9"): "⁹",
ord("a"): "ᵃ",
ord("b"): "ᵇ",
ord("c"): "ᶜ",
Expand Down Expand Up @@ -85,5 +95,5 @@

def tinytext(big: str) -> str:
"""convert your text ᶦᶰᵗᵒ ᵗᶦᶰᶦᵉʳ ᵗᵉˣᵗ"""
tiny: str = big.translate(tiny_letters)
tiny: str = big.translate(tiny_characters)
return tiny
11 changes: 11 additions & 0 deletions tests/test_tinytext.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ def test_something() -> None:

# Assert
assert tiny == "ᶦᶰᵗᵒ ᵗᶦᶰᶦᵉʳ ᵗᵉˣᵗ"


def test_for_digits() -> None:
# Arrange
numbers = "9876543210"

# Act
tiny: str = tinytext.tinytext(numbers)

# Assert
assert tiny == "⁹⁸⁷⁶⁵⁴³²¹⁰"

0 comments on commit 87e7f73

Please sign in to comment.