Markdown - cheatsheet
Markdown is an easy way to write formatted and structured content in a simple text editor. It converts easily to various formats, such as HTML and is often used to publish github project documentation in form of a README.md. Here is my personal cheatsheet.
First appearance
Markdown has no official RFC or specification and is just a collection of best practises, that may differ depending on the platform / parser that is used. Although there is no official specification, a link to the original source may help you understanding the idea before going into detail.
Headers
# H1
## H2
### H3
#### H4
##### H5
###### H6
Emphasis
*italic*
**bold**
***bold italic***
~~strikethrough~~
<!--- this might not work everywhere -->
==highlight yellow==
Links
[An embedded link](https://www.pilabor.com "Link title")
[A link referenced by number][1]
[1]: https://www.pilabor.com
[A link referenced by name]
[A link referenced by name]: https://www.pilabor.com
Images

![referenced alt text][my-image]
[my-image]: https://picsum.photos/200 "referenced title text"
Blockquotes
> This is one multiline
> blockquote
> this is a blockquote
>> this is a nested blockquote
Footnotes
This is a footnote[^1], that might not work everywhere
[^1]: Footnotes can be used to give details at the bottom of a page
Escaping
\*literal asterisks - not italic\*
Escaping backticks might work different: `` or \`
List of chars, that may need to be escaped (depending on context): \, `, *, _, {, }, [, ], (, ),#, +, -, ., !
Lists
<!--- unordered lists -->
- unordered list item 1
- sub item
- unordered list item 2
<!--- ordered lists -->
1. ordered list item
- unordered sub item
2. ordered list item
<!--- split lists (different lists following up each other) -->
- list one - item 1
^
- list two - item A
^
- list three - item _i_
<!--- task lists (with checkboxes) - this might not work everywhere -->
- [x] completed task
- [ ] open task
- [x] another completed task
Horizontal rules
Horizontal rules can be done like this:
---
Raw HTML
If everything else fails to work, you can still use raw HTML most of the time, although this might be escaped by some renderers to provide better security:
# We need to do something very complex here
an acronym with multiple color letters:
<span style="color:red;">R</span>
<span style="color:green;">G</span>
<span style="color:blue;">B</span>
Details / spoilers
<!--- github variant -->
<details><summary>Show more...</summary>
here are some details
</details>
<!--- stackoverflow variant -->
>! A multi-line spoiler
>! contains ! multiple times
Tables
| First Column (align left) | Second Column (center) | Third Column (align right) |
| ------------------------- |:----------------------:| --------------------------:|
|^---no colon align left---^|^---two colons center--^|^-right colon aligns right-^|
| Second line, col 1 | Second line, col 2 | Second line, col 3 |
Code and Syntax
`inline code`
```
// code block
```
```php
// php highlighted code block
// available highlighters depend on your environment
// for a list of them, see bottom of the page
```
<!--- markdown to show how to use code in markdown (INCEPTION - more backticks nest more layers)-->
# Here is how to highlight code
````markdown
My code looks like this
```php
<?php
echo "hello world!";
```
````
Syntax highlighting
Markdown renderers often ship with different features for syntax highlighting. The list below is searchable a reference for hugo , the static site generator, which might work for other renderers.
Highlighter (e.g. ```markdown) | Language |
|---|---|
markdown | Markdown |
ABAP, abap | ABAP |
abnf | ABNF |
actionscript, as | ActionScript |
actionscript3, as, as3 | ActionScript 3 |
ada, ada2005, ada95, adb, ads | Ada |
al, dal | AL |
ng2 | Angular2 |
antlr | ANTLR |
aconf, apache, apacheconf, conf, htaccess | ApacheConf |
apl | APL |
applescript | AppleScript |
arduino, ino | Arduino |
awk, gawk, mawk, nawk | Awk |
bal, ballerina | Ballerina |
*, bsdmake, mak, make, makefile, mf, mk | Base Makefile |
bash, bash_*, bashrc, ebuild, eclass, env, exheres-0, exlib, ksh, sh, shell, zsh, zshrc | Bash |
bat, batch, cmd, dosbatch, winbatch | Batchfile |
bib, bibtex | BibTeX |
b3d, bb, blitzbasic, bplus, decls | BlitzBasic |
bnf | BNF |
b, bf, brainfuck | Brainfuck |
c, h, idc, x[bp]m | C |
c#, cs, csharp | C# |
C, CPP, H, c++, cc, cp, cpp, cxx, h++, hh, hpp, hxx | C++ |
caddy, caddyfile | Caddyfile |
caddy-d, caddyfile-d, caddyfile-directives | Caddyfile Directives |
capnp | Cap’n Proto |
cassandra, cql | Cassandra CQL |
ceylon | Ceylon |
cf, cf3, cfengine3 | CFEngine3 |
cfs | cfstatement |
chai, chaiscript | ChaiScript |
cheetah, spitfire, spt, tmpl | Cheetah |
clj, clojure | Clojure |
cmake, txt | CMake |
COB, CPY, cob, cobol, cpy | COBOL |
coffee, coffee-script, coffeescript | CoffeeScript |
cl, common-lisp, lisp | Common Lisp |
coq, v | Coq |
cr, crystal | Crystal |
css | CSS |
cython, pxd, pxi, pyrex, pyx | Cython |
d, di | D |
dart | Dart |
diff, patch, udiff | Diff |
django, jinja | Django/Jinja |
docker, dockerfile | Docker |
dtd | DTD |
dyl, dylan, intr | Dylan |
ebnf | EBNF |
elixir, ex, exs | Elixir |
elm | Elm |
el, elisp, emacs, emacs-lisp | EmacsLisp |
erl, erlang, es, escript, hrl | Erlang |
factor | Factor |
fish, fishshell, load | Fish |
forth, frt, fs, fth | Forth |
F03, F90, f03, f90, fortran | Fortran |
F, f, fortranfixed | FortranFixed |
fs, fsharp, fsi | FSharp |
S, asm, gas, s | GAS |
gd, gdscript | GDScript |
genshi, kid, xml+genshi, xml+kid | Genshi |
html+genshi, html+kid | Genshi HTML |
genshitext | Genshi Text |
Cucumber, FEATURE, Gherkin, cucumber, feature, gherkin | Gherkin |
frag, geo, glsl, vert | GLSL |
gnuplot, plot, plt | Gnuplot |
go, golang | Go |
go-html-template | Go HTML Template |
go-text-template | Go Text Template |
gql, graphql, graphqls | GraphQL |
1p, 3pm, [1-9], groff, man, nroff | Groff |
gradle, groovy | Groovy |
handlebars, hbs | Handlebars |
haskell, hs | Haskell |
haxe, hx, hxsl | Haxe |
hcl | HCL |
hexdump | Hexdump |
hlb | HLB |
htm, html, xhtml, xslt | HTML |
http | HTTP |
hy, hylang | Hy |
idr, idris | Idris |
igor, igorpro, ipf | Igor |
cfg, dosini, editorconfig, gitconfig, inf, ini | INI |
io | Io |
ijs, j | J |
java | Java |
javascript, js, jsm, mjs | JavaScript |
json | JSON |
jl, julia | Julia |
jungle | Jungle |
kotlin, kt | Kotlin |
lighttpd, lighty | Lighttpd configuration file |
ll, llvm | LLVM |
lua, wlua | Lua |
mako, mao | Mako |
markdown, md, mkd | markdown |
m, mason, mc, mhtml, mi | Mason |
cdf, ma, mathematica, mma, nb, nbp | Mathematica |
m, matlab | Matlab |
mcfunction | mcfunction |
metal | Metal |
MZN, dzn, fzn, minizinc, mzn | MiniZinc |
mlir | MLIR |
def, m2, mod, modula2 | Modula-2 |
mc, monkeyc | MonkeyC |
morrowind, mwscript | MorrowindScript |
myghty, myt | Myghty |
mysql, sql | MySQL |
ASM, asm, nasm | NASM |
newspeak, ns2 | Newspeak |
conf, nginx | Nginx configuration file |
nim, nimrod | Nim |
nix, nixos | Nix |
h, m, obj-c, objc, objective-c, objectivec | Objective-C |
ml, mli, mll, mly, ocaml | OCaml |
m, octave | Octave |
openscad, scad | OpenSCAD |
org, orgmode | Org Mode |
conf, pacmanconf | PacmanConf |
perl, pl, pm, t | Perl |
inc, php, php3, php4, php5, php[345] | PHP |
inc, php, php[345], phtml | PHTML |
pig | Pig |
pc, pkgconfig | PkgConfig |
plpgsql | PL/pgSQL |
no-highlight, plain, text, txt | plaintext |
pony | Pony |
postgres, postgresql | PostgreSQL SQL dialect |
eps, postscr, postscript, ps | PostScript |
inc, pov | POVRay |
powerquery, pq | PowerQuery |
posh, powershell, ps1, psd1, psm1 | PowerShell |
ecl, pl, pro, prolog | Prolog |
promql | PromQL |
proto, protobuf | Protocol Buffer |
pp, puppet | Puppet |
bazel, bzl, jy, py, py3, pyi, python, python3, pyw, sage, sc, tac | Python |
py2, python2 | Python 2 |
BAS, bas, basic, qbasic | QBasic |
qbs, qml | QML |
R, Renviron, Rhistory, Rprofile, S, r, s, splus | R |
racket, rkt, rktd, rktl | Racket |
ragel | Ragel |
6pl, 6pm, nqp, p6, p6l, p6m, perl6, pl, pl6, pm, pm6, raku, rakudoc, rakumod, rakutest, t | Raku |
jsx, react | react |
re, reason, reasonml, rei | ReasonML |
reg, registry | reg |
rest, restructuredtext, rst | reStructuredText |
arexx, rex, rexx, rx | Rexx |
duby, gemspec, rake, rb, rbw, rbx, ruby | Ruby |
in, rs, rust | Rust |
SAS, sas | SAS |
sass | Sass |
scala | Scala |
scheme, scm, ss | Scheme |
sce, sci, scilab, tst | Scilab |
scss | SCSS |
smalltalk, squeak, st | Smalltalk |
smarty, tpl | Smarty |
snobol | Snobol |
sol, solidity | Solidity |
rq, sparql | SPARQL |
sql | SQL |
conf, squid, squid.conf, squidconf | SquidConf |
fun, sig, sml | Standard ML |
styl, stylus | Stylus |
svelte | Svelte |
swift | Swift |
automount, device, dnssd, link, mount, netdev, network, path, scope, service, slice, socket, swap, systemd, target, timer | SYSTEMD |
sv, svh, systemverilog | systemverilog |
tablegen, td | TableGen |
ASM, asm, tasm | TASM |
rvt, tcl | Tcl |
csh, tcsh | Tcsh |
src, termcap | Termcap |
src, terminfo | Terminfo |
terraform, tf | Terraform |
aux, latex, tex, toc | TeX |
thrift | Thrift |
toml | TOML |
tradingview, tv | TradingView |
t-sql, tsql | Transact-SQL |
tu, turing | Turing |
ttl, turtle | Turtle |
twig | Twig |
ts, tsx, typescript | TypeScript |
ts, typoscript | TypoScript |
typoscriptcssdata | TypoScriptCssData |
typoscripthtmldata | TypoScriptHtmlData |
bas, vb, vb.net, vbnet | VB.net |
v, verilog | verilog |
vhd, vhdl | VHDL |
exrc, gvimrc, vim, vimrc | VimL |
vue, vuejs | vue |
wdte | WDTE |
rss, svg, wsdl, wsf, xml, xsd, xsl, xslt | XML |
conf, xorg.conf | Xorg |
yaml, yml | YAML |
yang | YANG |
zig | Zig |
