Skip to content
Go back

Markdown Extended: Advanced Syntax Features

Explore advanced Markdown features including math formulas, KaTeX, syntax-highlighted code blocks, GitHub Alerts, abbreviations, definition lists, and keyboard shortcuts.

Beyond the basics, Markdown supports a rich set of extended features. This article demonstrates math typesetting, code blocks with advanced highlighting, GitHub-style alerts, and more.


Math Formulas

Inline Math

Use single dollar signs for inline math. For example, Einstein’s famous equation E=mc2E = mc^2 changed physics forever. The quadratic formula x=b±b24ac2ax = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} solves any quadratic equation. Euler’s identity eiπ+1=0e^{i\pi} + 1 = 0 is often called the most beautiful equation in mathematics.

Block Math

Use double dollar signs for display-mode math:

The Gaussian integral:

ex2dx=π\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}

Maxwell’s equations in differential form:

E=ρε0B=0×E=Bt×B=μ0J+μ0ε0Et\begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\ \nabla \cdot \mathbf{B} &= 0 \\ \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\ \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{aligned}

The Schrödinger equation:

itΨ(r,t)=H^Ψ(r,t)i\hbar \frac{\partial}{\partial t} \Psi(\mathbf{r}, t) = \hat{H} \Psi(\mathbf{r}, t)

KaTeX Examples

Matrices

A 3×3 identity matrix:

I3=(100010001)I_3 = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}

Matrix multiplication:

[abcd][efgh]=[ae+bgaf+bhce+dgcf+dh]\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} ae + bg & af + bh \\ ce + dg & cf + dh \end{bmatrix}

Integrals

Definite integral:

01x2dx=13\int_0^1 x^2 \, dx = \frac{1}{3}

Double integral:

Df(x,y)dA=abg1(x)g2(x)f(x,y)dydx\iint_D f(x, y) \, dA = \int_a^b \int_{g_1(x)}^{g_2(x)} f(x, y) \, dy \, dx

Contour integral:

CFdr=S(×F)dS\oint_C \mathbf{F} \cdot d\mathbf{r} = \iint_S (\nabla \times \mathbf{F}) \cdot d\mathbf{S}

Summations

Finite sum:

k=1nk=n(n+1)2\sum_{k=1}^{n} k = \frac{n(n+1)}{2}

Infinite series (Basel problem):

n=11n2=π26\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}

Taylor series expansion of exe^x:

ex=n=0xnn!=1+x+x22!+x33!+e^x = \sum_{n=0}^{\infty} \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots

Fractions and Binomials

Continued fraction:

ϕ=1+11+11+11+\phi = 1 + \cfrac{1}{1 + \cfrac{1}{1 + \cfrac{1}{1 + \cdots}}}

Binomial coefficient:

(nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k!(n-k)!}

Binomial theorem:

(x+y)n=k=0n(nk)xnkyk(x + y)^n = \sum_{k=0}^{n} \binom{n}{k} x^{n-k} y^k

Limits and Products

Limit definition of ee:

e=limn(1+1n)ne = \lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n

Wallis product:

π2=n=14n24n21\frac{\pi}{2} = \prod_{n=1}^{\infty} \frac{4n^2}{4n^2 - 1}

Code Blocks with Syntax Highlighting

JavaScript / TypeScript

async function fetchPosts(tag) {
  const response = await fetch(`/api/posts?tag=${encodeURIComponent(tag)}`);
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }
  const posts = await response.json();
  return posts.filter(post => !post.draft).sort((a, b) =>
    new Date(b.pubDatetime) - new Date(a.pubDatetime)
  );
}
javascript

Python

Rust

CSS


Code Block Advanced Features

Line Highlighting

Highlight specific lines to draw attention (using {1,3-5} syntax — support depends on your Markdown processor):

const config = {
  site: 'https://example.com',
  base: '/',
  integrations: [
    tailwind(),
    sitemap(),
  ],
};
javascript

Diff Notation

Show code changes with diff syntax:

- const greeting = "Hello, World!";
+ const greeting = "Hello, Astro!";

  function main() {
-   console.log(greeting);
+   console.log(`${greeting} 🚀`);
+   console.log("Welcome to the blog!");
  }
diff

Shell / Terminal Commands

# Create a new Astro project
npm create astro@latest my-blog

# Navigate to project directory
cd my-blog

# Install dependencies
pnpm install

# Start the development server
pnpm run dev

# Build for production
pnpm run build
bash

JSON Configuration

{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "jsx": "react-jsx",
    "jsxImportSource": "astro",
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"],
      "@components/*": ["src/components/*"]
    }
  }
}
json

GitHub Alerts

GitHub-style alerts provide visually distinct callouts for different types of information:

Note

This is a note alert. Use it for helpful information that users should be aware of, even when skimming content.

Tip

This is a tip alert. Use it for optional suggestions that help users be more successful.

Important

This is an important alert. Use it for crucial information needed for users to succeed.

Warning

This is a warning alert. Use it for urgent information that requires the user’s immediate attention to avoid problems.

Caution

This is a caution alert. Use it to advise about risks or negative outcomes of certain actions.

Alerts with Rich Content

Tip

Performance Tip: When building your Astro site, use the --remote flag to fetch content from remote sources:

pnpm run build --remote
bash

This can reduce build times by up to 60% on large sites.

Warning

Note: Blog content lives in src/data/blog/ (not src/content/). Import like this:

- import { getCollection } from 'astro:content';
+ import { getCollection } from 'astro:content';  // same API, new data/ directory
diff

Run npx astro migrate to automatically update your project.


Abbreviations

The HTML specification is maintained by the W3C.

*[HTML]: HyperText Markup Language *[W3C]: World Wide Web Consortium

Other common abbreviations in web development:

*[CSS]: Cascading Style Sheets *[JS]: JavaScript *[API]: Application Programming Interface *[SSR]: Server-Side Rendering *[SSG]: Static Site Generation


Definition Lists

Astro
A modern static site generator that allows you to build faster websites with less client-side JavaScript. It supports multiple UI frameworks and uses an island architecture.
Tailwind CSS
A utility-first CSS framework that provides low-level utility classes for building custom designs without writing custom CSS.
MDX
An authoring format that lets you use JSX components within Markdown documents, combining the simplicity of Markdown with the power of component-based UI.
TypeScript
A typed superset of JavaScript that compiles to plain JavaScript. It adds optional static typing and class-based object-oriented programming.

Keyboard Shortcuts

Display keyboard shortcuts with the <kbd> element:

Common Editor Shortcuts

ActionWindows / LinuxmacOS
SaveCtrl + S + S
UndoCtrl + Z + Z
RedoCtrl + Shift + Z + Shift + Z
FindCtrl + F + F
ReplaceCtrl + H + H
CommentCtrl + / + /
FormatShift + Alt + FShift + + F

VS Code Power Shortcuts

ActionShortcut
Command PaletteCtrl + Shift + P
Quick OpenCtrl + P
Toggle TerminalCtrl + `
Go to DefinitionF12
Peek DefinitionAlt + F12
Multi-cursorCtrl + D
Move LineAlt + /

Terminal Shortcuts

Navigate your terminal like a pro:


Wrapping Up

These extended Markdown features add significant expressive power to your writing. Math formulas bring technical precision, syntax-highlighted code blocks improve readability, and GitHub alerts create clear visual hierarchies. Combine these with the basic Markdown syntax to create polished, professional technical content.



Previous Post
Markdown Basics: A Complete Syntax Guide
Next Post
Markmap Mindmaps: Visual Thinking in Markdown

评论区

文明评论,共建和谐社区