Esempio n. 1
0
def get_html(
    mapper: Type[sa.orm.Mapper], connection: sa.engine.Connection, target: sa.orm.Mapper
) -> None:
    if target.ptype == "html":
        target.html = target.content
    else:
        target.html = markdown(target.content)
Esempio n. 2
0
def render_markdown(mapper: Type[sa.orm.Mapper],
                    connection: sa.engine.Connection,
                    target: sa.orm.Mapper) -> None:
    if not target.slug:
        target.slug = slugify(target.title)
    if not target.date:
        target.date = datetime.utcnow()
    target.html = markdown(target.content)
    target.toc = markdown.renderer.render_toc()
    target.url = "/{}/{}".format(target.date.strftime("%Y/%m-%d"), target.slug)
Esempio n. 3
0
def comment_html(mapper: Type[sa.orm.Mapper], connection: sa.engine.Connection,
                 target: sa.orm.Mapper) -> None:
    # Use a more strict version of markdown parser for untrusted source.
    target.html = strict_markdown(target.content)
Esempio n. 4
0
def comment_html(
    mapper: Type[sa.orm.Mapper], connection: sa.engine.Connection, target: sa.orm.Mapper
) -> None:
    target.html = markdown(target.content)
Esempio n. 5
0
def update_post(mapper, connection: sa.engine.Connection,
                target: sa.orm.Mapper) -> None:
    target.last_modified = datetime.utcnow()
Esempio n. 6
0
def init_url(mapper, connection: sa.engine.Connection,
             target: sa.orm.Mapper) -> None:
    if target.slug:
        return
    target.slug = slugify(target.title)