Support for custom Pygments formatter by sharat87 · Pull Request #1187 · Python-Markdown/markdown (original) (raw)
This looks like a great start. Before we merge this, at a minimum, we will need to address the failing tests.
- As this is a new feature, it will require us to move up to a new MINOR version (version 3.4; see the Contributing Guide). Therefore, a new file will need to be created at
docs/change_log/release-3.4.md
for the release notes, and those release notes need to be added. - The word
formatters
should be added to .spell-dict so that it is recognized as a correctly spelled word. - Some tests should be added to tests/test_syntax/extensions/test_fenced_code.py which confirm that the new API works as advertised.
Finally, I wonder if perhaps we should have some error handling to deal with bad string names and/or objects (classes/callables) which don't properly match Pygments' API. As a reminder, a user passing text to Markdown should never result in an error. However, creating an instance of the Markdown class certainly can. So any error checking usually needs to happen when the extension is loaded, not when it is passed user input. If that is not possible or practical (as I suspect is the case here), then perhaps we should fall back to a default formatter on error.