Skip to content

Commit

Permalink
formated by black
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna2134 committed May 10, 2024
1 parent 515d5a3 commit bdb82ac
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions docs/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from mizu import parse
from jinja2 import Template, Environment, FileSystemLoader

env = Environment(loader=FileSystemLoader('.'), trim_blocks=False)
template = env.get_template('main.tpl')
env = Environment(loader=FileSystemLoader("."), trim_blocks=False)
template = env.get_template("main.tpl")
with open("main.md", "r") as f:
raw = f.read()
text = template.render(content=parse(raw))
Expand Down
20 changes: 8 additions & 12 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,24 @@
import os
import sys

sys.path.insert(0, os.path.abspath('../../'))
sys.path.insert(0, os.path.abspath("../../"))


project = 'mizu'
copyright = '2022, tuna2134'
author = 'tuna2134'
project = "mizu"
copyright = "2022, tuna2134"
author = "tuna2134"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.napoleon"
]
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]

templates_path = ['_templates']
templates_path = ["_templates"]
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
html_theme = "furo"
html_static_path = ["_static"]
18 changes: 4 additions & 14 deletions mizu/mizu.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@ from .options import Options

import asyncio


class Mizu:
def __init__(
self, options: Options = Options()
) -> None:
...

def set_loop(self, loop: asyncio.AbstractEventLoop) -> None:
...

def parse(self, text: str) -> str:
...

async def aioparse(self, text: str) -> str:
...
def __init__(self, options: Options = Options()) -> None: ...
def set_loop(self, loop: asyncio.AbstractEventLoop) -> None: ...
def parse(self, text: str) -> str: ...
async def aioparse(self, text: str) -> str: ...
23 changes: 17 additions & 6 deletions mizu/options.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Mizu's markdown options


class Options:
"""Options for Markdown parsing.
Expand All @@ -11,17 +12,23 @@ class Options:
smart_punctuation (bool): Enable smart punctuation parsing.
heading_attribute (bool): Enable heading attribute parsing.
"""

tables: bool
footnotes: bool
strikethrough: bool
tasklists: bool
smart_punctuation: bool
heading_attribute: bool

def __init__(
self, *, tables: bool = False, footnotes: bool = False,
strikethrough: bool = False, tasklists: bool = False,
smart_punctuation: bool = False, heading_attribute: bool = False
self,
*,
tables: bool = False,
footnotes: bool = False,
strikethrough: bool = False,
tasklists: bool = False,
smart_punctuation: bool = False,
heading_attribute: bool = False,
) -> None:
self.tables = tables
self.footnotes = footnotes
Expand All @@ -34,6 +41,10 @@ def __init__(
def all(cls) -> "Options":
"""Returns an Options object with all options enabled."""
return cls(
tables=True, footnotes=True, strikethrough=True,
tasklists=True, smart_punctuation=True, heading_attribute=True
tables=True,
footnotes=True,
strikethrough=True,
tasklists=True,
smart_punctuation=True,
heading_attribute=True,
)
12 changes: 7 additions & 5 deletions mizu/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ class Mizu:
options (Options): Options for parser.
loop (AbstractEventLoop): Event loop
"""

def __init__(
self, options: Options = Options(),
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.
"""
Expand All @@ -32,8 +34,8 @@ def parse(self, text: str) -> str:
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)
return await self.__parser.aioparse(text)
2 changes: 1 addition & 1 deletion tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
@pytest.mark.asyncio
async def test_parse():
m = Mizu(loop=asyncio.get_running_loop())
assert await m.aioparse("# hello") == "<h1>hello</h1>\n"
assert await m.aioparse("# hello") == "<h1>hello</h1>\n"
3 changes: 2 additions & 1 deletion tests/test_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

mizu = Mizu()


def test_parse():
assert mizu.parse("# Hello") == "<h1>Hello</h1>\n"
assert mizu.parse("# Hello") == "<h1>Hello</h1>\n"

0 comments on commit bdb82ac

Please sign in to comment.