Markdown 代码块语言申明

语法

markdown中可以用```{code}```来展示代码片段。为了方便阅读,一般在首行注明代码语言类别,便于编辑或预览进行渲染。
例如

#include "stdio.h"
void main()
{
	printf("Hello world!");
}

一些编辑器插件,如Markdownlint,没有语言类别也会出现检查提示,因此有必要注明语言类别。
一下使代码语言名称及其申明代码,内容摘自 coding.net。常见的语言都可以用文件扩展名代替。

语言申明代码

语言名称 Markdown 语言声明 常见文件名
1C Enterprise 1c-enterprise *.bsl
4D 4d *.4dm
ABAP abap *.abap
ABNF abnf *.abnf
AGS Script ags-script, ags *.asc
AMPL ampl *.ampl
ANTLR antlr *.g4
API Blueprint api-blueprint *.apib
APL apl *.apl
ASN.1 asn.1 *.asn
ASP asp, aspx, aspx-vb *.asp
ATS ats, ats2 *.dats
ActionScript actionscript, actionscript3, as3 *.as
Ada ada, ada95, ada2005 *.adb
Adobe Font Metrics adobe-font-metrics, acfm, amfm *.afm
Agda agda *.agda
Alloy alloy *.als
Alpine Abuild alpine-abuild, abuild, apkbuild APKBUILD
Altium Designer altium-designer, altium *.OutJob
AngelScript angelscript *.as
Ant Build System ant-build-system ant.xml
ApacheConf apacheconf, aconf, apache *.apacheconf, .htaccess
Apex apex *.cls
Apollo Guidance Computer apollo-guidance-computer *.agc
AppleScript applescript, osascript *.applescript
Arc arc *.arc
AsciiDoc asciidoc *.asciidoc
AspectJ aspectj *.aj
Assembly assembly, asm, nasm *.asm
Asymptote asymptote *.asy
Augeas augeas *.aug
AutoHotkey autohotkey, ahk *.ahk
AutoIt autoit, au3, AutoIt3, AutoItScript *.au3
Awk awk *.awk
Ballerina ballerina *.bal
Batchfile batchfile, bat, batch, dosbatch, winbatch *.bat
Befunge befunge *.befunge
BibTeX bibtex *.bib
Bison bison *.bison
BitBake bitbake *.bb
Blade blade *.blade
BlitzBasic blitzbasic, b3d, blitz3d, blitzplus, bplus *.bb
BlitzMax blitzmax, bmax *.bmx
Bluespec bluespec *.bsv
Boo boo *.boo
Brainfuck brainfuck *.b
Brightscript brightscript *.brs
C c *.c
C# c#, csharp *.cs
C++ c++, cpp *.cpp
C-ObjDump c-objdump *.c-objdump
C2hs Haskell c2hs-haskell, c2hs *.chs
CLIPS clips *.clp
CMake cmake *.cmake, CMakeLists.txt
COBOL cobol *.cob
COLLADA collada *.dae
CSON cson *.cson
CSS css *.css
CSV csv *.csv
CWeb cweb *.w
Cabal Config cabal-config, Cabal *.cabal, cabal.config
Cap’n Proto cap’n-proto *.capnp
CartoCSS cartocss, Carto *.mss
Ceylon ceylon *.ceylon
Chapel chapel, chpl *.chpl
Charity charity *.ch
ChucK chuck *.ck
Cirru cirru *.cirru
Clarion clarion *.clw
Clean clean *.icl
Click click *.click
Clojure clojure *.clj, riemann.config
Closure Templates closure-templates, soy *.soy
Cloud Firestore Security Rules cloud-firestore-security-rules firestore.rules
CoNLL-U conll-u, CoNLL, CoNLL-X *.conllu
CodeQL codeql, ql *.ql
CoffeeScript coffeescript, coffee, coffee-script *.coffee, Cakefile
ColdFusion coldfusion, cfm, cfml *.cfm
ColdFusion CFC coldfusion-cfc, cfc *.cfc
Common Lisp common-lisp, lisp *.lisp
Common Workflow Language common-workflow-language, cwl *.cwl
Component Pascal component-pascal, delphi, objectpascal *.cp
Cool cool *.cl
Coq coq *.coq
Cpp-ObjDump cpp-objdump, c+±objdump *.cppobjdump
Creole creole *.creole
Crystal crystal *.cr
Csound csound, csound-orc *.orc
Csound Document csound-document, csound-csd *.csd
Csound Score csound-score, csound-sco *.sco
Cuda cuda *.cu
Cycript cycript *.cy
Cython cython, pyrex *.pyx
D d *.d
D-ObjDump d-objdump *.d-objdump
DIGITAL Command Language digital-command-language, dcl *.com
DM dm, byond *.dm
DNS Zone dns-zone *.zone
DTrace dtrace, dtrace-script *.d
Dafny dafny *.dfy
Darcs Patch darcs-patch, dpatch *.darcspatch
Dart dart *.dart
DataWeave dataweave *.dwl
Dhall dhall *.dhall
Diff diff, udiff *.diff
DirectX 3D File directx-3d-file *.x
Dockerfile dockerfile *.dockerfile, Dockerfile
Dogescript dogescript *.djs
Dylan dylan *.dylan
E e *.E
EBNF ebnf *.ebnf
ECL ecl *.ecl
ECLiPSe eclipse *.ecl
EJS ejs *.ejs
EML eml *.eml
EQ eq *.eq
Eagle eagle *.sch
Easybuild easybuild *.eb
Ecere Projects ecere-projects *.epj
EditorConfig editorconfig, editor-config .editorconfig
Edje Data Collection edje-data-collection *.edc
Eiffel eiffel *.e
Elixir elixir *.ex, mix.lock
Elm elm *.elm
Emacs Lisp emacs-lisp, elisp, emacs *.el, .abbrev_defs
EmberScript emberscript *.em
Erlang erlang *.erl, Emakefile
F# f#, fsharp *.fs
F* f*, fstar *.fst
FIGlet Font figlet-font, FIGfont *.flf
FLUX flux *.fx
Factor factor *.factor, .factor-boot-rc
Fancy fancy *.fy, Fakefile
Fantom fantom *.fan
Faust faust *.dsp
Filebench WML filebench-wml *.f
Filterscript filterscript *.fs
Formatted formatted *.for
Forth forth *.fth
Fortran fortran *.f
Fortran Free Form fortran-free-form *.f90
FreeMarker freemarker, ftl *.ftl
Frege frege *.fr
Futhark futhark *.fut
G-code g-code *.g
GAML gaml *.gaml
GAMS gams *.gms
GAP gap *.g
GCC Machine Description gcc-machine-description *.md
GDB gdb *.gdb
GDScript gdscript *.gd
GEDCOM gedcom *.ged
GLSL glsl *.glsl
GN gn *.gn, .gn
Game Maker Language game-maker-language *.gml
Genie genie *.gs
Genshi genshi, xml+genshi, xml+kid *.kid
Gentoo Ebuild gentoo-ebuild *.ebuild
Gentoo Eclass gentoo-eclass *.eclass
Gerber Image gerber-image, rs-274x *.gbr
Gettext Catalog gettext-catalog, pot *.po
Gherkin gherkin, cucumber *.feature
Git Attributes git-attributes, gitattributes .gitattributes
Git Config git-config, gitconfig, gitmodules *.gitconfig, .gitconfig
Glyph glyph *.glf
Glyph Bitmap Distribution Format glyph-bitmap-distribution-format *.bdf
Gnuplot gnuplot *.gp
Go go, golang *.go
Golo golo *.golo
Gosu gosu *.gs
Grace grace *.grace
Gradle gradle *.gradle
Grammatical Framework grammatical-framework, gf *.gf
Graph Modeling Language graph-modeling-language *.gml
GraphQL graphql *.graphql
Graphviz (DOT) dot *.dot
Groovy groovy *.groovy, Jenkinsfile
Groovy Server Pages groovy-server-pages, gsp *.gsp
HAProxy haproxy *.cfg, haproxy.cfg
HCL hcl, terraform *.hcl
HLSL hlsl *.hlsl
HTML html, xhtml *.html
HTML+Django html+django, django, html+jinja, htmldjango *.jinja
HTML+ECR html+ecr, ecr *.ecr
HTML+EEX html+eex, eex *.eex
HTML+ERB html+erb, erb *.erb
HTML+PHP html+php *.phtml
HTML+Razor html+razor, razor *.cshtml
HTTP http *.http
HXML hxml *.hxml
Hack hack *.hack
Haml haml *.haml
Handlebars handlebars, hbs, htmlbars *.handlebars
Harbour harbour *.hb
Haskell haskell *.hs
Haxe haxe *.hx
HiveQL hiveql *.q
HolyC holyc *.hc
Hy hy, hylang *.hy
HyPhy hyphy *.bf
IDL idl *.pro
IGOR Pro igor-pro, igor, igorpro *.ipf
INI ini, dosini *.ini, buildozer.spec
IRC log irc-log, irc *.irclog
Idris idris *.idr
Ignore List ignore-list, ignore, gitignore, git-ignore *.gitignore, .atomignore
Inform 7 inform-7, i7, inform7 *.ni
Inno Setup inno-setup *.iss
Io io *.io
Ioke ioke *.ik
Isabelle isabelle *.thy
Isabelle ROOT isabelle-root ROOT
J j *.ijs
JFlex jflex *.flex
JSON json *.json, .arcconfig
JSON with Comments json-with-comments, jsonc *.jsonc, .babelrc
JSON5 json5 *.json5
JSONLD jsonld *.jsonld
JSONiq jsoniq *.jq
JSX jsx *.jsx
Jasmin jasmin *.j
Java java *.java
Java Properties java-properties *.properties
Java Server Pages java-server-pages, jsp *.jsp
JavaScript javascript, js, node *.js, Jakefile
JavaScript+ERB javascript+erb *.js.erb
Jison jison *.jison
Jison Lex jison-lex *.jisonlex
Jolie jolie *.ol
Jsonnet jsonnet *.jsonnet
Julia julia *.jl
Jupyter Notebook jupyter-notebook *.ipynb, Notebook
KRL krl *.krl
KiCad Layout kicad-layout, pcbnew *.kicad_pcb, fp-lib-table
KiCad Legacy Layout kicad-legacy-layout *.brd
KiCad Schematic kicad-schematic *.sch
Kit kit *.kit
Kotlin kotlin *.kt
LFE lfe *.lfe
LLVM llvm *.ll
LOLCODE lolcode *.lol
LSL lsl *.lsl
LTspice Symbol ltspice-symbol *.asy
LabVIEW labview *.lvproj
Lasso lasso, lassoscript *.lasso
Latte latte *.latte
Lean lean *.lean
Less less *.less
Lex lex, flex *.l
LilyPond lilypond *.ly
Limbo limbo *.b
Linker Script linker-script *.ld, ld.script
Linux Kernel Module linux-kernel-module *.mod
Liquid liquid *.liquid
Literate Agda literate-agda *.lagda
Literate CoffeeScript literate-coffeescript, litcoffee *.litcoffee
Literate Haskell literate-haskell, lhaskell, lhs *.lhs
LiveScript livescript, live-script, ls *.ls, Slakefile
Logos logos *.xm
Logtalk logtalk *.lgt
LookML lookml *.lookml
LoomScript loomscript *.ls
Lua lua *.lua, .luacheckrc
M m, mumps *.mumps
M4 m4 *.m4
M4Sugar m4sugar, autoconf *.m4, configure.ac
MATLAB matlab, octave *.matlab
MAXScript maxscript *.ms
MLIR mlir *.mlir
MQL4 mql4 *.mq4
MQL5 mql5 *.mq5
MTML mtml *.mtml
MUF muf *.muf
Macaulay2 macaulay2, m2 *.m2
Makefile makefile, bsdmake, make, mf *.mak, BSDmakefile
Mako mako *.mako
Markdown markdown, pandoc *.md, contents.lr
Marko marko, markojs *.marko
Mask mask *.mask
Mathematica mathematica, mma *.mathematica
Maven POM maven-pom pom.xml
Max max, max/msp, maxmsp *.maxpat
MediaWiki mediawiki *.mediawiki
Mercury mercury *.m
Meson meson meson.build
Metal metal *.metal
Microsoft Developer Studio Project microsoft-developer-studio-project *.dsp
MiniD minid *.minid
Mirah mirah *.druby
Modelica modelica *.mo
Modula-2 modula-2 *.mod
Modula-3 modula-3 *.i3
Module Management System module-management-system *.mms, descrip.mmk
Monkey monkey *.monkey
Moocode moocode *.moo
MoonScript moonscript *.moon
Motorola 68K Assembly motorola-68k-assembly, m68k *.asm
Muse muse, amusewiki *.muse
Myghty myghty *.myt
NASL nasl *.nasl
NCL ncl *.ncl
NEON neon, ne-on *.neon
NL nl *.nl
NPM Config npm-config, npmrc .npmrc
NSIS nsis *.nsi
Nearley nearley *.ne
Nemerle nemerle *.n
NetLinx netlinx *.axs
NetLinx+ERB netlinx+erb *.axs.erb
NetLogo netlogo *.nlogo
NewLisp newlisp *.nl
Nextflow nextflow *.nf, nextflow.config
Nginx nginx *.nginxconf, nginx.conf
Nim nim *.nim, nim.cfg
Ninja ninja *.ninja
Nit nit *.nit
Nix nix, nixos *.nix
Nu nu, nush *.nu, Nukefile
NumPy numpy *.numpy
OCaml ocaml *.ml
ObjDump objdump *.objdump
Object Data Instance Notation object-data-instance-notation *.odin
ObjectScript objectscript *.cls
Objective-C objective-c, obj-c, objc, objectivec *.m
Objective-C++ objective-c++, obj-c++, objc++, objectivec++ *.mm
Objective-J objective-j, obj-j, objectivej, objj *.j
Odin odin, odinlang, odin-lang *.odin
Omgrofl omgrofl *.omgrofl
Opa opa *.opa
Opal opal *.opal
Open Policy Agent open-policy-agent *.rego
OpenCL opencl *.cl
OpenEdge ABL openedge-abl, progress, openedge, abl *.p
OpenQASM openqasm *.qasm
OpenRC runscript openrc-runscript, openrc
OpenSCAD openscad *.scad
OpenStep Property List openstep-property-list *.plist
OpenType Feature File opentype-feature-file, AFDKO *.fea
Org org *.org
Ox ox *.ox
Oxygene oxygene *.oxygene
Oz oz *.oz
P4 p4 *.p4
PHP php, inc *.php, .php
PLSQL plsql *.pls
PLpgSQL plpgsql *.pgsql
POV-Ray SDL pov-ray-sdl, pov-ray, povray *.pov
Pan pan *.pan
Papyrus papyrus *.psc
Parrot parrot *.parrot
Parrot Assembly parrot-assembly, pasm *.pasm
Parrot Internal Representation parrot-internal-representation, pir *.pir
Pascal pascal *.pas
Pawn pawn *.pwn
Pep8 pep8 *.pep
Perl perl, cperl *.pl, Makefile.PL
Pic pic *.pic
Pickle pickle *.pkl
PicoLisp picolisp *.l
PigLatin piglatin *.pig
Pike pike *.pike
PlantUML plantuml *.puml
Pod pod *.pod
Pod 6 pod-6 *.pod
PogoScript pogoscript *.pogo
Pony pony *.pony
PostCSS postcss *.pcss
PostScript postscript, postscr *.ps
PowerBuilder powerbuilder *.pbt
PowerShell powershell, posh, pwsh *.ps1
Prisma prisma *.prisma
Processing processing *.pde
Proguard proguard *.pro
Prolog prolog *.pl
Propeller Spin propeller-spin *.spin
Protocol Buffer protocol-buffer, protobuf *.proto
Public Key public-key *.asc
Pug pug *.jade
Puppet puppet *.pp, Modulefile
Pure Data pure-data *.pd
PureBasic purebasic *.pb
PureScript purescript *.purs
Python python, python3, rusthon *.py, .gclient
Python console python-console, pycon
Python traceback python-traceback *.pytb
QML qml *.qml
QMake qmake *.pro
Quake quake m3makefile
R r, R, Rscript, splus *.r, .Rprofile
RAML raml *.raml
RDoc rdoc *.rdoc
REALbasic realbasic *.rbbas
REXX rexx, arexx *.rexx
RHTML rhtml, html+ruby *.rhtml
RMarkdown rmarkdown *.rmd
RPC rpc, rpcgen, oncrpc, xdr *.x
RPM Spec rpm-spec, specfile *.spec
RUNOFF runoff *.rnh
Racket racket *.rkt
Ragel ragel, ragel-rb, ragel-ruby *.rl
Raku raku, perl6, perl-6 *.6pl
Rascal rascal *.rsc
Raw token data raw-token-data, raw *.raw
Readline Config readline-config, inputrc, readline .inputrc
Reason reason *.re
Rebol rebol *.reb
Red red, red/system *.red
Redcode redcode *.cw
Regular Expression regular-expression, regexp, regex *.regexp
Ren’Py ren’py, renpy *.rpy
RenderScript renderscript *.rs
Rich Text Format rich-text-format *.rtf
Ring ring *.ring
Riot riot *.riot
RobotFramework robotframework *.robot
Roff roff, groff, mdoc, nroff, troff *.roff, eqnrc
Roff Manpage roff-manpage *.1
Rouge rouge *.rg
Ruby ruby, jruby, macruby, rake, rb, rbx *.rb, .irbrc
Rust rust *.rs
SAS sas *.sas
SCSS scss *.scss
SMT smt *.smt2
SPARQL sparql *.sparql
SQF sqf *.sqf
SQL sql *.sql
SQLPL sqlpl *.sql
SRecode Template srecode-template *.srt
SSH Config ssh-config ssh-config
STON ston *.ston
SVG svg *.svg
SWIG swig *.i
Sage sage *.sage
SaltStack saltstack, saltstate, salt *.sls
Sass sass *.sass
Scala scala *.scala
Scaml scaml *.scaml
Scheme scheme *.scm
Scilab scilab *.sci
Self self *.self
ShaderLab shaderlab *.shader
Shell shell, sh, shell-script, bash, zsh *.sh, .bash_aliases
ShellSession shellsession, console *.sh-session
Shen shen *.shen
Sieve sieve *.sieve
Slash slash *.sl
Slice slice *.ice
Slim slim *.slim
SmPL smpl, coccinelle *.cocci
Smali smali *.smali
Smalltalk smalltalk, squeak *.st
Smarty smarty *.tpl
Solidity solidity
SourcePawn sourcepawn, sourcemod *.sp
Spline Font Database spline-font-database *.sfd
Squirrel squirrel *.nut
Stan stan *.stan
Standard ML standard-ml, sml *.ML
Starlark starlark, bazel, bzl *.bzl, BUCK
Stata stata *.do
Stylus stylus *.styl
SubRip Text subrip-text *.srt
SugarSS sugarss *.sss
SuperCollider supercollider *.sc
Svelte svelte *.svelte
Swift swift *.swift
SystemVerilog systemverilog *.sv
TI Program ti-program *.8xp
TLA tla *.tla
TOML toml *.toml, Cargo.lock
TSQL tsql *.sql
TSX tsx *.tsx
TXL txl *.txl
Tcl tcl *.tcl, owh
Tcsh tcsh *.tcsh
TeX tex, latex *.tex
Tea tea *.tea
Terra terra *.t
Texinfo texinfo *.texinfo
Text text, fundamental *.txt, COPYING
Textile textile *.textile
Thrift thrift *.thrift
Turing turing *.t
Turtle turtle *.ttl
Twig twig *.twig
Type Language type-language, tl *.tl
TypeScript typescript, ts *.ts
Unified Parallel C unified-parallel-c *.upc
Unity3D Asset unity3d-asset *.anim
Unix Assembly unix-assembly *.s
Uno uno *.uno
UnrealScript unrealscript *.uc
UrWeb urweb, Ur/Web, Ur *.ur
V v, vlang *.v
VBA vba, vb6 *.bas
VBScript vbscript *.vbs
VCL vcl *.vcl
VHDL vhdl *.vhdl
Vala vala *.vala
Verilog verilog *.v
Vim Snippet vim-snippet, SnipMate, UltiSnip, NeoSnippet *.snip
Vim script vim-script, vim, viml, nvim *.vim, .gvimrc
Visual Basic .NET vbnet, vb.net *.vb
Volt volt *.volt
Vue vue *.vue
Wavefront Material wavefront-material *.mtl
Wavefront Object wavefront-object *.obj
Web Ontology Language web-ontology-language *.owl
WebAssembly webassembly, wast, wasm *.wast
WebIDL webidl *.webidl
WebVTT webvtt *.vtt
Wget Config wget-config, wgetrc .wgetrc
Windows Registry Entries windows-registry-entries *.reg
Wollok wollok *.wlk
World of Warcraft Addon Data world-of-warcraft-addon-data *.toc
X BitMap x-bitmap, xbm *.xbm
X Font Directory Index x-font-directory-index encodings.dir
X PixMap x-pixmap, xpm *.xpm
X10 x10, xten *.x10
XC xc *.xc
XCompose xcompose .XCompose
XML xml, rss, xsd, wsdl *.xml, .classpath
XML Property List xml-property-list *.plist
XPages xpages *.xsp-config
XProc xproc *.xpl
XQuery xquery *.xquery
XS xs *.xs
XSLT xslt, xsl *.xslt
Xojo xojo *.xojo_code
Xtend xtend *.xtend
YAML yaml, yml *.yml, .clang-format
YANG yang *.yang
YARA yara *.yar
YASnippet yasnippet, snippet, yas *.yasnippet
Yacc yacc *.y
ZAP zap *.zap
ZIL zil *.zil
Zeek zeek, bro *.zeek
ZenScript zenscript *.zs
Zephir zephir *.zep
Zig zig *.zig
Zimpl zimpl *.zimpl
cURL Config curl-config, curlrc .curlrc
desktop desktop *.desktop
dircolors dircolors *.dircolors, .dir_colors
eC ec *.ec
edn edn *.edn
fish fish *.fish
mIRC Script mirc-script *.mrc
mcfunction mcfunction *.mcfunction
mupad mupad *.mu
nanorc nanorc *.nanorc, .nanorc
nesC nesc *.nc
ooc ooc *.ooc
q q *.q
reStructuredText restructuredtext, rst *.rst
sed sed *.sed
wdl wdl *.wdl
wisp wisp *.wisp
xBase xbase, advpl, clipper, foxpro *.prg