-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,8 @@ | ||
# Mizu's main module. | ||
|
||
from .mizu import Mizu | ||
from .parse import Mizu | ||
from .mizu import Mizu as LowMizu | ||
from .options import Options | ||
|
||
from warnings import warn | ||
|
||
|
||
def parse_ext(text: str, *args, **kwargs) -> str: | ||
warn("parse_ext is deprecated, use Mizu class.", DeprecationWarning) | ||
return Mizu(Options(*args, **kwargs)).parse(text) | ||
|
||
|
||
def parse(*args, **kwargs) -> str: | ||
warn("parse is deprecated, use Mizu class.", DeprecationWarning) | ||
return Mizu(Options()).parse(*args, **kwargs) | ||
|
||
|
||
__all__ = ("parse", "parse_ext", "Mizu", "Options") | ||
__all__ = ("parse", "parse_ext", "Mizu", "Options", "LowMizu") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from .mizu import Mizu as _Mizu | ||
from .options import Options | ||
from asyncio import AbstractEventLoop | ||
from typing import Optional | ||
|
||
|
||
class Mizu: | ||
""" | ||
Markdown parser. | ||
Args: | ||
options (Options): Options for parser. | ||
loop (AbstractEventLoop): Event loop | ||
""" | ||
def __init__( | ||
self, options: Options = Options(), | ||
loop: Optional[AbstractEventLoop] = None, | ||
) -> None: | ||
self.__parser = _Mizu(options) | ||
if loop: | ||
self.__parser.set_loop(loop) | ||
|
||
def parse(self, text: str) -> str: | ||
""" | ||
Parse markdown text to html. | ||
Args: | ||
text (str): Markdown text. | ||
""" | ||
return self.__parser.parse(text) | ||
|
||
async def aioparse(self, text: str) -> str: | ||
""" | ||
Parse markdown text to html (async version) | ||
Args: | ||
text (str): Markdown text | ||
""" | ||
return await self.__parser.aioparse(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters