2018-01-02 18:57:04 +01:00
|
|
|
#!/usr/bin/env python3
|
2018-02-19 19:50:26 +01:00
|
|
|
#******************************************************************************
|
|
|
|
# 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
|
2018-01-05 22:13:30 +01:00
|
|
|
|
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, \
|
2018-09-10 16:45:17 +02:00
|
|
|
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",
|
2018-09-10 16:45:17 +02:00
|
|
|
"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):
|
2018-02-15 20:16:21 +01:00
|
|
|
""" Converts textout BBcode to HTML.
|
|
|
|
Receives a string, returns a string. """
|
|
|
|
|
2018-11-01 23:40:50 +01:00
|
|
|
t = _Translator(_StringIO(message), _StringIO(), 'html', \
|
|
|
|
tweaks, options)
|
|
|
|
return t.process().getvalue()
|
2018-02-15 20:16:21 +01:00
|
|
|
|
2018-07-28 19:36:43 +02:00
|
|
|
def tolightscript(message, options = _default_options, **tweaks):
|
2018-02-15 20:16:21 +01:00
|
|
|
""" 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-02-15 20:16:21 +01:00
|
|
|
|
2018-01-02 18:57:04 +01:00
|
|
|
# End of file.
|