MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / WikiLinkExtension

Class WikiLinkExtension

markdown/extensions/wikilinks.py:37–65  ·  view source on GitHub ↗

Add inline processor to Markdown.

Source from the content-addressed store, hash-verified

35
36
37class WikiLinkExtension(Extension):
38 """ Add inline processor to Markdown. """
39
40 def __init__(self, **kwargs):
41 self.config = {
42 'base_url': ['/', 'String to append to beginning or URL.'],
43 'end_url': ['/', 'String to append to end of URL.'],
44 'html_class': ['wikilink', 'CSS hook. Leave blank for none.'],
45 'build_url': [build_url, 'Callable formats URL from label.'],
46 }
47 """ Default configuration options. """
48 super().__init__(**kwargs)
49
50 def extendMarkdown(self, md):
51 """ Register the processor.
52
53 | Class Instance | Registry | Name | Priority |
54 | --------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------ | :------: |
55 | [`WikiLinksInlineProcessor`][markdown.extensions.wikilinks.WikiLinksInlineProcessor] | [`inlinepatterns`][markdown.inlinepatterns.build_inlinepatterns] | `wikilink` | `75` |
56
57 """
58 # flake8: noqa: E501 53-55
59 self.md = md
60
61 # append to end of inline patterns
62 WIKILINK_RE = r'\[\[([\w0-9_ -]+)\]\]'
63 wikilinkPattern = WikiLinksInlineProcessor(WIKILINK_RE, self.getConfigs())
64 wikilinkPattern.md = md
65 md.inlinePatterns.register(wikilinkPattern, 'wikilink', 75)
66
67
68class WikiLinksInlineProcessor(InlineProcessor):

Callers 2

testURLCallbackMethod · 0.90
makeExtensionFunction · 0.85

Calls

no outgoing calls

Tested by 1

testURLCallbackMethod · 0.72