24

I have an RST where I want an italicized link. However, the markup

*Warning: `Watch this <http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e>`_!*

renders in HTML as

<em>Warning: `Watch this <http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e>`_!</em>

That is, the italics render but the link doesn't. How do I get italics around the link?

Trevor Burnham
  • 76,828
  • 33
  • 160
  • 196

2 Answers2

24

The problem is that reST markup cannot be nested.

I managed to get it work with this:

Warning: |text|_

.. _text: http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e

.. |text| replace:: *Watch this*
Martin Ueding
  • 8,245
  • 6
  • 46
  • 92
  • 5
    Yikes. I've been using raw HTML as the workaround, and I think I'll stick to that. Thanks for the answer, though. – Trevor Burnham May 26 '12 at 14:40
  • 4
    Almost 10 years later, has nothing changed? – Alex Reinking Jan 28 '21 at 18:53
  • @AlexReinking: I'm not aware of anything, but I haven't used reST for a while now. The above works fine in Markdown. – Martin Ueding Jan 29 '21 at 06:43
  • That's kind of sad. Markdown is so fragmented, it's hard to have reliable tooling support (eg. paragraph reflow, formatters), but then reST lacks basic nesting while having great extensibility options. – Alex Reinking Jan 29 '21 at 07:06
  • Indeed, I dislike the fragmentation of Markdown. With Pandoc there is a large flavor, and with CommonMark we also have a specification. But not everything uses CommonMark. What do you use reST for? – Martin Ueding Jan 29 '21 at 07:22
0

Another option in this case is to use unicode italic text:

: `  <http://www.youtube.com/watch?v=dQw4w9WgXcQ&ob=av3e>`_!

Although this does mean that you are stuck with the specific formatting of those unicode characters (you can get a serif version too).

Matt Pitkin
  • 3,989
  • 1
  • 18
  • 32