Replies: 1 comment
-
I will probably also want to do this, but don't have time to play with it right now. Could you put an artificial prefix on each kind of format, and pull that out in the regex? Having a distinct prefix might avoid the wrong regex greedily matching. E.g., needs_string_links = {
'render_github_user': {
'regex': r"^github:(?P<value>.+)$",
'link_url': "https://github.com/orgs/MyOrg/teams/" + "{{value}}",
'link_name': "{{value}}",
'options': ['owner']
},
'render_email_address': {
'regex': r"^mailto:(?P<value>.+)$",
'link_url' : "mailto:" + "{{value}}",
'link_name': "{{value}}"
'options': ['owner']
},
} Then in your needs, have .. need:: Need 1
:id: 1
:owner: github:john-doe_user
.. need:: Need 2
:id: 2
:owner: mailto:[email protected] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
say I have two needs of the same type, such as this:
Note that the format of the option entry for
owner
differs, the one in Need 1 is meant to represent a github user identification, the one in Need 2 is a plain email address.According to 1 there exists the option to render the owner option as a link when processed by sphinx. I want to allow both formats, but still want clickable links, hence I am hoping to write clever
needs_link_strings
to capture these cases*:In my experience this doesn't seem to work as it appears (I wasn't able to find conclusive evidence on this) that only the first entry is pulled, i.e. the first dict pertaining to the
:owner:
option is consumed and, if the regex doesn't match, nothing happens. Which is ok -- but any subsequent dicts also corresponding to the:owner:
element don't seem to be taken into account.Is there a chance that this "mulitple entry" approach could be added or "hacked around" somehow?
--
*: yes, I know that the regexes aren't the nicest ones around, but please bear with me :)
PS: I have also posted this - formed as a question - at StackOverflow: https://stackoverflow.com/q/76047208/1984137
Beta Was this translation helpful? Give feedback.
All reactions