如何在 wordpress.com 上发布代码博客

发布于 2024-07-06 11:50:28 字数 1570 浏览 6 评论 0 原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

人疚 2024-07-13 11:50:28

请参阅此处:http://en.support.wordpress.com/code/ posts-source-code/

将代码包含在这些标签中: [sourcecode language='css'] .. [/sourcecode]

(或更短的 [code lang='css'] .. [/code]

)可视化编辑器不会解释标签,您需要单击“预览”来查看它是如何工作的。

可用的语言代码:

  • actionscript3
  • bash
  • clojure
  • Coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • erlang
  • fsharp
  • diff
  • groovy
  • html
  • javascript
  • java
  • javafx
  • matlab(仅限关键字)
  • objc
  • perl
  • php
  • text
  • powershell
  • python
  • r
  • ruby
  • ​​ scala
  • sql
  • vb
  • xml

See here: http://en.support.wordpress.com/code/posting-source-code/

Wrap your code in these tags: [sourcecode language='css'] .. [/sourcecode]

(or shorter [code lang='css'] .. [/code] )

Note that Visual Editor doesn't interpret the tags, you need to click Preview to see how it works.

Available language codes:

  • actionscript3
  • bash
  • clojure
  • coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • erlang
  • fsharp
  • diff
  • groovy
  • html
  • javascript
  • java
  • javafx
  • matlab (keywords only)
  • objc
  • perl
  • php
  • text
  • powershell
  • python
  • r
  • ruby
  • scala
  • sql
  • vb
  • xml
无力看清 2024-07-13 11:50:28

您还可以使用hilite.me。 它不需要安装插件或 JS/CSS 文件。 它也是开源的并且有 API。

免责声明:我是开发者。

You can also use hilite.me. It doesn't require installation of plugins or JS/CSS files. It's also open-source and has an API.

Disclaimer: I'm the developer.

多像笑话 2024-07-13 11:50:28

蜡笔语法荧光笔是一个优秀的免费插件。 我选择了这个,但我遇到的许多其他可能可以达到目的:

Crayon Syntax Highlighter is an excellent free plugin. I went with that one, but there are many others I came across that may serve the purpose:

亢潮 2024-07-13 11:50:28

有一个<代码> 您可以使用 html 元素。 否则,您可以尝试 TextileMarkdown 语法(我不确定 WordPress.com 是否使用它们)。 尝试一下并使用 WordPress 中的预览功能来查看是否正确。

There's a <code> html element you can use. Otherwise you could try the Textile or Markdown syntaxes (I'm not sure if WordPress.com uses them). Try it out and use the preview function in WordPress to see when you get it right.

夜声 2024-07-13 11:50:28

通过我的 Wordpress.org 安装,我无法获得接受的答案 在这里工作(不确定这是否只适用于 Wordpress.com)...

我最终使用了 <而是使用 href="https://wordpress.org/plugins/syntaxhighlighter/" rel="nofollow noreferrer">SyntaxHighlighter 插件。

使用该插件,首先,您的代码将在“预览更改”视图中显示为转义:发布后它将正确显示。 我认为发布后它将正确显示在“预览更改”中(不是 100%)。

With my Wordpress.org installation, I couldn't get the Accepted Answer here to work (not sure if that's only expected to work with Wordpress.com?)...

I ended up using the SyntaxHighlighter plugin instead.

With that plugin, at first, your code will appear escaped in 'Preview Changes' view: It will appear correctly then after publishing. I think thereafter publishing it will then appear correctly in 'Preview Changes' (not 100% about that).

葬シ愛 2024-07-13 11:50:28

如果您托管自己的 WordPress 博客而不是在 WP.com 上,您可以通过安装此插件来获得此功能,因为它与 WP.com 代码所依赖的插件相同。

http://wordpress.org/extend/plugins/google-syntax-highlighter/< /a>

If you are hosting your own wordpress blog opposed to on WP.com you can get this functionality by installing this plugin, since it is the same plugin that the WP.com code relies on.

http://wordpress.org/extend/plugins/google-syntax-highlighter/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文