Markdown 代码块语言声明列表

文章目录

markdown 代码块如何指定语言?有哪些语言可以指定?

在撰写技术文档或分享代码时,使用 Markdown 格式可以极大地提升可读性与简洁性。然而,很多人在编写代码块时,常常会忘记如何正确声明代码的语言名称,这不仅影响格式,还会降低代码展示效果。本文整理了一份常见编程语言的 Markdown 代码块语言声明速查表,并附带常见文件扩展名,帮助你快速选择正确的语言标识。无论你是技术博主、开发者,还是学习者,这份清单都能让你在编写 Markdown 文档时事半功倍。

Markdown 代码块语言声明列表

语言名称 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

FAQ

1. 如何在 Markdown 中指定代码块的语言? 在 Markdown 中,代码块使用三个反引号 (```) 包围代码内容,并在第一行的反引号后加上所使用的编程语言。例如: ```python print(“Hello, World!”) ```

2. Markdown 代码块如何指定语言声明? 在编写代码块时,只需在代码块的开头声明语言名称,例如 ```python、```javascript 来指定 Python 或 JavaScript 代码,帮助实现语法高亮。

3. Markdown 代码块如何设置样式? Markdown 代码块样式主要依赖于渲染引擎。不同的平台可能对代码块进行不同的样式处理,如语法高亮、背景颜色、缩进等。你可以使用 CSS 自定义代码块样式。

4. Markdown 代码块支持哪些编程语言? Markdown 支持多种编程语言,包括但不限于:Python、JavaScript、HTML、CSS、C++、Shell 等。你可以在代码块开头声明你需要的语言,如 ```python。

5. Markdown 代码块如何显示行号? Markdown 原生不支持行号显示功能,但可以通过一些插件或自定义 CSS 来实现。比如使用一些渲染工具(如 highlight.js)来添加行号功能。

6. Markdown 代码块如何折叠? Markdown 本身不支持代码块折叠功能,但可以通过一些第三方插件或工具(如 Typora、Hexo 等)为代码块添加折叠功能。

7. Markdown 代码块缩进如何设置? Markdown 代码块缩进可以通过两个方式设置:使用 4 个空格或 1 个制表符(Tab 键)来缩进每一行代码。

8. Markdown 代码块如何高亮代码? Markdown 中的代码高亮功能依赖于语法解析器或渲染引擎。通过在代码块声明语言,如 ```python,就可以为该语言代码块进行语法高亮。

9. 如何在 Markdown 代码块中添加滚动条? 如果代码块内容较长,可通过 CSS 设置 overflow: auto; 来实现滚动条显示,使代码块在页面中不占用太多空间。

10. 如何在 Markdown 代码块中显示 Shell 终端效果? 在代码块中声明 ```shell 或 ```bash 来编写 Shell 脚本的代码,从而显示 Shell 终端效果。

11. Markdown 代码块如何自动换行? Markdown 默认不处理代码块的自动换行。可以通过自定义 CSS 样式来添加 white-space: pre-wrap; 属性,使代码块自动换行。

12. 如何在 Markdown 代码块中显示 C++ 代码? 在代码块的开头声明 ```cpp 或 ```c++ 来指明代码块中的语言是 C++,这样会对 C++ 代码进行适当的语法高亮。

13. Markdown 代码块如何换行? 要在 Markdown 代码块中换行,可以直接按 Enter 键或使用 \n 转义字符来表示换行。

14. Markdown 代码块是否支持中文符号? Markdown 代码块是支持中文符号的。不过需要注意的是,某些语言解析器可能对中文符号处理不当,因此测试结果可能因平台而异。

15. 如何在 Markdown 中创建一个可以显示终端输出的代码块? 使用 ```shell 或 ```bash 来创建一个代码块,该代码块将模拟显示终端的输出样式,适用于编写 Shell 脚本示例。

16. Markdown 代码块如何加粗? Markdown 中的加粗使用两个星号(**)或两个下划线(__)包围文本来实现。但在代码块中不支持加粗,所有内容将以纯文本形式显示。

17. Markdown 代码块如何打 * ? 如果要在代码块中显示星号(*),直接输入即可,因为代码块内的内容不会被解析成 Markdown 样式,所有内容都将按原样显示。

18. 如何在 Markdown 中显示代码块的代码块? 为了在 Markdown 代码块中显示代码块,可以使用转义字符或在代码块内嵌套反引号(`)。

19. 如何为 Markdown 代码块添加终端效果? 你可以通过在代码块声明 ```shell 或 ```bash 来模拟终端效果,显示 Shell 脚本的代码和输出。

20. Markdown 代码块支持自动语法高亮吗? 支持自动语法高亮,前提是你必须在代码块的开头正确声明所使用的编程语言,如 ```python 或 ```javascript。

小结

通过掌握 Markdown 代码块的语言声明格式,编写技术文档和代码示例将变得更加流畅和高效。这份速查表覆盖了多种主流编程语言及其常见文件扩展名,让你在使用 Markdown 编写文档时,轻松查找需要的代码块语言声明。如果你想提升自己的文档编写效率,建议将这份清单收藏起来,随时使用,助你更快速地处理代码格式问题。


小而赚副业指南

分享低成本靠谱赚钱副业,获取实用的搞钱指南,开启你的副业赚钱之旅吧!

全国大流量卡免费领

19元月租ㆍ超值优惠ㆍ长期套餐ㆍ免费包邮ㆍ官方正品