18

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Santosh Kumar
  • 26,475
  • 20
  • 67
  • 118

4 Answers4

14

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.

Hal W
  • 186
  • 1
  • 9
5

Not so clean solution, but works for me.

.. raw:: html

   <s>

This text is crossed out

.. raw:: html

   </s>
Praveen Kumar
  • 1,280
  • 1
  • 8
  • 14
  • Using [Nikola static blogger](https://getnikola.com/) I had to use replace your `` with `This text is crossed out.` and leave out the last `.. raw:: html` directive. Then strikethrough text was rendered in the Nikola output. Thanks for the suggestion! – dmmfll Jun 12 '16 at 11:33
2

This is not possible right now as the Markdown equivalent is top level GitHub Flavored Markdown syntax, whereas with the RST it is a document-specific style. On GitHub's repository rendering, there are currently no CSS additions permitted.

Community
  • 1
  • 1
Matthew McCullough
  • 17,160
  • 7
  • 39
  • 38
  • As [Praveen Kumar](https://stackoverflow.com/users/916125/praveen-kumar)'s [working solution](https://stackoverflow.com/a/29065401/2809027) suggests, this _is_ actually feasible... for the specific (_albeit common_) output format of HTML. Although the reST standard provides no explicit support for strikethrough, it _does_ provide explicit support for embedding raw HTML tags – including the `...` strikethrough tag. Naturally, this falls down for non-HTML output (e.g., PDF). When life hands you lemons, you hack HTML. – Cecil Curry Jan 03 '17 at 03:05
1

Or you can use https://www.thefancytext.com/strikethrough-text-generator.

S̶t̶r̶i̶k̶e̶o̶u̶t̶

Ain't fancy, but if you copy and paste it in your editor, pandoc should take it.

Dash2TheDot
  • 109
  • 1
  • 5