Answer a question

I am talking about github markdown here, for files like README.md.

Question: Is it possible to strikethrough a complete code block in markdown on github?

I know how to mark text as a block of code

this is
multiline code

and this

this

also

by indenting by 4 spaces or by using ``` or `...

I also know how to strike through texts using

  • del tag
  • s tag
  • ~~

Temporary solution:

Independently they work fine, but together not as expected or desired. I tried several combinations of the above mentioned.

For now, I use this:

striked

through

by using ~~ and ` for every single line.

Requirement:

I would like to have a code formatted text striked through, where the code block is continuous:

unfortunately, this is
not striked through

or at least with only a small paragraph in between:

unfortunately, also not striked through

Is this possible at all?

I found some old posts and hints on using jekyll, but what I was searching for is a simple way, preferably in markdown.

Answers

After much much trying, I finally got it to work! It boils down to this:

  • inside ``` block, nothing is rendered (other than syntax for language specified)
  • inside <code> block, markdown won't render, only HTML. You can use <strike>. Its fine, but you don't get the syntax coloring
  • now for the magic: use HTML for striking, and markdown for coloring:
<strike>

```language
  this is
  multiline code
`` `

</strike>

PS.: ``` blocks should always be surrounded by blank lines to work

PS.2: had to write "`` `" there so the example wouldn't break!

PS.3: Tested in this gist: https://gist.github.com/bernardoadc/49477b77ddeffb6f78d1e7ec47834425

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐