Skip to content

Handle removed markdown version_info #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions python_jsonschema_objects/markdown_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import re
import json

try:
from markdown import __version_info__ as markdown_version_info
except ImportError:
from markdown import version_info as markdown_version_info


def extract_code_blocks(filename):
with open(filename) as fin:
Expand All @@ -14,14 +19,9 @@ def extract_code_blocks(filename):
preprocessors = M.preprocessors
tree_processors = M.treeprocessors

try:
version_info = markdown.__version_info__
except AttributeError:
version_info = markdown.version_info

# Markdown 3.* stores the processors in a class that can be iterated directly.
# Markdown 2.* stores them in a dict, so we have to pull out the values.
if version_info[0] == 2:
if markdown_version_info[0] == 2:
# Note: `markdown.version_info` will be deprecated in favor of
# `markdown.__version_info__` in later versions of Markdown.
preprocessors = preprocessors.values()
Expand All @@ -45,7 +45,7 @@ def extendMarkdown(self, md, md_globals=None):
""" Add FencedBlockPreprocessor to the Markdown instance. """
md.registerExtension(self)

if markdown.version_info[0] >= 3:
if markdown_version_info[0] >= 3:
md.preprocessors.register(
SpecialFencePreprocessor(md), "fenced_code_block", 10
)
Expand Down