diff options
| author | 2022-08-05 01:00:19 -0400 | |
|---|---|---|
| committer | 2022-08-05 01:00:19 -0400 | |
| commit | 393aa58f2c5afd51f92fd9bd4b6dfd0dc90cea41 (patch) | |
| tree | a61de275324558358abc0c85f85827649a159512 /nikola/plugins/compile/markdown/mdx_gist.py | |
| parent | 942e313727d1ad886a1024c24fe4a9e8e2e0bb3e (diff) | |
New upstream version 8.2.3.upstream/8.2.3
Diffstat (limited to 'nikola/plugins/compile/markdown/mdx_gist.py')
| -rw-r--r-- | nikola/plugins/compile/markdown/mdx_gist.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/nikola/plugins/compile/markdown/mdx_gist.py b/nikola/plugins/compile/markdown/mdx_gist.py index f6ce20a..fc24d34 100644 --- a/nikola/plugins/compile/markdown/mdx_gist.py +++ b/nikola/plugins/compile/markdown/mdx_gist.py @@ -76,19 +76,19 @@ Error Case: non-existent file: """ import requests +import xml.etree.ElementTree as etree from nikola.plugin_categories import MarkdownExtension from nikola.utils import get_logger try: from markdown.extensions import Extension - from markdown.inlinepatterns import Pattern + from markdown.inlinepatterns import InlineProcessor from markdown.util import AtomicString - from markdown.util import etree except ImportError: # No need to catch this, if you try to use this without Markdown, # the markdown compiler will fail first - Extension = Pattern = object + Extension = InlineProcessor = AtomicString = object LOGGER = get_logger('compile_markdown.mdx_gist') @@ -112,12 +112,12 @@ class GistFetchException(Exception): status_code, url) -class GistPattern(Pattern): +class GistPattern(InlineProcessor): """InlinePattern for footnote markers in a document's body text.""" def __init__(self, pattern, configs): """Initialize the pattern.""" - Pattern.__init__(self, pattern) + InlineProcessor.__init__(self, pattern) def get_raw_gist_with_filename(self, gist_id, filename): """Get raw gist text for a filename.""" @@ -139,8 +139,9 @@ class GistPattern(Pattern): return resp.text - def handleMatch(self, m): + def handleMatch(self, m, _): """Handle pattern match.""" + # The third arg is "data", wider context around the match; we don't need it. gist_id = m.group('gist_id') gist_file = m.group('filename') @@ -170,7 +171,7 @@ class GistPattern(Pattern): warning_comment = etree.Comment(' WARNING: {0} '.format(e.message)) noscript_elem.append(warning_comment) - return gist_elem + return (gist_elem, m.start(0), m.end(0)) class GistExtension(MarkdownExtension, Extension): |
