Skip to content
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

possible regression with 2.3.6 #311

Closed
parmentelat opened this issue Oct 10, 2018 · 3 comments
Closed

possible regression with 2.3.6 #311

parmentelat opened this issue Oct 10, 2018 · 3 comments

Comments

@parmentelat
Copy link

Hi

I just was trying to upgrade from 2.3.5 to 2.3.6 and had to back off, because I ran into this:

    html = markdown_module.markdown(
        markdown, extras=['markdown-in-html', 'toc', 'header-ids'])

which triggers this:

  File "/Users/tparment/git/r2lab.inria.fr/md/views.py", line 562, in markdown_page
    markdown, extras=['markdown-in-html', 'toc', 'header-ids'])
  File "/Users/tparment/git/r2lab.inria.fr/venv/lib/python3.7/site-packages/markdown2.py", line 193, in markdown
    use_file_vars=use_file_vars, cli=cli).convert(text)
  File "/Users/tparment/git/r2lab.inria.fr/venv/lib/python3.7/site-packages/markdown2.py", line 379, in convert
    text = self._run_block_gamut(text)
  File "/Users/tparment/git/r2lab.inria.fr/venv/lib/python3.7/site-packages/markdown2.py", line 941, in _run_block_gamut
    text = self._do_headers(text)
  File "/Users/tparment/git/r2lab.inria.fr/venv/lib/python3.7/site-packages/markdown2.py", line 1585, in _do_headers
    return self._h_re.sub(self._h_sub, text)
  File "/Users/tparment/git/r2lab.inria.fr/venv/lib/python3.7/site-packages/markdown2.py", line 1565, in _h_sub
    self._toc_add_entry(n, header_id, html)
  File "/Users/tparment/git/r2lab.inria.fr/venv/lib/python3.7/site-packages/markdown2.py", line 1520, in _toc_add_entry
    if level > self._toc_depth:
AttributeError: 'Markdown' object has no attribute '_toc_depth'

everything was going fine with 2.3.5

in this particular instance, the input markdown does not contain any [TOC] flag, this is because the same code applies to several pages regardless of their having a toc or not.

A very quick reading of the code suggests that this _toc_depth attribute is not always set

@nicholasserra
Copy link
Collaborator

Thanks for the report! Will look into this asap.

thombashi added a commit to thombashi/python-markdown2 that referenced this issue Oct 12, 2018
_toc_depth initialization skipped if "toc" and "header-ids" are
specified to extras.
This will cause AttributeError in later process.
@nicholasserra
Copy link
Collaborator

@parmentelat Could you give the changes in pr #312 a spin with the input that triggered the error? Or provide the input text and I can try it. Looks like a correct fix but I want to double check. Thanks!

nicholasserra added a commit that referenced this issue Oct 15, 2018
@nicholasserra
Copy link
Collaborator

Fixed in #312

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants