Skip to content

Typeset plugin breaks with some Markdown in titles #5797

@tiangolo

Description

@tiangolo

Context

Versions:

Python: Python 3.10.3
mkdocs: 1.5.2
mkdocs-material: 9.1.21+insiders.4.38.1
mkdocs-material-extensions: 1.1.1

MkDocs Material versions

This breaks with the latest version: 9.1.21-insiders-4.38.1

It worked with the previous version (just tested it): 9.1.21-insiders-4.38.0

Bug description

Typeset plugin breaks with some Markdown in titles, the example markdown that breaks is:

### About `**user_in.dict()`

Interestingly, this doesn't break:

### About `user_in.dict()`

...my theory is that something is trying to parse the double ** as a bold in Markdown, but it's inside a code block/fragment. Not sure, just a quick theory.


A sample of the error:

❯ mkdocs build 
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /Users/user/code/try-mkdocs/site
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
             - tutorial/index.md
             - tutorial/first-steps.md
ERROR   -  Error reading page 'index.md': multiple repeat at position 27
Traceback (most recent call last):
  File "/Users/user/code/try-mkdocs/env3.10/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/mkdocs/__main__.py", line 286, in build_command
    build.build(cfg, dirty=not clean)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/mkdocs/commands/build.py", line 322, in build
    _populate_page(file.page, config, files, dirty)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/mkdocs/commands/build.py", line 179, in _populate_page
    page.content = config.plugins.on_page_content(
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/mkdocs/plugins.py", line 578, in on_page_content
    return self.run_event('page_content', html, page=page, config=config, files=files)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
  File "/Users/user/code/try-mkdocs/env3.10/lib/python3.10/site-packages/material/plugins/typeset/plugin.py", line 77, in on_page_content
    if re.search(rf"data-toc-label=['\"]{label}", page.markdown):
  File "/Users/user/.pyenv/versions/3.10.3/lib/python3.10/re.py", line 200, in search
    return _compile(pattern, flags).search(string)
  File "/Users/user/.pyenv/versions/3.10.3/lib/python3.10/re.py", line 303, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/Users/user/.pyenv/versions/3.10.3/lib/python3.10/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/Users/user/.pyenv/versions/3.10.3/lib/python3.10/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/Users/user/.pyenv/versions/3.10.3/lib/python3.10/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/Users/user/.pyenv/versions/3.10.3/lib/python3.10/sre_parse.py", line 671, in _parse
    raise source.error("multiple repeat",
re.error: multiple repeat at position 27

I found it on CI and tested it locally on Linux and macOS.

Related links

Reproduction

mkdocs.yml

site_name: Demo
theme:
  name: material

nav:
- index.md

plugins: 
  typeset:

docs/index.md

### About `**user_in.dict()`

Steps to reproduce

  • Install MkDocs Insiders
  • Copy those two files
  • Run:
mkdocs build

Browser

Other

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