Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sphinx.ext.extlinks: Allow %s in link caption string #8898

Merged
merged 4 commits into from Apr 11, 2021
Merged

sphinx.ext.extlinks: Allow %s in link caption string #8898

merged 4 commits into from Apr 11, 2021

Commits on Feb 15, 2021

  1. sphinx.ext.extlinks: Allow %s in link caption string

    Tweak syntax of extlinks to also allow ``%s`` in the link caption part.
    Like for the base URL ``%s`` will be substituted with the content of the
    role.  This allows configurations like
    
        extlinks = {'quarter': ('https://example.org/quaters/%s',
                              '%s. quarter')}
    
    with ``:quarter:`2``` getting replaced by a link titled `2. quarter`.
    
    The requirement for the caption string is to be either None or contain
    exactly one ``%s``.  If neither is the case, then we emit a warning and
    fall back to the old behaviour which is concatenating the caption string
    with the role content.
    Merry Bass committed Feb 15, 2021
    Copy the full SHA
    6ca568c View commit details
    Browse the repository at this point in the history

Commits on Apr 9, 2021

  1. sphinx.ext.extlinks: Clarify escaping of %

    We use Pythons %-formatting, so literal ``%`` must be escaped as ``%%``.
    Clarify this behaviour for the caption and base URL strings.
    Merry Bass committed Apr 9, 2021
    Copy the full SHA
    c39f147 View commit details
    Browse the repository at this point in the history
  2. fixup! sphinx.ext.extlinks: Clarify escaping of %

    Merry Bass committed Apr 9, 2021
    Copy the full SHA
    120daee View commit details
    Browse the repository at this point in the history
  3. fixup! sphinx.ext.extlinks: Allow %s in link caption string

    The old syntax will be deprecated in 4.x and 5.x and removed in Sphinx
    6.0.
    Merry Bass committed Apr 9, 2021
    Copy the full SHA
    ee9c7d3 View commit details
    Browse the repository at this point in the history