在github上降价的删除线代码 [英] strikethrough code in markdown on github

查看:203
本文介绍了在github上降价的删除线代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里讨论 github markdown ,对于像 README.md 这样的文件。




是否可以通过github上的markdown删除完整的代码块?


我知道如何标记文本作为一段代码

 这是
多行代码


this







通过4个空格或使用```或`...

缩进

我也知道如何<使用


  • 删除标记
  • s标记
  • >
  • ~~



临时解决方案



独立地,它们工作正常,但并非如预期或期望的那样。我尝试了上面提到的几种组合。



现在,我使用这个:

striked



through



通过对每一行使用~~和`。

要求

strong>:



我想要一个代码格式化的文本,其中代码块是连续的:

 不幸的是,这是
没有穿过

或者至少只有一小段:

不幸的是,也没有通过


这完全有可能吗?



我发现了一些旧帖子和关于使用jekyll的提示,但我正在寻找的是一个简单的方法,最好是在降价。

解决方案

这只适用于原始HTML, GitHub不允许。但你也许可以使用diff。





我意识到格式不会使用透视,但会使用常用和理解的格式。对于更复杂的块,您应该使用 diff 实用程序为您生成差异。


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.

解决方案

This would only be possible with raw HTML, which GitHub doesn't allow. But you may be able to use a diff instead.

Code blocks are for "pre-formatted" text only. The only formatting you can get in a code block is the formatting that can be represented in plain text (indentation, capitalization, etc). There is no mechanism to mark up the content of a code block (as bold, italic, stricken, underlined, etc). This was an intentional design decision. Otherwise, how would you be able to show Markdown text in a code block? If you want formatted text, then you need to use something other than a code block.

As the rules state:

HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.

Therefore you would need to format your own custom HTML code block with the various bits marked up properly:

<pre><code><del>some stricken code</del>
<del>A second line of stricken code</del>
</pre></code>

However, for security reasons, GitHub will strip out any such raw HTML in your Markdown. So while this works where you have full control of the entire stack, on a hosted service it is most likely not possible.

However, I'm assuming you want to show some changes made to a block of code. As it turns out, a specific format already exists for that. Namely a diff. Just use a fenced code block with diff as the language and GitHub will format it correctly:

```diff
  Unchanged Line
- Removed Line
+ Added Line
```

You can see how GitHub displays the above code block live (you can also see that in raw), but I've included a screenshot below for convenience.

I realize that the formatting does not use strike-through, but is does use a commonly used and understood format. For more complex blocks, you should probably use thediff utility program to generate the diff for you.

这篇关于在github上降价的删除线代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆