# Highlight.js
Highlight.js highlights syntax in code examples on blogs, forums and,
in fact, on any web page. It's very easy to use because it works
automatically: finds blocks of code, detects a language, highlights it.
Autodetection can be fine tuned when it fails by itself (see "Heuristics").
## Basic usage
Link the library and a stylesheet from your page and hook highlighting to
the page load event:
```html
<link rel="stylesheet" href="styles/default.css">
<script src="highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
```
This will highlight all code on the page marked up as `<pre><code> .. </code></pre>`.
If you use different markup or need to apply highlighting dynamically, read
"Custom initialization" below.
- You can download your own customized version of "highlight.pack.js" or
use the hosted one as described on the download page:
<http://highlightjs.org/download/>
- Style themes are available in the download package or as hosted files.
To create a custom style for your site see the class reference in the file
[CSS classes reference][cr] from the downloaded package.
[cr]: http://highlightjs.readthedocs.org/en/latest/css-classes-reference.html
## node.js
Highlight.js can be used under node.js. The package with all supported languages is
installable from NPM:
npm install highlight.js
Alternatively, you can build it from the source with only languages you need:
python3 tools/build.py -tnode lang1 lang2 ..
Using the library:
```javascript
var hljs = require('highlight.js');
// If you know the language
hljs.highlight(lang, code).value;
// Automatic language detection
hljs.highlightAuto(code).value;
```
## AMD
Highlight.js can be used with an AMD loader. You will need to build it from
source in order to do so:
```bash
$ python3 tools/build.py -tamd lang1 lang2 ..
```
Which will generate a `build/highlight.pack.js` which will load as an AMD
module with support for the built languages and can be used like so:
```javascript
require(["highlight.js/build/highlight.pack"], function(hljs){
// If you know the language
hljs.highlight(lang, code).value;
// Automatic language detection
hljs.highlightAuto(code).value;
});
```
## Tab replacement
You can replace TAB ('\x09') characters used for indentation in your code
with some fixed number of spaces or with a `<span>` to give them special
styling:
```html
<script type="text/javascript">
hljs.configure({tabReplace: ' '}); // 4 spaces
// ... or
hljs.configure({tabReplace: '<span class="indent">\t</span>'});
hljs.initHighlightingOnLoad();
</script>
```
## Custom initialization
If you use different markup for code blocks you can initialize them manually
with `highlightBlock(code)` function. It takes a DOM element containing the
code to highlight and optionally a string with which to replace TAB
characters.
Initialization using, for example, jQuery might look like this:
```javascript
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
```
You can use `highlightBlock` to highlight blocks dynamically inserted into
the page. Just make sure you don't do it twice for already highlighted
blocks.
If your code container relies on `<br>` tags instead of line breaks (i.e. if
it's not `<pre>`) set the `useBR` option to `true`:
```javascript
hljs.configure({useBR: true});
$('div.code').each(function(i, e) {hljs.highlightBlock(e)});
```
## Heuristics
Autodetection of a code's language is done using a simple heuristic:
the program tries to highlight a fragment with all available languages and
counts all syntactic structures that it finds along the way. The language
with greatest count wins.
This means that in short fragments the probability of an error is high
(and it really happens sometimes). In this cases you can set the fragment's
language explicitly by assigning a class to the `<code>` element:
```html
<pre><code class="html">...</code></pre>
```
You can use class names recommended in HTML5: "language-html",
"language-php". Classes also can be assigned to the `<pre>` element.
To disable highlighting of a fragment altogether use "no-highlight" class:
```html
<pre><code class="no-highlight">...</code></pre>
```
## Export
File export.html contains a little program that allows you to paste in a code
snippet and then copy and paste the resulting HTML code generated by the
highlighter. This is useful in situations when you can't use the script itself
on a site.
## Meta
- Version: 8.0
- URL: http://222.178.203.72:19005/whst/63/_ghfgkhfgsirznqf//
For the license terms see LICENSE files.
For authors and contributors see AUTHORS.en.txt file.
没有合适的资源?快使用搜索试试~ 我知道了~
springboot & shiro 商城后台管理系统.zip
共784个文件
png:220个
js:154个
java:108个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 49 浏览量
2024-01-04
15:07:45
上传
评论
收藏 6.03MB ZIP 举报
温馨提示
Java SpringBoot实现在线商城项目,实现了电商商城、淘淘商城、新蜂商城、小程序商城、电商书城、淘宝天猫商城、秒杀系统、黑马乐优商城、塔可商城、仿小米商城、微信商城,使用了SpringBoot、Redis、ElasticSearch、JWT、Vue、JavaScript、Dubbo、、Docker、RESTful API、BootStrap、微服务、高并发、Kafka、MyBatis、uni-app、Layui、MySQL、Kubernetes等技术,适用于大作业、课程设计、毕业设计、商用。
资源推荐
资源详情
资源评论
收起资源包目录
springboot & shiro 商城后台管理系统.zip (784个子文件)
mvnw.cmd 6KB
layui.css 71KB
notice.css 59KB
editor_ie8.css 41KB
editor_iequirks.css 41KB
editor_ie.css 40KB
editor_gecko.css 39KB
editor.css 39KB
admin.css 30KB
formSelects-v4.css 18KB
dialog_ie8.css 15KB
dialog_iequirks.css 14KB
dialog_ie.css 14KB
layer.css 14KB
dialog.css 13KB
introJs.css 12KB
theme-white.css 11KB
theme-purple-white.css 10KB
theme-red-white.css 10KB
layui.mobile.css 10KB
apexcharts.min.css 9KB
dropdown.css 8KB
laydate.css 7KB
metroStyle.css 6KB
zTreeStyle.css 6KB
theme-pink.css 5KB
Cropper.css 5KB
theme-red.css 5KB
theme-cyan.css 5KB
theme-purple.css 5KB
theme-yellow.css 5KB
theme-green.css 5KB
theme-blue.css 5KB
cascader.css 5KB
dtreefont.css 4KB
contents.css 3KB
eleTree.css 3KB
city-picker.css 3KB
dtree.css 3KB
login.css 3KB
default.css 3KB
railscasts.css 2KB
tagsInput.css 2KB
arta.css 2KB
monokai_sublime.css 2KB
obsidian.css 2KB
xcode.css 2KB
sunburst.css 2KB
googlecode.css 2KB
monokai.css 2KB
school_book.css 2KB
magula.css 2KB
far.css 2KB
zenburn.css 2KB
theme-black.css 2KB
brown_paper.css 2KB
docco.css 2KB
atelier-lakeside.light.css 2KB
atelier-lakeside.dark.css 2KB
atelier-seaside.light.css 2KB
dark.css 2KB
atelier-seaside.dark.css 2KB
atelier-forest.light.css 2KB
atelier-forest.dark.css 2KB
atelier-heath.light.css 2KB
idea.css 2KB
atelier-heath.dark.css 2KB
atelier-dune.light.css 2KB
atelier-dune.dark.css 2KB
github.css 2KB
Split.css 2KB
pojoaque.css 2KB
tomorrow-night-blue.css 2KB
solarized_dark.css 2KB
solarized_light.css 2KB
tomorrow-night.css 2KB
rainbow.css 2KB
foundation.css 2KB
vs.css 2KB
tomorrow-night-eighties.css 2KB
tomorrow-night-bright.css 1KB
templates.css 1KB
paraiso.light.css 1KB
paraiso.dark.css 1KB
copyformatting.css 1KB
ir_black.css 1KB
tomorrow.css 1KB
step.css 1KB
tableselection.css 1KB
code.css 1KB
custom-nav.css 1024B
mono-blue.css 899B
ascetic.css 803B
colordialog.css 772B
error-page.css 572B
main.css 498B
treetable.css 294B
treeSelect.css 0B
ip2region.db 2.6MB
iconfont.eot 41KB
共 784 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
东哥说AI
- 粉丝: 5699
- 资源: 165
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 污水监控 环境监测 云平台
- JAVA实现捡金币闯关小游戏(附源码).zip
- FPGA滤波器设计教程,教你快速设计FIR滤波器并利用IP Core实现 清单: 教程文档一份,示例代码工程一份 文档性质产品
- 视频录制和实时流OBS-Studio-30.2.3-Windows
- 农业经济学名词解释.doc
- 汽车百年发展史.doc
- 浅析幼儿园利用乡土教育资源开发园本课程内容的尝试.doc
- 热电厂锅炉试题.doc
- 三年级数学[下册]脱式计算题300题.doc
- 生物圈是最大的生态系统教学案.doc
- 上学期期末考试七年级语文试卷.doc
- 摄影基础试题-学生版[多选].doc
- 税收不安全因素管理指标+解释.doc
- 水利工程概论复习试题及答案.doc
- 统编版二年级上册语文教学计划.doc
- 污染控制微生物学试题.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功