# Path: cab/utils.py
# def sanitize_markdown(value):
#     return mark_safe(
#         bleach.clean(
#             markdown_func(value),
#             tags=[
#                 "a",
#                 "abbr",
#                 "acronym",
#                 "b",
#                 "blockquote",
#                 "code",
#                 "em",
#                 "h1",
#                 "h2",
#                 "h3",
#                 "h4",
#                 "h5",
#                 "h6",
#                 "i",
#                 "li",
#                 "ol",
#                 "p",
#                 "pre",
#                 "strong",
#                 "ul",
#             ],
#         )
#     )


from django import template
from django.utils.safestring import mark_safe
from markdown import markdown as markdown_func
from ..utils import sanitize_markdown


register = template.Library()


@register.filter
def markdown(value):
    """
    Run Markdown over a given value.
    """
    return mark_safe(markdown_func(value))


@register.filter
def safe_markdown(value):
    """
    Strip raw HTML and run Markdown over a given value.
    """

# Path: cab/utils.py
# def sanitize_markdown(value):
#     return mark_safe(
#         bleach.clean(
#             markdown_func(value),
#             tags=[
#                 "a",
#                 "abbr",
#                 "acronym",
#                 "b",
#                 "blockquote",
#                 "code",
#                 "em",
#                 "h1",
#                 "h2",
#                 "h3",
#                 "h4",
#                 "h5",
#                 "h6",
#                 "i",
#                 "li",
#                 "ol",
#                 "p",
#                 "pre",
#                 "strong",
#                 "ul",
#             ],
#         )
#     )


# Path: cab/templatetags/markup.py
from django import template
from django.utils.safestring import mark_safe
from markdown import markdown as markdown_func
from ..utils import sanitize_markdown



register = template.Library()


@register.filter
def markdown(value):
    """
    Run Markdown over a given value.
    """
    return mark_safe(markdown_func(value))


@register.filter
def safe_markdown(value):
    """
    Strip raw HTML and run Markdown over a given value.
    """

    return sanitize_markdown(value)