# Path: wikked/utils.py
# def get_meta_name_and_modifiers(name):
#     """ Strips a meta name from any leading modifiers like `__` or `+`
#         and returns both as a tuple. If no modifier was found, the
#         second tuple value is `None`.
#     """
#     clean_name = name
#     modifiers = None
#     if name[:2] == '__':
#         modifiers = '__'
#         clean_name = name[3:]
#     elif name[0] == '+':
#         modifiers = '+'
#         clean_name = name[1:]
#     return (clean_name, modifiers)
# 
# def html_escape(text):
#     return escape(text, html_escape_table)
# 
# def split_page_url(url):
#     m = endpoint_regex.match(url)
#     if m is None:
#         return (None, url)
#     endpoint = m.group(1)
#     path = m.group(2)
#     return (endpoint, path)
# 
# def get_url_tail(url):
#     return os.path.basename(url)


import os
import os.path
import re
import logging
import jinja2
from io import StringIO
from .utils import (
    get_meta_name_and_modifiers, html_escape, split_page_url, get_url_tail)
            if endpoint in self.endpoints:
                return self.endpoints[endpoint](
                    ctx, endpoint, name.strip(), value.strip(), frag)
            return self._formatEndpointLink(
                ctx, endpoint, name.strip(), value.strip(), frag)
        text = RE_LINK_ENDPOINT.sub(repl1, text)

        # [[display name|endpoint:Something/Whatever]]
        def repl2(m):
            display = m.group(1).strip()
            endpoint = m.group(2)
            value = m.group(3).strip()
            frag = m.group(4)
            if endpoint in self.endpoints:
                return self.endpoints[endpoint](
                    ctx, endpoint, display, value, frag)
            return self._formatEndpointLink(
                ctx, endpoint, display, value, frag)
        text = RE_LINK_ENDPOINT_DISPLAY.sub(repl2, text)

        # [[display name|Whatever/PageName]]
        def repl3(m):
            return s._formatWikiLink(ctx, m.group(1).strip(),
                                     m.group(2).strip(),
                                     m.group(3))
        text = RE_LINK_DISPLAY.sub(repl3, text)

        # [[Namespace/PageName]]
        def repl4(m):
            value, frag = m.group(1, 2)

# Path: wikked/utils.py
# def get_meta_name_and_modifiers(name):
#     """ Strips a meta name from any leading modifiers like `__` or `+`
#         and returns both as a tuple. If no modifier was found, the
#         second tuple value is `None`.
#     """
#     clean_name = name
#     modifiers = None
#     if name[:2] == '__':
#         modifiers = '__'
#         clean_name = name[3:]
#     elif name[0] == '+':
#         modifiers = '+'
#         clean_name = name[1:]
#     return (clean_name, modifiers)
# 
# def html_escape(text):
#     return escape(text, html_escape_table)
# 
# def split_page_url(url):
#     m = endpoint_regex.match(url)
#     if m is None:
#         return (None, url)
#     endpoint = m.group(1)
#     path = m.group(2)
#     return (endpoint, path)
# 
# def get_url_tail(url):
#     return os.path.basename(url)


# Path: wikked/formatter.py
import os
import os.path
import re
import logging
import jinja2
from io import StringIO
from .utils import (
    get_meta_name_and_modifiers, html_escape, split_page_url, get_url_tail)

            if endpoint in self.endpoints:
                return self.endpoints[endpoint](
                    ctx, endpoint, name.strip(), value.strip(), frag)
            return self._formatEndpointLink(
                ctx, endpoint, name.strip(), value.strip(), frag)
        text = RE_LINK_ENDPOINT.sub(repl1, text)

        # [[display name|endpoint:Something/Whatever]]
        def repl2(m):
            display = m.group(1).strip()
            endpoint = m.group(2)
            value = m.group(3).strip()
            frag = m.group(4)
            if endpoint in self.endpoints:
                return self.endpoints[endpoint](
                    ctx, endpoint, display, value, frag)
            return self._formatEndpointLink(
                ctx, endpoint, display, value, frag)
        text = RE_LINK_ENDPOINT_DISPLAY.sub(repl2, text)

        # [[display name|Whatever/PageName]]
        def repl3(m):
            return s._formatWikiLink(ctx, m.group(1).strip(),
                                     m.group(2).strip(),
                                     m.group(3))
        text = RE_LINK_DISPLAY.sub(repl3, text)

        # [[Namespace/PageName]]
        def repl4(m):
            value, frag = m.group(1, 2)

            name = get_url_tail(value)