--Snipplr—解决方法:注释中的代码

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了--Snipplr—解决方法:注释中的代码相关的知识,希望对你有一定的参考价值。

For some reason, Snipplr has decided not to html-encode <code>&lt;</code> and <code>&gt;</code> signs (i.e., replacing them with `&lt;` and `&gt;`) that a user inputs into a comment box, and instead strips anything that looks like a tag from the comment entirely.

So, if you enter something like <code>&#96;&lt;div&gt;test&lt;/div&gt;&#96;</code> in the comment box, you would expect to see <code>&lt;div&gt;test&lt;/div&gt;</code> in the post but you would actually end up with `test`.

The exceptions that I've found are `<b>`, `<i>`, `<em>`, `<strong>`, and `<code>` tags.

The only reliable way to get around this odd implementation is to use the code tag with its content already HTML-encoded, just like you would if you were writing your own HTML. So entering something like <code>&lt;code&gt;&amp;lt;div&amp;gt;test&amp;lt;/div&amp;gt;&lt;/code&gt;</code> will give the expected result <code>&lt;div&gt;test&lt;/div&gt;</code>.

Note that you will also have to replace the back-ticks with `&#96;`

FYI, here is the code I used to create this description itself. The same code is entered in the first comment below (note the difference where the back-ticks are used to surround this: `test`).
  1. For some reason, Snipplr has decided not to HTML-encode <code>&lt;</code> and <code>&gt;</code> signs (i.e., replacing them with `&lt;` and `&gt;`) that a user inputs into a comment box, and instead strips anything that looks like a tag from the comment entirely.
  2.  
  3. So, if you enter something like <code>&#96;&lt;div&gt;test&lt;/div&gt;&#96;</code> in the comment box, you would expect to see <code>&lt;div&gt;test&lt;/div&gt;</code> in the post but you would actually end up with `test`.
  4.  
  5. The exceptions that I've found are `<b>`, `<i>`, `<em>`, `<strong>`, and `<code>` tags.
  6.  
  7. The only reliable way to get around this odd implementation is to use the code tag with its content already HTML-encoded, just like you would if you were writing your own HTML. So entering something like <code>&lt;code&gt;&amp;lt;div&amp;gt;test&amp;lt;/div&amp;gt;&lt;/code&gt;</code> will give the expected result <code>&lt;div&gt;test&lt;/div&gt;</code>.
  8.  
  9. Note that you will also have to replace the back-ticks with `&#96;`
  10.  
  11. FYI, here is the code I used to create this description itself. The same code is entered in the first comment below (note the difference where the back-ticks are used to surround this: `<div>test</div>`).

以上是关于--Snipplr—解决方法:注释中的代码的主要内容,如果未能解决你的问题,请参考以下文章

备份你自己的snipplr.com网站片段

vbscript 各种自定义代码片段 - 有关详细信息,请参阅注释

用于Snipplr API的Snipplr代码段结构

解决IDEA中的CTRL+/ 快捷注释键不自动缩进

解决方案电影标题中缺少代码的片段,完成挑战更多[关闭]

解决IDEA中的CTRL+/ 快捷注释键不自动缩进