FastComments.com


共享代码片段


什么是代码片段? Internal Link


代码片段是小段的代码,因此称为 "snippets",可以在评论时共享。

Code Snippet Example

在 FastComments 中,简单粘贴一段代码片段应该会被自动检测并格式化。

在发表评论时,代码片段会被包裹在 <code> 块中,格式化会在 您提交评论后发生。

在许多语言中,粘贴代码片段时,包裹到 <code> 块中是自动完成的。

或者,您可以高亮选中一段文本,然后在工具栏中单击 Code 按钮。


编程社区 Internal Link


代码片段共享对于那些可能频繁共享代码的社区非常有用。

这使得用户可以轻松地阅读共享的代码片段,几乎不需要额外的努力。

我们希望该功能使 FastComments 成为与编程相关的网站和 应用程序的理想选择。


支持的编程语言 Internal Link


在分享代码片段时,FastComments 会尽力自动判断代码片段所使用的编程语言,以自动格式化并应用语法高亮。

FastComments 的语法高亮当前支持 39 种常见语言:

  • .properties
  • Apache
  • config
  • Bash
  • C
  • C#
  • C++
  • CSS
  • CoffeeScript
  • Diff
  • Go
  • HTML, XML
  • HTTP
  • JSON
  • Java
  • JavaScript
  • Kotlin
  • Less
  • Lua
  • Makefile
  • Markdown
  • Nginx
  • config
  • Objective-C
  • PHP
  • PHP Template
  • Perl
  • Plain text
  • Python
  • Python REPL
  • R
  • Ruby
  • Rust
  • SCSS
  • SQL
  • Shell
  • Session
  • Swift
  • TOML and INI
  • TypeScript
  • Visual Basic .NET
  • YAML

When sharing a code snippet in a language we don't support, it will still be rendered like code - but no syntax highlighting or reformatting will be applied.


设置代码片段共享 Internal Link


无需任何设置即可启用此功能。它会自动为您的用户可用

当使用 FastComments 时。

分享代码片段 Internal Link

要使用代码片段支持,只需粘贴任何缩进为两个或四个空格并包含 {( 字符的代码。

或者,粘贴你的代码片段,选中它,然后点击工具栏中的 Code 选项