Insertar un enlace en texto en negrita en reStructuredText

I try to insert a link into bold text in reStructuredText but failed.

This is my rst source:

**Lorem ipsum dolor sit amet, `consectetur <http://www.example.com>`_ 
adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore 
magna aliqua.**

pero tengo:

<strong>Lorem ipsum dolor sit amet, `consectetur <http://www.example.com>`_ 
adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.</strong>

Quiero conseguir esto:

<strong>Lorem ipsum dolor sit amet, <a href="http://www.example.com">consectetur</a> 
adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua.</strong>

preguntado el 10 de marzo de 12 a las 09:03

This question was answered at stackoverflow.com/questions/4743845/… -

4 Respuestas

At the moment it seems that this is not possible: see the Docutils FAQ, specifically the question "Is nested inline markup possible". The answer basically states that nested inline markup is on the to do list, so it will eventually be possible to do what you ask in the question, and provides a couple of work arounds (which they state are not recommended).

Since the workarounds are not recommended perhaps for the time being you could just do something like:

**Lorem ipsum dolor sit amet,** `consectetur <http://www.example.com>`_ 
**adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore 
magna aliqua.**

Of course your link would not be bold, but at least it will be a valid link.

respondido 10 mar '12, 10:03

One further workaround would be to mark the whole paragraph as bold, if applicable.

.. class:: bold

Lorem ipsum dolor sit amet, `consectetur <http://www.example.com>`_ 
adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore 
magna aliqua.

respondido 20 mar '12, 13:03

Not exactly the HTML you ask for, but it creates a link inside of a fully bold text:

.. _consectetur: http://www.example.com
.. |consectetur| replace:: **consectetur** 

**Lorem ipsum dolor sit amet,** |consectetur|_ **
adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore 
magna aliqua.**

Producirá:

<strong>Lorem ipsum dolor sit amet,</strong>
<a href="http://www.example.com"><strong>consectetur</strong></a>
<strong>adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore 
magna aliqua.</strong>

Respondido 13 ago 20, 12:08

Whoa, thank you! For my purpose, this works hermosamente! - pepoluano

I've made a Shpinx extension xxlink.py which registers Docutils roles :stlink: y :emlink:.

descanso

`example <https://example.org>`__
:stlink:`example <https://example.org>`
:emlink:`example <https://example.org>`

emited HTML

<p><a class="reference external" href="https://example.org">example</a>
<strong><a class="reference external" href="https://example.org">example</a></strong>
<em><a class="reference external" href="https://example.org">example</a></em></p>

resultado

ejemplo ejemplo ejemplo

Now I don't have to define 2 extra text substitutions for every single em/strong link.

Las sugerencias son bienvenidas.

Respondido 31 Jul 21, 09:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.