From: Matthew W. <mwo...@gm...> - 2019-10-28 20:57:01
|
On 28/10/2019 12.11, Guenter Milde via Docutils-users wrote: > On 2019-10-08, Guenter Milde via Docutils-users wrote: >> On 2019-10-07, Matthew Woehlke wrote: >>> On 07/10/2019 14.11, Guenter Milde via Docutils-users wrote: >>>> You may be looking for `inline internal targets`__. >>>> >>>> __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-internal-targets >>> >>> Huh. Okay, that *sort of* works, but is there any way to style the text? >> >> Unfortunately, inline markup nesting is not supported. >> This is a long standing feature request. >> http://docutils.sourceforge.net/docs/dev/todo.html#nested-inline-markup > > Another option would be to extend `custom interpreted text roles`_ to roles > based on hyperlink targets and hyperlink references. > > __ http://docutils.sourceforge.net/docs/ref/rst/directives.html#custom-interpreted-text-roles > > Concept: > Two special roles :hyperlink-reference: and :hyperlink-target: are > defined (similar to the `:raw:`__ role). > > __ http://docutils.sourceforge.net/docs/ref/rst/roles.html#raw > > Then, the rSText:: > > .. role:: emph-link(hyperlink-target) > > :emph-link:`here` > > would create a target with class argument:: > > <target ids="target" names="target" classes="emph-link"> > target > > that could be styled accordingly. Yes, something like that could possibly work, especially as user roles can also have custom classes added. The problem currently is, as you note, there is no way to create a user role that also turns its text into an anchor. Your suggested :hyperlink-target: would fix that. Do you think a patch along those lines would be considered? (BTW, what *is* the patch process? I came across a "move to github" thread that talked about doing so as a way of making it easier to submit patches...) > Maybe we could also allow a combination of hyperlink syntax and role syntax > like:: > > This is an _`important target`:emphasis: and a very :strong:`bold link`_. While that looks technically plausible, I suspect the implementation would be much more difficult. (I have some experience with sphinx hacking, so I'm not entirely unfamiliar with the internals. I feel confident I could bash out a patch along the lines of your first idea pretty quickly. The second...?) BTW, I wonder why nested markup is such an issue? I've implemented that before for my own custom extensions, and it wasn't hard. (IIRC, something mutter something about creating an extra paragraph node, but I think I solved that by stripping out the interior node from nested_parse. At least, I had something that was working for my use case, and I don't think it would have worked with an extra paragraph node, which suggests I was able to deal with it somehow.) -- Matthew |