Skip to content

hyphen in tag extras file tag list breaks build #6973

@galthaus

Description

@galthaus

Context

No response

Bug description

When adding this to mkdocs.yml, the build breaks.

plugins:
  - tags:
      tags_extra_files:
        tags/object.md:
          - test-automation

Produces stack trace:

ERROR   -  Error reading page 'tags/object.md': bad character range t-a at position 36
Traceback (most recent call last):
  File "/home/galthaus/docs/greg/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/mkdocs/__main__.py", line 286, in build_command
    build.build(cfg, dirty=not clean)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/mkdocs/commands/build.py", line 322, in build
    _populate_page(file.page, config, files, dirty)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/mkdocs/commands/build.py", line 171, in _populate_page
    page.markdown = config.plugins.on_page_markdown(
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/mkdocs/plugins.py", line 575, in on_page_markdown
    return self.run_event('page_markdown', markdown, page=page, config=config, files=files)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/material/plugins/tags/plugin.py", line 163, in on_page_markdown
    markdown = self._handle_deprecated_tags_extra_files(page, markdown)
  File "/home/galthaus/docs/greg/venv/lib/python3.8/site-packages/material/plugins/tags/plugin.py", line 292, in _handle_deprecated_tags_extra_files
    if not re.search(pattern, markdown):
  File "/usr/lib/python3.8/re.py", line 201, in search
    return _compile(pattern, flags).search(string)
  File "/usr/lib/python3.8/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.8/sre_parse.py", line 598, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range t-a at position 36

Related links

Reproduction

9.5.15+insiders.4.53.3-hyphen-tags-break-build.zip

Steps to reproduce

  1. Update mkdocs.yml
  2. mkdocs build

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions