Skip to content

mkdocs-material annotations support #7

@Viicos

Description

@Viicos

Thanks for creating this extension. At Pydantic, we have a similar custom implementation to create tabs, but it has been a source of bugs and I wanted to move away from this approach.

Unfortunately, it seems like the markdown implementation has to be done via regex, and as you probably experienced the Sphinx/docutils approach is easier to reason about.

I want to switch from our current implementation to this extension. However, we make use of mkdocs-material annotations. Looking at the implementation of annotations, it seems to be a mkdocs-material specific feature implemented in JS, and what it does is it replaces lists with annotations:

```python
a = 1  # (1)!
```

1. I will be replaced when the page is rendered

This is imo a poor design choice, but there isn't much we can do.

Do you think the regex logic of the markdown_ext.py module could be updated to support annotations? Here are some valid examples, for reference:

```python
a = 1  # (1)!
b = 2  # (2)!
```


1. An arbitrary amount of new lines can be used between the code block and the first element of the list.


2. Same for any following list element.
I can also span multiple lines.

=== "Tab 1"

    ```python
    a: int  # (1)!
    ```

    1. Annotation in tab. Watch out for the indentation.

=== "Tab 2"

    ```python
    a: int
    ```

Note that the new block API could be used, as this avoids headaches with indentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions