{"action":"created","issue":{"url":"https://api.github.com/repos/waylan/Python-Markdown/issues/490","repository_url":"https://api.github.com/repos/waylan/Python-Markdown","labels_url":"https://api.github.com/repos/waylan/Python-Markdown/issues/490/labels{/name}","comments_url":"https://api.github.com/repos/waylan/Python-Markdown/issues/490/comments","events_url":"https://api.github.com/repos/waylan/Python-Markdown/issues/490/events","html_url":"https://github.com/waylan/Python-Markdown/pull/490","id":173323458,"number":490,"title":"Add ability to specify custom Formatter for Pygments code highlighting","user":{"login":"dprothero","id":1897006,"avatar_url":"https://avatars.githubusercontent.com/u/1897006?v=3","gravatar_id":"","url":"https://api.github.com/users/dprothero","html_url":"https://github.com/dprothero","followers_url":"https://api.github.com/users/dprothero/followers","following_url":"https://api.github.com/users/dprothero/following{/other_user}","gists_url":"https://api.github.com/users/dprothero/gists{/gist_id}","starred_url":"https://api.github.com/users/dprothero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dprothero/subscriptions","organizations_url":"https://api.github.com/users/dprothero/orgs","repos_url":"https://api.github.com/users/dprothero/repos","events_url":"https://api.github.com/users/dprothero/events{/privacy}","received_events_url":"https://api.github.com/users/dprothero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-25T22:14:25Z","updated_at":"2016-08-26T00:36:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/waylan/Python-Markdown/pulls/490","html_url":"https://github.com/waylan/Python-Markdown/pull/490","diff_url":"https://github.com/waylan/Python-Markdown/pull/490.diff","patch_url":"https://github.com/waylan/Python-Markdown/pull/490.patch"},"body":"In our use of the Python-Markdown library, we discovered the need to be able to use a custom Pygments Formatter class. Pygments supports creating custom formatters, but there wasn't a way to have the `CodeHiliteExtension` utlize them.\r\n\r\nI've added `pygments_formatter` as a config option for the `CodeHiliteExtension` class (which is also used by `FencedCodeExtension`). It can take a string, which will be passed to the call to Pygments' `get_formatter_by_name` function. It defaults to 'html', which is what was hard-coded before.\r\n\r\nAlso, the option can take a reference to a class. This makes it convenient to specify a custom class in code without having to create a separate package for your custom formatter. Usage is something like this:\r\n\r\n```\r\ndef get_html_from_markdown(value):\r\n    # Use the extra extensions\r\n    from code_samples.code_formatters import MarkdownHtmlFormatter\r\n    return markdown.markdown(value, extensions=[\r\n        'markdown.extensions.extra',\r\n        TocExtension(anchorlink=True),\r\n        CodeHiliteExtension(pygments_formatter=MarkdownHtmlFormatter)])\r\n```\r\n\r\nThe last line of code demonstrates the usage.\r\n\r\nAll tests pass (aside from those marked as Skip), including the additional test I added. Let me know if you'd like any modifications."},"comment":{"url":"https://api.github.com/repos/waylan/Python-Markdown/issues/comments/242588220","html_url":"https://github.com/waylan/Python-Markdown/pull/490#issuecomment-242588220","issue_url":"https://api.github.com/repos/waylan/Python-Markdown/issues/490","id":242588220,"user":{"login":"waylan","id":78846,"avatar_url":"https://avatars.githubusercontent.com/u/78846?v=3","gravatar_id":"","url":"https://api.github.com/users/waylan","html_url":"https://github.com/waylan","followers_url":"https://api.github.com/users/waylan/followers","following_url":"https://api.github.com/users/waylan/following{/other_user}","gists_url":"https://api.github.com/users/waylan/gists{/gist_id}","starred_url":"https://api.github.com/users/waylan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waylan/subscriptions","organizations_url":"https://api.github.com/users/waylan/orgs","repos_url":"https://api.github.com/users/waylan/repos","events_url":"https://api.github.com/users/waylan/events{/privacy}","received_events_url":"https://api.github.com/users/waylan/received_events","type":"User","site_admin":false},"created_at":"2016-08-26T00:36:09Z","updated_at":"2016-08-26T00:36:09Z","body":"Oh, and before you ask, the timeline is \"when it's done.\""}}
{"actor":{"display_login":"waylan"}}