Repository navigation
Ensure removing Abbreviations does not raise an error. - #1634
Merged
Merged
Conversation
In the documentation it is noted that an abbreviation defined in the global glossary can be removed for a specific document by assigning it to a blank value. However, if an abbreviation was not defined in a glossary, attempting to remove it would result in an error during rendering. The error is now avoided.
Member
Author
|
Prior to the code change, the new test would fail. Or here is a console session: >>> import markdown
>>> markdown.markdown('HTML', extensions=['abbr'], extension_configs={'abbr': {'glossary': {'HTML': 'Hyper Text Markup Language'}}})
'<p><abbr title="Hyper Text Markup Language">HTML</abbr></p>'
>>> markdown.markdown('HTML\n*[HTML]: ""', extensions=['abbr'], extension_configs={'abbr': {'glossary': {'HTML': 'Hyper Text Markup Language'}}})
'<p>HTML</p>'
>>> markdown.markdown('HTML\n*[HTML]: ""', extensions=['abbr'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\code\md\markdown\core.py", line 502, in markdown
return md.convert(text)
^^^^^^^^^^^^^^^^
File "C:\code\md\markdown\core.py", line 363, in convert
root = self.parser.parseDocument(self.lines).getroot()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code\md\markdown\blockparser.py", line 117, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "C:\code\md\markdown\blockparser.py", line 136, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "C:\code\md\markdown\blockparser.py", line 158, in parseBlocks
if processor.run(parent, blocks) is not False:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code\md\markdown\extensions\abbr.py", line 165, in run
self.abbrs.pop(abbr)
KeyError: 'HTML' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the documentation it is noted that an abbreviation defined in the global glossary can be removed for a specific document by assigning it to a blank value. However, if an abbreviation was not defined in a glossary, attempting to remove it would result in an error during rendering. The error is now avoided.
Description
AI Assistance Disclosure
Checklist