<commit_before>import mistune
import threading
from weakref import ref as weakref

from markupsafe import Markup

from lektor.context import get_ctx
from werkzeug.urls import url_parse


_markdown_cache = threading.local()


class ImprovedRenderer(mistune.Renderer):

    def link(self, link, title, text):
        if self.record is not None:
            url = url_parse(link)
            if not url.scheme:
                link = self.record.url_to('!' + link,
                                          base_url=get_ctx().base_url)
        return mistune.Renderer.link(self, link, title, text)


class MarkdownConfig(object):

    def __init__(self):
        self.options = {}
        self.renderer_base = ImprovedRenderer<commit_msg>Implemented relative URL processing for images in markdown.<commit_after>import mistune
import threading
from weakref import ref as weakref

from markupsafe import Markup

from lektor.context import get_ctx
from werkzeug.urls import url_parse


_markdown_cache = threading.local()


class ImprovedRenderer(mistune.Renderer):

    def link(self, link, title, text):
        if self.record is not None:
            url = url_parse(link)
            if not url.scheme:
                link = self.record.url_to('!' + link,
                                          base_url=get_ctx().base_url)
        return mistune.Renderer.link(self, link, title, text)

    def image(self, src, title, text):
        if self.record is not None:
            url = url_parse(src)
            if not url.scheme:
                src = self.record.url_to('!' + src,
                                         base_url=get_ctx().base_url)
        return mistune.Renderer.image(self, src, title, text)


class MarkdownConfig(object):

    def __init__(self):
        self.options = {}
        self.renderer_base = ImprovedRenderer
{'fraction_non_alphanumeric': 0.08315217391304348, 'fraction_numerical': 0.0, 'mean_word_length': 2.2816399286987523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '872743', 'n_tokens_mistral': 520, 'n_tokens_neox': 507, 'n_words': 144}