HTML< code>中的颜色(语法突出显示)标签 [英] Color (syntax highlighting) within an HTML <code> tag

查看:450
本文介绍了HTML< code>中的颜色(语法突出显示)标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在如下代码段中...

In a code fragment like the following ...

class Foo
{
  internal Foo()
  {
    for (int i = 0; i < 42; ++i);
  }
}

...当它在我的浏览器中显示时,其各种关键字等都用颜色进行了编码.

... its various keywords and so on are color-coded when they're displayed in my browsers.

当我执行查看源代码"时,在HTML中看不到会实现这种颜色编码的任何特殊内容.

When I do "View source", I don't see anything special in the HTML that would implement this color-coding.

那么,该语法特定的颜色突出显示如何以及/或在哪里实现?例如,它是内置在浏览器中,还是由特定于站点的JavaScript在浏览器中编辑DOM来实现?

How and/or where is this syntax-specific color-highlighting implemented, then? For example is it built-in to the browsers, or is it implemented by site-specific JavaScript editing the DOM within the browsers?

我觉得这对Google来说是个难题.

I find this a difficult question to Google for.

推荐答案

Stackoverflow使用 Google的修饰 JS库,用于突出显示语法.在服务器交付HTML之后,它将在客户端执行.这就是为什么您在原始HTML源代码中看不到它的原因.如果您具有 FireBug 之类的浏览器插件,则可以在美化了魔术之后检查DOM.

Stackoverflow uses Google's prettify JS library for doing syntax highlighting. It executes on the client side after the HTML has been delivered by the server. That's why you don't see it in the raw HTML source. If you have a browser plugin such as FireBug, you'll be able to inspect the DOM after prettify has done its magic.

这篇关于HTML&lt; code&gt;中的颜色(语法突出显示)标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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