Skip to content

Can't use anything for a button-link URL other than a string? #222

Open
@matterhorn103

Description

@matterhorn103

Context

Hi!

We're using Sphinx/MyST-Parser/MyST Markdown/Sphinx-Design. Sphinx-Design is really nice and has made creating an adaptable web layout very easy, so thanks.

We have one problem though. Various external URLs used on our site need to automatically adapt to the current release version being changed in conf.py.

Across the site this is in general done using myst_substitutions to insert the appropriate URL, and the URLs are defined using f-strings in conf.py so that the up-to-date URLs are generated at build time. This works fine in most places, up until wanting to use it in some Sphinx-Design buttons that I am trying to make.

Previously a particular set of link buttons were created within a Sphinx-Design card like so:

{{ '<a class="sd-sphinx-override sd-btn sd-text-wrap sd-btn-outline-primary reference external" href="' + winurl + '"><span>Download Installer</span></a>'}}

The resulting link works fine but the created button has awkward formatting and looks out of place next to the native Sphinx-Design ones, so I tried to turn them into proper SD buttons:

:::{button-link} {{winurl}}
:color: primary
:outline:
Download Installer
:::

but the substitution doesn't work.

I've scoured the web and tried myst_url_schemes as well as what feels like every possible syntax and nothing works. Why don't any of the syntaxes with ', {, <, ", ``, do anything other than pass the literal characters in this situation? Is there any way to give a URL argument to the {button-link} directive as anything other than a simple string?

Any help appreciated.

Proposal

No response

Tasks and updates

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions