diff options
author | Isaac Muse <faceless.shop@gmail.com> | 2018-01-04 13:07:45 -0700 |
---|---|---|
committer | Waylan Limberg <waylan.limberg@icloud.com> | 2018-01-04 15:07:45 -0500 |
commit | 1de595a4a9c5536d32d597dba799cd036582af0f (patch) | |
tree | 3d0a7f5c99938a8fcc1101de252ba0b943e57395 /markdown | |
parent | bbada79726d900ef9ae5410ab3a0ce573a742c00 (diff) | |
download | markdown-1de595a4a9c5536d32d597dba799cd036582af0f.tar.gz markdown-1de595a4a9c5536d32d597dba799cd036582af0f.tar.bz2 markdown-1de595a4a9c5536d32d597dba799cd036582af0f.zip |
Fix raw html reference issue (#585)
Preserve the line which a reference was on to prevent raw HTML indexing issue. Fixes #584.
Prevent raw HTML parsing issue in abbr and footnotes
Peserve abbreviation line when stripping and preserve a line for each footnote block. Footnotes should also accumulate the extraneous padding.
Test extra lines at the end of references
Strip the gathered extraneous whitespace
When processing footnotes, we don't actually care to process the extra whitespace at the end of a footnote, but we want it to calculate lines to preserve.
Diffstat (limited to 'markdown')
-rw-r--r-- | markdown/extensions/abbr.py | 3 | ||||
-rw-r--r-- | markdown/extensions/footnotes.py | 12 | ||||
-rw-r--r-- | markdown/preprocessors.py | 3 |
3 files changed, 17 insertions, 1 deletions
diff --git a/markdown/extensions/abbr.py b/markdown/extensions/abbr.py index bfa8c10..ec2428a 100644 --- a/markdown/extensions/abbr.py +++ b/markdown/extensions/abbr.py @@ -53,6 +53,9 @@ class AbbrPreprocessor(Preprocessor): title = m.group('title').strip() self.markdown.inlinePatterns['abbr-%s' % abbr] = \ AbbrPattern(self._generate_pattern(abbr), title) + # Preserve the line to prevent raw HTML indexing issue. + # https://github.com/Python-Markdown/markdown/issues/584 + new_text.append('') else: new_text.append(line) return new_text diff --git a/markdown/extensions/footnotes.py b/markdown/extensions/footnotes.py index cdaf391..072c5dd 100644 --- a/markdown/extensions/footnotes.py +++ b/markdown/extensions/footnotes.py @@ -238,7 +238,12 @@ class FootnotePreprocessor(Preprocessor): fn, _i = self.detectTabbed(lines[i+1:]) fn.insert(0, m.group(2)) i += _i-1 # skip past footnote - self.footnotes.setFootnote(m.group(1), "\n".join(fn)) + footnote = "\n".join(fn) + self.footnotes.setFootnote(m.group(1), footnote.rstrip()) + # Preserve a line for each block to prevent raw HTML indexing issue. + # https://github.com/Python-Markdown/markdown/issues/584 + num_blocks = (len(footnote.split('\n\n')) * 2) + newlines.extend([''] * (num_blocks)) else: newlines.append(lines[i]) if len(lines) > i+1: @@ -290,6 +295,11 @@ class FootnotePreprocessor(Preprocessor): if lines[j].strip(): next_line = lines[j] break + else: + # Include extreaneous padding to prevent raw HTML + # parsing issue: https://github.com/Python-Markdown/markdown/issues/584 + items.append("") + i += 1 else: break # There is no more text; we are done. diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index 94f9830..1e99afa 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -346,6 +346,9 @@ class ReferencePreprocessor(Preprocessor): lines.pop(0) t = tm.group(2) or tm.group(3) or tm.group(4) self.markdown.references[id] = (link, t) + # Preserve the line to prevent raw HTML indexing issue. + # https://github.com/Python-Markdown/markdown/issues/584 + new_text.append('') else: new_text.append(line) |