Files
mes-ui-d2/docs/zh/sys-components/highlight.md

300 lines
3.6 KiB
Markdown
Raw Normal View History

# d2-highlight
代码高亮显示组件
## 参数
| 参数名 | 介绍 | 必选 | 值类型 | 可选值 | 默认值 |
| --- | --- | --- | --- | --- | --- |
| code | 代码字符串 | 非 | String | | |
| format-html | 是否格式化 HTML | 非 | Boolean | | false |
| lang | 首选语言 | 非 | String | | |
::: tip
format 建议只在内容为 HTML 的时候打开,如果内容不是 HTML设置为 true 会有负面效果
:::
## 示例
``` vue
<d2-highlight code="alert('Hello')"/>
```
::: tip
本框架只是提供代码高亮的简单实现,如需实现更高级的设置请修改组件代码
:::
## 语言
如果不指定语言,默认会依次尝试以下语言:
1. html
2. javascript
3. json
4. css
5. scss
6. less
如果指定语言,将会首先尝试根据指定的语言解析。全部支持的语言:
* 1c
* abnf
* accesslog
* actionscript
* ada
* apache
* applescript
* cpp
* arduino
* armasm
* xml
* asciidoc
* aspectj
* autohotkey
* autoit
* avrasm
* awk
* axapta
* bash
* basic
* bnf
* brainfuck
* cal
* capnproto
* ceylon
* clean
* clojure
* clojure-repl
* cmake
* coffeescript
* coq
* cos
* crmsh
* crystal
* cs
* csp
* css
* d
* markdown
* dart
* delphi
* diff
* django
* dns
* dockerfile
* dos
* dsconfig
* dts
* dust
* ebnf
* elixir
* elm
* ruby
* erb
* erlang-repl
* erlang
* excel
* fix
* flix
* fortran
* fsharp
* gams
* gauss
* gcode
* gherkin
* glsl
* go
* golo
* gradle
* groovy
* haml
* handlebars
* haskell
* haxe
* hsp
* htmlbars
* http
* hy
* inform7
* ini
* irpf90
* java
* javascript
* jboss-cli
* json
* julia
* julia-repl
* kotlin
* lasso
* ldif
* leaf
* less
* lisp
* livecodeserver
* livescript
* llvm
* lsl
* lua
* makefile
* mathematica
* matlab
* maxima
* mel
* mercury
* mipsasm
* mizar
* perl
* mojolicious
* monkey
* moonscript
* n1ql
* nginx
* nimrod
* nix
* nsis
* objectivec
* ocaml
* openscad
* oxygene
* parser3
* pf
* php
* pony
* powershell
* processing
* profile
* prolog
* protobuf
* puppet
* purebasic
* python
* q
* qml
* r
* rib
* roboconf
* routeros
* rsl
* ruleslanguage
* rust
* scala
* scheme
* scilab
* scss
* shell
* smali
* smalltalk
* sml
* sqf
* sql
* stan
* stata
* step21
* stylus
* subunit
* swift
* taggerscript
* yaml
* tap
* tcl
* tex
* thrift
* tp
* twig
* typescript
* vala
* vbnet
* vbscript
* vbscript-html
* verilog
* vhdl
* vim
* x86asm
* xl
* xquery
* zephir
## 主题
* agate
* androidstudio
* arduino-light
* arta
* ascetic
* atelier-cave-dark
* atelier-cave-light
* atelier-dune-dark
* atelier-dune-light
* atelier-estuary-dark
* atelier-estuary-light
* atelier-forest-dark
* atelier-forest-light
* atelier-heath-dark
* atelier-heath-light
* atelier-lakeside-dark
* atelier-lakeside-light
* atelier-plateau-dark
* atelier-plateau-light
* atelier-savanna-dark
* atelier-savanna-light
* atelier-seaside-dark
* atelier-seaside-light
* atelier-sulphurpool-dark
* atelier-sulphurpool-light
* atom-one-dark
* atom-one-light
* brown-paper
* brown-papersq.png
* codepen-embed
* color-brewer
* darcula
* dark
* darkula
* default
* docco
* dracula
* far
* foundation
* github-gist
* github
* googlecode
* grayscale
* gruvbox-dark
* gruvbox-light
* hopscotch
* hybrid
* idea
* ir-black
* kimbie.dark
* kimbie.light
* magula
* mono-blue
* monokai-sublime
* monokai
* obsidian
* ocean
* paraiso-dark
* paraiso-light
* pojoaque
* pojoaque.jpg
* purebasic
* qtcreator_dark
* qtcreator_light
* railscasts
* rainbow
* routeros
* school-book
* school-book.png
* solarized-dark
* solarized-light
* sunburst
* tomorrow-night-blue
* tomorrow-night-bright
* tomorrow-night-eighties
* tomorrow-night
* tomorrow
* vs
* vs2015
* xcode
* xt256
* zenburn