Skip to content

Automatic link text generation in captions extensionΒ #2670

@BFuhry

Description

@BFuhry

Description

First, thank you very much for pymdown overall.
Furthermore, I highly appreciate the captions extension that was introduced recently.

With the the current captions extensions of pymdown, the following works:

In the following, shows [Figure 1](#fig_diagram) a decision diagram.

![placeholder](diagram.svg)
/// figure-caption
    attrs: {id: fig_diagram}
Decision Diagram
///

However, when a figure is moved around or when add a new figure is added before this figure, Figure 1 is no longer an appropriate text.

Therefore, I would like an automatic link text generation for the captions using the type + number, e.g., Figure 1, Table 1, Table 5.
Optionally, it would be nice to have the possibility to create type + number + caption, e.g., Figure 1. Decision Diagram.

Benefits

Removes the need to remember link text adjustment when a the number of a captioned block, e.g., a figure or table, changes.

Solution Idea

For example, mkdocs-caption provides such a feature and details can be found at https://tobiasah.github.io/mkdocs-caption/references/#automatic-link-text-generation. In short: using [](#fig_diagram) as a link placeholder will automatically generate <a href="#fig_diagram)">Figure 1</a> in HTML.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P: maybePending approval of low priority request.T: featureFeature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions