Add inline processor to Markdown.
| 35 | |
| 36 | |
| 37 | class 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 | self.md = md |
| 52 | |
| 53 | # append to end of inline patterns |
| 54 | WIKILINK_RE = r'\[\[([\w0-9_ -]+)\]\]' |
| 55 | wikilinkPattern = WikiLinksInlineProcessor(WIKILINK_RE, self.getConfigs()) |
| 56 | wikilinkPattern.md = md |
| 57 | md.inlinePatterns.register(wikilinkPattern, 'wikilink', 75) |
| 58 | |
| 59 | |
| 60 | class WikiLinksInlineProcessor(InlineProcessor): |
no outgoing calls
searching dependent graphs…