Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do strikethrough in a reStructuredText file hosted on GitHub?

I am converting a README.md file to README.rst. The reason is, I am going to make a package available to PyPi. I am forced to use .rst.

My conversion is nearly complete, but I have a strikethrough line in my markdown file, e.g.:

~~This text is crossed out~~

which renders on GitHub as crossed out. But I am unable to do this in reStructuredText. A similar post on StackOverflow suggests defining a strike like this:

.. role:: strike
    :class: strike

And using something like this in the CSS file:

.strike {
  text-decoration: line-through;
}

And do strikethrough like this:

:strike:`This text is crossed out`

But the problem is I have no control over CSS file of GitHub.

like image 214
Santosh Kumar Avatar asked Apr 13 '13 15:04

Santosh Kumar


2 Answers

You can also use substitutions to make multiple uses easier. Put this markup somewhere in your file:

.. |ss| raw:: html

   <strike>

.. |se| raw:: html

   </strike>

Then just enclose the text to be struck out with |ss| & |se|:

One, |ss| two |se|, three |ss| strikes |se| you're out!

will render as:

One, two , three strikes you're out!

Just be sure to have space around the substitution elements, so they are parsed correctly. It looks a bit awkward here, but this is a contrived example.

like image 180
Hal W Avatar answered Sep 28 '22 05:09

Hal W


Not so clean solution, but works for me.

.. raw:: html

   <s>

This text is crossed out

.. raw:: html

   </s>
like image 45
Praveen Kumar Avatar answered Sep 28 '22 05:09

Praveen Kumar