Menu

#115 Add directive option value type "strip_quotes"

Default
open
nobody
None
5
2025-05-14
2025-05-14
No

The "include" directive options :start-after: and :end-before: as well as the "sectnum" directive options :prefix: and :suffix: accept values of type "text". However, currently, there is no syntax for text option values starting or ending with whitespace.

Proposal:
Define a new conversion function parsers.rst.directives.strip_quotes and use it in the Directive.option_spec of :start-after:, :end-before:, :prefix:, and :suffix:. The function should remove one pair of double-quote characters from the option value (only, if there are double quotes at both, start and end of the value).

Use case: enumerate sections with "Chapter 1", "Chapter 2", ... with

.. sectnum::
    :prefix: "Chapter "
    :depth: 1

Use case: include file "example.rst" up to the first occurence of word (starting with a space character).

.. include::
    :end-before: " word"

As this is a backwards-incompatible change, it should be announced one version in advance.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.