squidfunk / mkdocs-material

Documentation that simply works
https://squidfunk.github.io/mkdocs-material/
MIT License
19.71k stars 3.44k forks source link

[Material v.9] ValueError: not enough values to unpack (expected 2, got 1) during build #4718

Closed Mara-Li closed 1 year ago

Mara-Li commented 1 year ago

Contribution guidelines

I've found a bug and checked that ...

Description

Hello! During build, I have this error : ValueError: not enough values to unpack (expected 2, got 1)

Complete error :

ERROR    -  Error building page 'Compendium/Hayleen May/index.md': not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\lilis\anaconda3\envs\Publisher\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\mkdocs\__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\mkdocs\commands\serve.py", line 83, in serve
    builder(config)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\mkdocs\commands\serve.py", line 76, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\mkdocs\commands\build.py", line 329, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\mkdocs\commands\build.py", line 226, in _build_page
    context = config.plugins.run_event(
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\mkdocs\plugins.py", line 520, in run_event
    result = method(item, **kwargs)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\material\plugins\search\plugin.py", line 90, in on_page_context
    self.search_index.add_entry_from_context(page)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\material\plugins\search\plugin.py", line 143, in add_entry_from_context
    parser.feed(page.content)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\html\parser.py", line 111, in feed
    self.goahead(0)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\html\parser.py", line 173, in goahead
    k = self.parse_endtag(i)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\html\parser.py", line 421, in parse_endtag
    self.handle_endtag(elem)
  File "C:\Users\xxxx\anaconda3\envs\Publisher\lib\site-packages\material\plugins\search\plugin.py", line 415, in handle_endtag
    prev, last = data[-2:]
ValueError: not enough values to unpack (expected 2, got 1)

It seems the bug is connected to my plugin ezlinked but I think it can be forced by any non closed tags, or empty links.

When I try to debug this, with adding a local try/except ValueError I got this :

data: ['<p>'] tag: p context: []

Expected behaviour

The building process normally.

Actual behaviour

A crash occur.

Steps to reproduce

  1. Run mkdocs serve
  2. Wait for crash

Package versions

Configuration

site_name: Seed
site_description: A little owl
site_url: https://www.mara-li.fr/

theme:
    name: 'material'
    logo: assets/meta/favicons.png
    favicon: assets/meta/favicons.png
    custom_dir: overrides
    font:
        text: Karla
        code: Ubuntu Mono
    language: fr
    palette:
    # Light mode
    - media: "(prefers-color-scheme: light)"
      scheme: default
      primary: teal
      accent: light blue
      toggle:
        icon: material/weather-night
        name: Switch to dark mode

    # Dark mode
    - media: "(prefers-color-scheme: dark)"
      scheme: slate
      primary: blue grey
      accent: light blue
      toggle:
        icon: material/weather-sunny
        name: Switch to light mode
    features:
        - navigation.indexes
        - navigation.top
        - navigation.tabs
        - navigation.tabs.sticky
        - search.suggest
        - search.highlight
plugins:
  - search
  - ezlinks:
        wikilinks: true

System information

squidfunk commented 1 year ago

Thanks for reporting. Could you please try and provide a minimal reproduction? Otherwise I'm unable to debug. Thanks!

marc2k3 commented 1 year ago

I get a similar error without any plugins and have removed all customisations from my .yml and made it this minimal...

site_name: JScript Panel 3
copyright: Copyright &copy; 2022 marc2003
strict: true
theme:
  name: material
INFO     -  Building documentation...
INFO     -  Cleaning site directory
ERROR    -  Error building page 'gallery/album-art.md': not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\mkdocs\__main__.py", line 234, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, watch=watch, **kwargs)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\mkdocs\commands\serve.py", line 83, in serve
    builder(config)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\mkdocs\commands\serve.py", line 76, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\mkdocs\commands\build.py", line 329, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\mkdocs\commands\build.py", line 226, in _build_page
    context = config.plugins.run_event(
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\mkdocs\plugins.py", line 520, in run_event
    result = method(item, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\material\plugins\search\plugin.py", line 90, in on_page_context
    self.search_index.add_entry_from_context(page)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\material\plugins\search\plugin.py", line 143, in add_entry_from_context
    parser.feed(page.content)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\html\parser.py", line 110, in feed
    self.goahead(0)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\html\parser.py", line 172, in goahead
    k = self.parse_endtag(i)
        ^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\html\parser.py", line 413, in parse_endtag
    self.handle_endtag(elem)
  File "D:\Users\marc\AppData\Local\Programs\Python\Python311\Lib\site-packages\material\plugins\search\plugin.py", line 415, in handle_endtag
    prev, last = data[-2:]
    ^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)

It seems to be choking on images...

If the markdown document starts with one it breaks...

![album art](../images/album-art.png)

If I insert some plain text before, it breaks...

Some text

![album art](../images/album-art.png)

However, if you insert a heading, it's OK...

# blah

![album art](../images/album-art.png)

Inserting an admonition first also works,,

!!! note
    blah

![album art](../images/album-art.png)
Mara-Li commented 1 year ago

Thank you! I come to the same conclusion in my side !

So, a minimal testing file can be :

---
date: 08-12-2022
title: 'My journey'
---

![](random_image.png)

and:

---
date: 08-12-2022
title: 'My journey'
---

Looks at the photo i take:

![](random_image.png)

So in reality, it's not connected to ezlinks!

squidfunk commented 1 year ago

Thanks for the input, I'm able to reproduce the error.

squidfunk commented 1 year ago

Fixed in ad2c800bc43120bd5581f212e369d8f3eaab2fd1. Please try the tip of feature/material-v9 branch, and check if the error is gone:

pip install https://github.com/squidfunk/mkdocs-material/archive/feature/material-v9.zip
marc2k3 commented 1 year ago

Yep that fixes it, thanks.

But I have a new unrelated issue incoming. I'll start my own when I've got a minimal repro. :grin:

Mara-Li commented 1 year ago

Work like a charm for me!

squidfunk commented 1 year ago

Perfect, thanks for testing!

squidfunk commented 1 year ago

Released as 9.0.0b3.