2
0
Fork 0
textout/textoutpc/__init__.py

47 lines
1.5 KiB
Python
Raw Normal View History

2018-01-02 18:57:04 +01:00
#!/usr/bin/env python3
#******************************************************************************
# Copyright (C) 2018 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
# This file is part of the textoutpc project, which is MIT-licensed.
#******************************************************************************
2018-01-02 18:57:04 +01:00
""" Functions for the user.
Really simplifies the thing.
"""
2018-07-28 19:36:43 +02:00
from io import StringIO as _StringIO
2020-07-01 12:10:35 +02:00
from .version import version
2018-07-28 19:36:43 +02:00
from ._options import TextoutOptions as Options, \
TextoutBlockTag as BlockTag, TextoutInlineTag as InlineTag, \
2018-08-25 20:28:05 +02:00
TextoutParagraphTag as ParagraphTag, TextoutSmiley as Smiley, \
TextoutImage as Image, TextoutVideo as Video
2018-07-28 19:36:43 +02:00
from ._translate import Translator as _Translator
__all__ = ["version", "tohtml", "tolightscript",
2018-07-29 19:51:42 +02:00
"Options", "BlockTag", "ParagraphTag", "InlineTag",
"Smiley", "Image", "Video"]
2018-02-12 08:32:02 +01:00
2018-07-28 19:36:43 +02:00
# ---
# Public functions.
# ---
_default_options = Options()
def tohtml(message, options = _default_options, **tweaks):
""" Converts textout BBcode to HTML.
Receives a string, returns a string. """
t = _Translator(_StringIO(message), _StringIO(), 'html', \
tweaks, options)
return t.process().getvalue()
2018-07-28 19:36:43 +02:00
def tolightscript(message, options = _default_options, **tweaks):
""" Converts textout BBcode to Lightscript.
Receives a string, returns a string. """
return "" # TODO: real thing one day
2018-07-28 19:36:43 +02:00
return _Translator(_StringIO(message), _StringIO(), 'lightscript', \
tweaks, options).process().getvalue()
2018-01-02 18:57:04 +01:00
# End of file.